0

In the method fillRect(x,y,w,h); , what does (x,y) exactly points to on the rectangle?

var c=document.getElementById("canvas1"); var ctx=c.getContext("2d"); ctx.fillRect(20,20,100,100);

4th Nov 2017, 6:54 AM
Abdussamad Nasir
Abdussamad Nasir - avatar
3 Answers
+ 1
Top left corner
4th Nov 2017, 7:02 AM
Enzo
Enzo - avatar
+ 12
x is the x-coordinate of the canvas, and y is the y-coordinate. The upper-left corner of the canvas has the coordinates (0, 0) ctx.fillRect(20, 20, 100, 100) means: start at the the position(20, 20) and draw a 100x100 rectangle!
4th Nov 2017, 7:07 AM
Dev
Dev - avatar
+ 1
Thank you
4th Nov 2017, 7:03 AM
Abdussamad Nasir
Abdussamad Nasir - avatar