Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program API drawingect creates rectangles


May 19, 2021 WeChat Mini Program Development Document


Table of contents


WeChat small program API drawingect creates rectangles Drawing interfaces and methods


canvasContext.rect


Defined

Create a rectangle.

Tip : Draw fill() the real canvas using the stroke() or stroke() method.

Parameters

Parameters Type Description
Number The x coordinates in the upper left corner of the rectangular path
Y Number The y coordinates in the upper left corner of the rectangular path
width Number The width of the rectangular path
height Number The height of the rectangular path

Example

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

WeChat small program API drawingect creates rectangles

WeChat small program API drawingect creates rectangles Drawing interfaces and methods