Section 2.6 Canvas in HTML5
Learning Objectives
After you have completed this section, you should be able to
- draw various lines and shapes on your web pages for web applications.
- manipulate various lines and shapes in different ways for your needs.
- create an HTML5 canvas-based game or similar web applications with sound and collision detection capabilities.
Activities
- Carefully read the learning objectives.
- Watch the presentation for the section;
- Read Chapter 14, HTML5: Introduction to canvas.
- Find answers to the study questions below.
- Do exercises 14.10, 14.11, 14. 17, 14.22, 14.25, 14.36, and 14.53 in Chapter 14.
Study Questions
- What is an HTML5 canvas?
- What is the canvas element in HTML5?
- What is the canvas coordinate system used in HTML5?
- How are the units in the canvas coordinate system measured?
- How do you create a new canvas in HTML5?
- How do you draw a rectangle on an HTML5 canvas?
- How do you draw lines, arcs, and circles?
- How do you draw shadows in HTML5?
- How do you draw quadratic curves and Bezier curves in HTML5?
- How do you draw linear gradients in a canvas?
- How do you draw radial gradients in a canvas?
- How do you draw an image to a canvas?
- How can you manipulate an image drawn on a canvas?
- How do you draw patters on a canvas?
- How do you scale and translate a shape?
- How do you rotate a shape to create an animation?
- What can you do with the transform method?
- How do you draw text on a canvas?
- How do you re-size a canvas to fit a browser window?
- What is alpha transparency? How do you do it?
- How do you control the layering of shapes and images drawn on a canvas?
- What are the differences between HTML5 canvas and scalable vector graphics (SVG)?
Review
Do the self-review exercises for Chapter 14.
Summary
Read the Chapter 14 summary.