02.06.2013 Views

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Canvas <strong>Animation</strong>s<br />

We can set the color <strong>of</strong> strokes (outlines) or fills, as well as drop-shadows using the<br />

following properties:<br />

Property Usage<br />

fillStyle Sets the color <strong>of</strong> the fill. Can be set to a CSS color, or a gradient object.<br />

shadowBlur Sets the amount <strong>of</strong> blur on the shadow.<br />

shadowColor Sets the color <strong>of</strong> the shadow. Can be set to a CSS color or a gradient<br />

object.<br />

shadowOffsetX Sets the relative position <strong>of</strong> the shadow along the x axis.<br />

shadowOffsetY Sets the relative position <strong>of</strong> the shadow along the y axis.<br />

strokeStyle Sets the color <strong>of</strong> the stroke. Can be set to a CSS color, or a gradient object.<br />

These properties can be set on paths and text as well. They aren't limited strictly to the<br />

native shape.<br />

Paths<br />

Any shape other than a rectangle must be drawn using a path. This gives us a flexible way<br />

<strong>of</strong> drawing custom, complex shapes. Methods used for creating paths include:<br />

Method Usage<br />

arc(a, b, c, d, e, f) Draws a circular sub-path. Arguments a and b are the<br />

starting coordinates <strong>of</strong> the sub-path, c is the radius,<br />

d is the starting angle in radians, and e is the ending<br />

angle in radians. The last parameter f accepts a Boolean<br />

indicating whether the sub-path should be drawn<br />

anticlockwise or not.<br />

arcTo(a, b, c, d, e) Draws a circular sub-path to a specified point. Arguments<br />

a and b are the starting coordinates, c and d are the<br />

ending coordinates. Argument e is the radius.<br />

beginPath() Starts a new path.<br />

bezierCurveTo(a, b, c, d, e, f) Draws a sub-path along a Bezier curve, which is a curve<br />

featuring two control points. Arguments a, b, c, and d<br />

represent the coordinates <strong>of</strong> the two control points and<br />

arguments e and f represent the end coordinates <strong>of</strong> the<br />

sub-path.<br />

closePath() Closes the path by drawing a line from the current<br />

position to the starting position <strong>of</strong> the first sub-path in<br />

the current path list.<br />

[ 268 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!