DEV Community

Discussion on: Jetpack Compose Desktop rendering performances

Collapse
 
romainguy profile image
Romain Guy

Repeating what I mentioned on Slack: my suggestion was not to apply a translation to the Path object itself. Instead create one instance of the Path, and before drawing, translate the Canvas: canvas.withTranslate { drawPath(…) } or equivalent.

Thread Thread
 
gz_k profile image
Gaetan Zoritchak

Sorry for the mistake; I read your message too fast.

I tried your suggestion with one path and moving the canvas before drawing it. It’s still a little bit under the first implementation performances but more stable (no more freezing).

RenderingWith.Diamond -> {
    canvas.translate(x,y)
    drawPath(diamond, color)
    canvas.translate(-x,-y)
}
Enter fullscreen mode Exit fullscreen mode