Skip to content
此页目录
本文总阅读量

Canvas 状态

js
save()   保存当前环境的状态。   
restore()  返回之前保存过的路径状态和属性。

ctx.beginPath()
ctx.fillStyle="greenyellow"
ctx.fillRect(20,20,200,100)
ctx.save() // 保留当前的环境配置
ctx.scale(2,2)
ctx.beginPath()
ctx.fillStyle="red"
ctx.fillRect(20,20,200,100)
ctx.restore() // 打开保留环境的配置
ctx.beginPath()
ctx.fillStyle="blue"
ctx.fillRect(200,100,100,50)

评论

交流群