Save canvas then restore, why is that?

后端 未结 5 948
太阳男子
太阳男子 2021-01-31 02:32

I often see the following code

canvas.save().
canvas translate or rotate
some drawing
canvas.restore

I don\'t understand why we save and then

5条回答
  •  生来不讨喜
    2021-01-31 03:03

    I guess the simplest way to put it is:

    It removes the change in settings, but not the drawing itself.

    Settings can include scaling the canvas etc., and it restores the scaling to the initial state when you called canvas.save().

提交回复
热议问题