1j01 / jspaint

🎨 Classic MS Paint, REVIVED + ✨Extras
https://jspaint.app/about
MIT License
7.25k stars 568 forks source link

Technical question - is the canvas part redrawn all of the time? #165

Closed Zireael07 closed 4 years ago

Zireael07 commented 4 years ago

Just wondering, is it redrawn if I click around the menus (i.e. interact with other parts of the app)? I tried looking around in the code but couldn't find it, tbh.

1j01 commented 4 years ago

Nothing is redrawn all the time, but some things are redrawn when you move the mouse around the canvas, for the brush preview, or when you scroll/zoom, for the grid as well as the brush preview. These are updated with update_helper_layer, which avoids updating twice in one animation frame so it can be called from multiple places in the code without too much worry.

1j01 commented 4 years ago

So in other words, it's not perfectly efficient. But the canvas state is persistent. It doesn't need to redraw the brush strokes constantly, just new brush strokes.

Let me know if this answered your question or if you want to know more.