You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use .save() and .restore() as the first and last calls during drawing to reset my canvas state. Since I call save at the beginning to store the initial state basically. Outside the two calls I can cleanly clearRect just before first .save() when drawing again.
Would .reset() be like resetting to initial state in the same way as these state related methods? Wouldn't it surprise developers if it does extra things like clearing the canvas?
Perhaps separately a simple .clear() that is like .clearRect() but implies the whole canvas instead of having to define the coordinates awkwardly?
There is already a separation between what is canvas state and clearing canvas content and I think it would be a mistake to mix the two.
So my suggestion is:
.reset() — restores the state of the canvas to the initial state, clearing the entire state stack
.clear() — erases the pixels in the entire canvas area by setting them to transparent black
The text was updated successfully, but these errors were encountered:
I use
.save()
and.restore()
as the first and last calls during drawing to reset my canvas state. Since I call save at the beginning to store the initial state basically. Outside the two calls I can cleanly clearRect just before first .save() when drawing again.Would
.reset()
be like resetting to initial state in the same way as these state related methods? Wouldn't it surprise developers if it does extra things like clearing the canvas?Perhaps separately a simple
.clear()
that is like.clearRect()
but implies the whole canvas instead of having to define the coordinates awkwardly?There is already a separation between what is canvas state and clearing canvas content and I think it would be a mistake to mix the two.
So my suggestion is:
.reset()
— restores the state of the canvas to the initial state, clearing the entire state stack.clear()
— erases the pixels in the entire canvas area by setting them to transparent blackThe text was updated successfully, but these errors were encountered: