Book description
No matter what platform or tools you use, the HTML5 revolution will soon change the way you build web applications, if it hasn't already. HTML5 is jam-packed with features, and there's a lot to learn. This book gets you started with the Canvas element, perhaps HTML5's most exciting feature. Learn how to build interactive multimedia applications using this element to draw, render text, manipulate images, and create animation.
Whether you currently use Flash, Silverlight, or just HTML and JavaScript, you'll quickly pick up the basics. Practical examples show you how to create various games and entertainment applications with Canvas as you learn. Gain valuable experience with HTML5, and discover why leading application developers rave about this specification as the future of truly innovative web development.
- Create and modify 2D drawings, text, and bitmap images
- Incorporate and manipulate video, and add audio
- Build a basic framework for creating a variety of games on Canvas
- Use bitmaps and tile sheets to develop animated game graphics
- Go mobile: port Canvas applications to iPhone with PhoneGap
- Explore ways to use Canvas for 3D and multiplayer game applications
Publisher resources
Table of contents
- Dedication
- A Note Regarding Supplemental Files
- Preface
- 1. Introduction to HTML5 Canvas
-
2. Drawing on the Canvas
- The Basic File Setup for This Chapter
- The Basic Rectangle Shape
- The Canvas State
- Using Paths to Create Lines
- Advanced Path Methods
- Compositing on the Canvas
- Simple Canvas Transformations
- Filling Objects with Colors and Gradients
- Filling Shapes with Patterns
- Creating Shadows on Canvas Shapes
- What’s Next
-
3. The HTML5 Canvas Text API
- Displaying Basic Text
- Setting the Text Font
- Text and the Canvas Context
- Text with Gradients and Patterns
- Width, Height, Scale, and toDataURL() Revisited
- Final Version of Text Arranger
- What’s Next
- 4. Images on the Canvas
-
5. Math, Physics, and Animation
- Moving in a Straight Line
- Bouncing Off Walls
- Curve and Circular Movement
- Simple Gravity, Elasticity, and Friction
- Easing
- What’s Next?
-
6. Mixing HTML5 Video and Canvas
- HTML5 Video Support
- Converting Video Formats
- Basic HTML5 Video Implementation
- Preloading Video in JavaScript
- Video and the Canvas
- Video on the Canvas Examples
- Animation Revisited: Moving Videos
- What’s Next?
-
7. Working with Audio
- The Basic <audio> Tag
- Audio Formats
- Audio Tag Properties, Functions, and Events
- Playing a Sound with No Audio Tag
- Creating a Canvas Audio Player
- Case Study in Audio: Space Raiders Game
- What’s Next
-
8. Canvas Game Essentials
- Why Games in HTML5?
- Our Basic Game HTML5 File
- Our Game’s Design
- Game Graphics: Drawing with Paths
- Animating on the Canvas
- Applying Transformations to Game Graphics
- Game Graphic Transformations
- Game Object Physics and Animation
- A Basic Game Framework
- Putting It All Together
- The player Object
- Geo Blaster Game Algorithms
- The Geo Blaster Basic Full Source
- Rock Object Prototype
- What’s Next
-
9. Combining Bitmaps and Sound
- Geo Blaster Extended
- Creating a Dynamic Tile Sheet at Runtime
-
A Simple Tile-Based Game
- Micro Tank Maze Description
- The Tile Sheet for Our Game
- The Playfield
- The Player
- The Enemy
- The Goal
- The Explosions
-
Turn-Based Game Flow and the State Machine
- GAME_STATE_INIT
- GAME_STATE_WAIT_FOR_LOAD
- GAME_STATE_TITLE
- GAME_STATE_NEW_GAME
- GAME_STATE_WAIT_FOR_PLAYER_MOVE
- GAME_STATE_ANIMATE_PLAYER
- GAME_STATE_EVALUATE_PLAYER_MOVE
- GAME_STATE_ENEMY_MOVE
- GAME_STATE_ANIMATE_ENEMY
- GAME_STATE_EVALUATE_ENEMY_MOVE
- GAME_STATE_EVALUATE_OUTCOME
- GAME_STATE_ANIMATE_EXPLODE
- GAME_STATE_CHECK_FOR_GAME_OVER
- GAME_STATE_PLAYER_WIN
- GAME_STATE_PLAYER_LOSE
- Simple Tile Movement Logic Overview
- Rendering Logic Overview
- Simple Homegrown AI Overview
- Micro Tank Maze Complete Game Code
- What’s Next
-
10. Mobilizing Games with PhoneGap
- Going Mobile!
-
Creating the iOS Application with PhoneGap
- Installing Xcode
- Installing PhoneGap
- Creating the BS Bingo PhoneGap Project in Xcode
- Testing the New Blank Application in the Simulator
- Integrating BS Bingo into the Project
- Setting the Orientation
- Changing the Banner and Icon
- Testing on the Simulator
- Adding in an iPhone “Gesture”
- Adding the Gesture Functions to index.html
- Testing on a Device
- Using Xcode to Target a Test Device
- Beyond the Canvas
- What’s Next
-
11. Further Explorations
- 3D with WebGL
- Multiplayer Applications with ElectroServer 5
- Conclusion
- Index
- About the Authors
- Colophon
- Copyright
Product information
- Title: HTML5 Canvas
- Author(s):
- Release date: May 2011
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9781449393908
You might also like
book
HTML5 Canvas Cookbook
Over 80 recipes to revolutionize the Web experience with HTML5 Canvas with this book and ebook …
book
Using SVG with CSS3 and HTML5
Using Scalable Vector Graphics (SVG) for illustrations only scratches the surface of this format’s potential on …
book
HTML5, JavaScript, and jQuery 24-Hour Trainer
Master web app development with hands-on practice and video demonstration HTML5, JavaScript, and jQuery 24-Hour Trainer …
book
HTML5 and JavaScript Projects: Build on your Basic Knowledge of HTML5 and JavaScript to Create Substantial HTML5 Applications
Build on your basic knowledge of HTML5 and JavaScript to create substantial HTML5 applications. Through the …