HTML5 APPLICATIONS DEVELOPMENT MANUAL

(lu) #1

28 - Working with Images, Shapes, and


Other Graphics


JavaScript can display different types of graphics, from JPG and PNG


files to shapes like


boxes and circles. One method is to use thecreateElement()method as shown in


chapter 26.


Manipulating the Canvas with JavaScript


Recall that the canvas element is used to create a container for


graphics.


With JavaScript, you can manipulate the container and draw graphics


dynamically.


To draw a canvas object, you use the getElementById() function to


access the canvas and the canvas.getContext to create the object.


<!DOCTYPE html>






Free download pdf