We can create a black rectangle on a canvas using fillRect()
.
As you can see, we provide four arguments to the fillRect()
method. These are the values for the x-coordinate,
y-coordinate,
widthand
height` respectively for the rectangle.
So, in the above example, the rectangle's upper-left corner is at 10 on the x-axis, the rectangle's upper-left corner is at 10 on the y-axis, the width of the rectangle is 300px and the length of the rectangle is 50px.