大学生之家,大学生资讯发布平台
大学生之家

小程序画布恢复之前保存的绘图上下文 CanvasContext.restore()

    发布时间:2025-04-12    阅读:
    来源:大学生之家
恢复之前保存的绘图上下文。

小程序插件:支持
示例代码

const ctx = wx.createCanvasContext('myCanvas')
 
// save the default fill style
ctx.save()
ctx.setFillStyle('red')
ctx.fillRect(10, 10, 150, 100)
 
// restore to the previous saved state
ctx.restore()
ctx.fillRect(50, 50, 150, 100)
 
ctx.draw()
计算机学习推荐
  • 扫一扫 分享悦读 ➤
  • 扫码可以分享到微信 qq朋友圈
计算机学习热点