WeChat Open Platform

Mini Programs Documentation

canvasContext.fillRect

Definition

Fills a rectangle.

Tip: Use setFillStyle() to set the rectangle's fill color. If this is not set, the default is black.

Parameters

Parameter Type Description
x Number The x-coordinate of the top left corner of the rectangle path
y Number The y-coordinate of the top left corner of the rectangle path
width Number The width of the rectangle path
height Number The height of the rectangle path

Examples

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