codecamp

微信小程序API 绘图rect创建矩形

微信小程序 canvas接口和方法绘图接口和方法


canvasContext.rect


定义

创建一个矩形。

Tip: 用fill()或者stroke()方法将矩形真正的画到 canvas 中。

参数

参数类型说明
xNumber矩形路径左上角的x坐标
yNumber矩形路径左上角的y坐标
widthNumber矩形路径的宽度
heightNumber矩形路径的高度

例子

const ctx = wx.createCanvasContext('myCanvas')
ctx.rect(10, 10, 150, 75)
ctx.setFillStyle('red')
ctx.fill()
ctx.draw()


微信小程序 canvas接口和方法绘图接口和方法

微信小程序API 绘图setMiterLimit(设置最大倾斜)
微信小程序API 绘图fillRect(填充矩形)
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定