September 2024
Beginner to intermediate
985 pages
35h 37m
English
This chapter has shown how to use JavaScript to create graphics within the browser window. The main points here are as follows:
Using the Canvas API, you can create graphics within a defined drawing area in the browser window.
The <canvas> element provides one or multiple rendering contexts through which the drawing area or its contents can be manipulated.
For drawing rectangles, the Canvas API offers three methods:
fillRect() creates a rectangle filled with a previously defined background color.
strokeRect() draws the outline of a rectangle (also with a previously defined frame color).
clearRect() removes everything from the drawing area that is inside the defined rectangle.
All other geometric shapes must be ...
Read now
Unlock full access