Book
Submodule 15.1: Canvas HTML element
Submodule 15.1: Canvas HTML element
Completion requirements
View
- Text
- Drawing
- Image
CanvasRenderingContext2D
We need CanvasRenderingContext2D
to create a surface in which we can draw on.
The steps to use CanvasRenderingContext2D are:
var canvas0 = document.getElementById("mycanvas0");
var context0= canvas.getContext('2d');
/* context0= will be your context */
You only need to do this once and then you can keep using it to do all your drawing.
In the next lesson, we will use this surface to start drawing.