In this tutorial, we will present the html canvas and all its methods. For an alternative, the standard reference is the Mozilla canvas tutorial, although many other interesting tutorials can be found on the web.

This tutorial will focus on 2d drawings; 3d drawings will be done using WebGL and covered in other tutorials.

We assume that you are familiar with javascript. In all of our examples, we will use an embedded html canvas as described by the following html code


If you feel curious (and adventurous!), you can view (and modify!) the actual code used to generate the window on the right by clicking on the image above. However it will likely seem a bit overwhelming at this time ... but hopefully the canvas-related methods used should become familiar by the time you complete this tutorial.


Your notebook

Keep your personal notes here. These notes are stored by your browser on your own computer, and will be available from any page on this site. You can choose to use html syntax for formatting.


HTML Add Note


  1. Introduction
  2. Before we begin
  3. Drawing simple lines
  4. Drawing coloured lines
  5. Line width
  6. Line cap
  7. Multiple lines
  8. Joining lines
  9. Curved lines: arcTo()
  10. Curved lines: arc()
  11. Curved lines: quadraticCurveTo()
  12. Curved lines: bezierCurveTo()
  13. Drawing rectangles
  14. Filling shapes
  15. Linear Gradient
  16. Radial Gradient