Save canvas then restore, why is that?

后端 未结 5 956
太阳男子
太阳男子 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:13

    When you have a background composed of multiple objects, a great way is to save this "static" background and only redraw objects that changed. This saves (processor) time.

提交回复
热议问题