Skip to Content
JavaScript for Kids
book

JavaScript for Kids

by Nick Morgan
December 2014
Beginner content levelBeginner
336 pages
6h 32m
English
No Starch Press
Content preview from JavaScript for Kids

Chapter 13. The Canvas Element

JavaScript isn’t all about playing with text and numbers. You can also use JavaScript to draw pictures with the HTML canvas element, which you can think of as a blank canvas or sheet of paper. You can draw almost anything that you want on this canvas, such as lines, shapes, and text. The only limit is your imagination!

In this chapter, you’ll learn the basics of drawing on the canvas. In the following chapters, we’ll build on our knowledge to create a canvas-based JavaScript game.

Creating a Basic Canvas

As our first step in using the canvas, create a new HTML document for the canvas element, as shown in the following listing. Save this document as canvas.html:

 <!DOCTYPE html> <html> <head> <title>Canvas</title> </head> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript For Kids For Dummies

JavaScript For Kids For Dummies

Chris Minnick, Eva Holland
JavaScript Projects for Kids

JavaScript Projects for Kids

Syed Omar Faruk Towaha

Publisher Resources

ISBN: 9781457189838Errata Page