rect()

Drawing Shapes Using HTML5 Canvas - Part 2: Drawing a Rectangle

In this lesson I will show you how to draw a rectangle using the HTML5 canvas. The process builds upon Lesson 1 where we created the canvas.

The process for drawing a rectangle is relatively straightforward but it does help to understand the canvas coordinate system and some simple geometry.