What's the purpose of Canvas.Context Save and Restore in this example?

后端 未结 2 560
自闭症患者
自闭症患者 2021-02-07 04:46

This page shows some animations in HTML5 canvas. If you look at the source of the scroller, there\'s a statement to save the context after clearing the rectangle and restoring i

2条回答
  •  生来不讨喜
    2021-02-07 05:28

    The context save() saves stuff like transformation color among other stuff. Then you can change the context and restore it to have the same as when you saved it. It works like a stack so you can push multiple canvas states onto the stack and recover them. http://html5.litten.com/understanding-save-and-restore-for-the-canvas-context/

提交回复
热议问题