微信小程序API绘图rect,用fill()或者stroke()方法创建矩形
2017-12-22
导读:绘图接口和方法 canvasContext.rect 定义 创建一个矩形。 Tip : 用 fill() 或者 stroke() 方法将矩形真正的画到 canvas 中。 参数 参数 类型 说明 x Number 矩形路径左上角的x坐标 y Number 矩形路径左上...
canvasContext.rect
定义
创建一个矩形。
Tip: 用fill()
或者stroke()
方法将矩形真正的画到 canvas 中。
参数
参数 | 类型 | 说明 |
---|---|---|
x | Number | 矩形路径左上角的x坐标 |
y | Number | 矩形路径左上角的y坐标 |
width | Number | 矩形路径的宽度 |
height | Number | 矩形路径的高度 |
例子
const ctx = wx.createCanvasContext('myCanvas')
ctx.rect(10, 10, 150, 75)
ctx.setFillStyle('red')
ctx.fill()
ctx.draw()
更多微信小程序开发教程,可以关注hi小程序。
第二部分:如何开通一个小商店