O'Reilly logo

HTML5 Web Application Development By Example Beginner's guide by J.M. Gustafson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding drawing actions

You may have noticed that when you changed an option, the next time you drew something the options applied to all of the previous lines that were drawn. That's not a very good user experience. The user expects that when they change the pen options it will only apply to the next thing they draw, not everything.

In order to get that to work properly we will need to add more data to each action than just a list of points. We also need to know the color, width, and opacity to draw the points with. For that we need an object to hold all of these values.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required