CanvasContext.rect
Draw a rect. Use fill()
or stroke()
to draw the rect to canvas.
Parameters
It is Object type.
Property | Type | Description |
x | Number | The x coordinate of left-upper corner of the rect. |
y | Number | The y coordinate of left-upper corner of the rect. |
width | Number | The width of the rect. |
height | Number | The height of the rect. |
Sample Code
copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas')
ctx.rect(20, 20, 250, 80)
ctx.setFillStyle('blue')
ctx.fill()
ctx.draw()