WeChat Open Platform

Mini Programs Documentation

canvasContext.strokeRect

Definition

Draws a rectangle (without fill).

Tip: Use setFillStroke() to set the rectangle line color. If this is not set the default is black.

Parameters

Parameter Type Range 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

Example

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