Here I am going to explain save and restore within a Canvas as best I can. Without a doubt, this was the hardest thing to get my head around, so it’ll certainly be useful to explain here what it could be used for, why it is useful, and how to implement it.
Category: HTML5
List of posts relating to HTML5
HTML5 Canvas: Transformations
With transformations, shapes drawn upon a Canvas can be moved to another spot on the Canvas, rotated, enlarged and reduced in size. I’ll be looking at how these transformations are achieved in this post, and explaining how they are applied.
HTML5 Canvas: Shadows
In this post, I shall be looking at applying shadows to shapes and text within a Canvas. Shadows can be applied to any shape and can be given a colour, offset from the shape they are applied to and the blur of the shadow controlled.
HTML5 Canvas: Patterns
Patterns in the form of repeating images can be applied to shapes and outlines of shapes within a Canvas. In this post I shall be exploring the steps to achieve this.
HTML5 Canvas: Gradients
In this post, I’m going to look at linear and radial gradients and the methods required to apply them as a fill to various different shapes within a Canvas. Gradients are very versatile; they can include multiple colour stops and be positioned within a shape.
HTML5 Canvas: Styles
Here I’m going to experiment with adding different styles onto shapes and lines within a Canvas – looking at colour fills, opacity of fills, outlines/borders and linejoins and linecaps for lines and outlines.
HTML5 Canvas: Text
Text can be added to a Canvas element. Text within a Canvas can’t be controlled a huge amount, but we’ll discover here what can be achieved.
HTML5 Canvas: Erasing shapes
As well as drawing shapes on a Canvas, shapes can also be erased. For the examples in this post, I have initially laid down a filled background rectangle, and erased shapes out of it to demonstrate.