CanvasContext.fillRect

Fill the rect.
setFillStyle() is used to set the color of the fill, by default, its color is black.

Parameters

It is Object type.

PropertyTypeDescription
xNumberThe x coordinate of left-upper corner of rect.
yNumberThe y coordinate of left-upper corner of rect.
widthNumberThe width of the rect.
heightNumberThe height of the rect.

Sample Code

copy
//.js
const ctx = my.createCanvasContext('awesomeCanvas')
ctx.fillRect(20, 20, 250, 80)
ctx.setFillStyle('blue')
ctx.draw()