2***@qq.com
2***@qq.com
  • 发布:2022-07-25 17:14
  • 更新:2022-08-11 18:10
  • 阅读:174

canvas绘制问题

分类:uni-app

在for循环中绘制画布 每次旋转之后会往上平移一段距离

ctx.save()  
ctx.translate(item.x / 2, item.y / 2)  
ctx.strokeRect(0, 0, item.width / 2, item.height / 2)  
ctx.translate(item.x / 4, item.y / 4)  
ctx.rotate(30 * Math.PI / 180)  
ctx.fillRect(-item.x / 4, -item.y / 4, item.width / 2,item.height / 2)  
ctx.restore()

图一是不旋转绘制的结果 图二就是如上代码绘制的结果

2022-07-25 17:14 负责人:无 分享
已邀请:
DCloud_UNI_WZF

DCloud_UNI_WZF

提供下测试工程

  • 2***@qq.com (作者)

    这个已经不需要 但是uni的画布操作编译到支付宝没有效果

    2022-08-13 13:24

要回复问题请先登录注册