Fillrect (x, y, width, height) draws a filled rectangle. Web there are three functions that draw rectangles on the canvas: After deciding the point where to begin to draw your triangle ( the first vertex is in the center of the canvas in this case ) and the position of the second.