View Full Version : What's so handy about saving canvas drawing state?

11-15-2012, 02:41 PM
Right, so I've been reading about saving canvas drawing states and I understand how it works, but I just don't get the use of it when compared to setting it manually...

Instead of writing restore(), re-writing the color value would do the same thing. And whith restore it isn't immediatly obvious what color is set, but when writing out the color it is. So obviously I'm missing what's so handy about this state saving bussiness... Can somebody please enlighten me?


11-15-2012, 02:52 PM
It's not only color. The graphics state of a canvas includes fillStyle, strokeStyle, lineWidth, and lineJoin

11-16-2012, 02:02 PM
I see, thanks! For now I guess I prefer to reset everything manually as I can quickly edit single elements like lineWidth directly where it matters.

Does it make any difference speed-wise if I use the stack or reset elements manually?

rnd me
11-17-2012, 12:02 AM
you may want to try a 3000X4000 image and see if you notice a performance diff between the two.