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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Download from Wow! eBook <br />

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

Method Usage<br />

createLinearGradient(a, b, c, d) Creates a linear gradient between two points.<br />

Arguments a and b are the start coordinates <strong>of</strong><br />

the gradient, c and d are the end coordinates.<br />

createRadialGradient(a, b, c, d, e, f) Creates a radial gradient between two circles.<br />

Arguments a and b are the start coordinates,<br />

and c is the radius <strong>of</strong> the first circle. Arguments<br />

d and e are the start coordinates <strong>of</strong> the second<br />

circle, and f is its radius.<br />

addColorStop(a, b) Adds color to a gradient. The first argument is a<br />

decimal between 0.0 and 1.0 and is the relative<br />

position within the gradient to add the color.<br />

The second argument is the color to use.<br />

The drawImage() and createPattern() methods are very similar in that they are both<br />

used to draw an image on the . The difference is that the pattern is repeated. The<br />

gradient methods return a gradient object which can then be used as the fill or stroke style<br />

for a shape.<br />

Text<br />

Text strings can be written to the canvas, but there is little styling we can perform on them<br />

as there is no associated box model with the text so that means no padding, margins, or<br />

borders. Although, we can set the font and alignment (and the fill color or stroke color using<br />

other properties). API methods include:<br />

Method Usage<br />

fillText(a, b, c) Creates solid text strings on the . The first argument is<br />

the text to write and arguments b and c are the start coordinates <strong>of</strong><br />

the text.<br />

measureText(a) Measures the specified text string and returns a metrics object with<br />

a width property.<br />

stroketext(a, b, c) Creates outline text strings on the . The first argument is<br />

the text to write and arguments b and c are the start coordinates <strong>of</strong><br />

the text.<br />

[ 270 ]

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

Saved successfully!

Ooh no, something went wrong!