Viewers: in countries Watching now:
One of the most exciting additions that HTML5 offers to designers is the ability to draw free-form graphics on a drawing surface known as the Canvas. In this course, author Joe Marini introduces the technical concepts behind Canvas and shows how to perform drawing operations directly in a web page. The course covers drawing basic and complex shapes, setting colors and styles, adding shadows, patterns, and gradients, more advanced techniques such as scaling, rotating, and compositing objects, and how to incorporate Canvas elements in a slideshow and an animation.
Before we get into working with canvas in the rest of the course, let's take a look at some of the real-world examples that people have built using canvas to achieve effects and drawing operations that used to require native plug-ins like Silverlight and Flash but can now be done using modern browsers and HTML5. This example is called canvasMol. It's on a web site called alteredqualia.com. Basically, this shows how canvas can be used to model molecules on a drawing surface.
So let's take a look at some ones. Here's one of my favorite ones; here's Caffeine. So you can see that what's happening here is when I click on a molecule over here in this list, this canvas drawing surface pops up and it shows me the molecule for that particular item. In this case, this is the caffeine molecule. I can use the mouse to grab this thing and move it around. And I can choose some other ones. Here's one, Fructose, another one of my favorites. So you can see now I bring up another canvas, the frame rate slows down a little bit because this drawing is happening in real time, and the more canvases you have on the drawing surface, the more processing power it takes.
So let's add another one little one. Let's add Lycopene, and then we can scroll down and see that. That's a pretty fairly complex molecule, but you get the idea here. What's happening is the canvas is being used to render each one of these molecular bonds with individual atoms. You can see that they're all shaded a certain way, and they're rotating. Each one of the canvases responds to the mouse. And we can add one more over here from the list. Let's go ahead and add Penicillin. So I can just go ahead and add each one of these in succession, and what's happening is a new little window is being popped up with the canvas inside of it.
And you can see that each one of the canvases is now drawing each molecule rotating in real time. Each one responds to the mouse. You can see that as I add more canvases, the drawing rate slows a little bit, but not very much; it's still highly usable. Each one is still also pretty responsive. So this is a really great example of something that would've probably required a plug-in in the past but is now just happening natively using canvas in HTML5.
There are currently no FAQs about HTML5: Graphics and Animation with Canvas.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.