Abstract
In this chapter, we will learn how to “draw” on a web page—or specifically, display arbitrary shapes using the canvas element. We will experiment with the drawing API, trying the most common things, such as drawing a line and filling a rectangle with the gradient fill. The code from this chapter serves as the basis for the complete game that we create in Chapter 3: Four Balls, a web version of a popular logical game where players try to arrange a line of four, same-colored tokens to win. (If you’re eager to take a peek at the final result, look at the first page of the next chapter.) We learn how to create the game’s visuals—the board and the tokens—in this chapter.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Rights and permissions
Copyright information
© 2012 Juriy Bura and Paul Coates
About this chapter
Cite this chapter
Bura, J. (2012). Graphics in the Browser: The Canvas Element. In: Pro Android Web Game Apps. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4302-3820-1_2
Download citation
DOI: https://doi.org/10.1007/978-1-4302-3820-1_2
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4302-3819-5
Online ISBN: 978-1-4302-3820-1
eBook Packages: Professional and Applied ComputingProfessional and Applied Computing (R0)Apress Access Books