HTML GraphicsLesson 47Free preview
HTML Canvas
This lesson is part of HTML · All levels
Summary
The <canvas> element provides an image field that can be programmatically drawn using JavaScript. Canvas is bitmap, meaning each pixel is drawn and the result cannot be edited as a separate object. Suitable for game graphics, interactive diagrams, or simple visual effects on a page.
Key points
- <canvas> creates an image field that works with JavaScript
- Canvas sizes are set by the width and height attributes
- The basic image uses getContext("2d") and then commands like fillRect
- The result of the canvas is bitmap and cannot be changed as an object
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.