jQuery 1.4 Animation Techniques - Index of
jQuery 1.4 Animation Techniques - Index of jQuery 1.4 Animation Techniques - Index of
Download from Wow! eBook context.lineWidth = 1; function makeStripe(props) { context.beginPath(); context.moveTo(props.startX, props.startY); context.lineTo(props.line1X, props.line1Y); context.lineTo(props.line2X, props.line2Y); context.lineTo(props.line3X, props.line3Y); context.fill(); context.closePath(); } setTimeout(function() { makeStripe({ startX: 50, startY: 50, line1X: 195, line1Y: 125, line2X: 165, line2Y: 125, line3X: 50, line3Y: 66 })}, 1); setTimeout(function() { makeStripe({ startX: 450, startY: 50, line1X: 305, line1Y: 125, line2X: 275, line2Y: 125, line3X: 422, line3Y: 50 })}, 50); setTimeout(function() { makeStripe({ startX: 450, startY: 250, line1X: 310, line1Y: 175, line2X: 335, line2Y: 175, line3X: 450, line3Y: 235 })}, 100); setTimeout(function() { makeStripe({ startX: 50, startY: 250, line1X: 200, line1Y: 175, line2X: 225, line2Y: 175, line3X: 80, line3Y: 250 })}, 150); }, growVertical = function() { if (height < 100 || width < 200) { if (height < 100) { context.beginPath(); context.moveTo(pos.up.x, pos.up.y); [ 287 ] Chapter 10
Canvas Animations }, context.lineTo(pos.up.x, pos.up.y - 2); context.moveTo(pos.down.x, pos.down.y); context.lineTo(pos.down.x, pos.down.y + 2); context.stroke(); context.closePath(); height = height + 2; pos.up.y = pos.up.y - 2; pos.down.y = pos.down.y + 2; } if (width < 200) { context.beginPath(); context.moveTo(pos.left.x, pos.left.y); context.lineTo(pos.left.x - 2, pos.left.y); context.moveTo(pos.right.x, pos.right.y); context.lineTo(pos.right.x + 2, pos.right.y); context.stroke(); context.closePath(); width = width + 2 pos.left.x = pos.left.x - 2; pos.right.x = pos.right.x + 2; } } else { clearInterval(crossInt); addStripes(); } }, crossInt = setInterval( function() { growVertical() }, 1); What just happened? Again, we have an outer inline function (called redCross()) containing some properties that set the color and line styles, and some nested functions that will be used to draw the red cross and the four custom shapes. As with the previous function, we declare width and height control variables, and an object called pos containing the starting positions for the lines that make up the cross. The cross is drawn first with the growVertical() function. This function is very similar to the function in the last section of code. We draw four lines starting in the middle of the rectangle which radiate to the top and bottom center, and the right and left center. [ 288 ]
- Page 257 and 258: CSS3 Animations Skew Remember the t
- Page 259 and 260: CSS3 Animations Calculating the sin
- Page 261 and 262: CSS3 Animations The filter property
- Page 263 and 264: CSS3 Animations If, like me, you th
- Page 265 and 266: CSS3 Animations } el.filters.item("
- Page 267 and 268: CSS3 Animations An unfortunate prob
- Page 269 and 270: CSS3 Animations The context of this
- Page 271 and 272: CSS3 Animations Time for action - i
- Page 273 and 274: CSS3 Animations The first variable
- Page 275 and 276: CSS3 Animations Time for action - a
- Page 277 and 278: Download from Wow! eBook CSS3 Anim
- Page 279 and 280: CSS3 Animations We also have to upd
- Page 281 and 282: CSS3 Animations flatMatrix[3] = fla
- Page 283 and 284: CSS3 Animations When updating the s
- Page 285 and 286: CSS3 Animations translate translate
- Page 287 and 288: Canvas Animations Subjects that we'
- Page 289 and 290: Canvas Animations We can set the co
- Page 291 and 292: Download from Wow! eBook Canvas An
- Page 293 and 294: Canvas Animations All imageData obj
- Page 295 and 296: Canvas Animations context.beginPath
- Page 297 and 298: Canvas Animations For the next part
- Page 299 and 300: Canvas Animations Time for action -
- Page 301 and 302: Canvas Animations 3. Save the new p
- Page 303 and 304: Canvas Animations Time for action -
- Page 305 and 306: Canvas Animations Once the rectangl
- Page 307: Canvas Animations We then define tw
- Page 311 and 312: Canvas Animations Creating a canvas
- Page 313 and 314: Canvas Animations Time for action -
- Page 315 and 316: Canvas Animations What just happene
- Page 317 and 318: Canvas Animations What just happene
- Page 319 and 320: Canvas Animations aliens.splice(x,
- Page 321 and 322: Canvas Animations Pop quiz - creati
- Page 323 and 324: Download from Wow! eBook
- Page 325 and 326: Pop Quiz Answers Using fadeToggle()
- Page 327 and 328: Pop Quiz Answers Using slideToggle
- Page 329 and 330: Pop Quiz Answers Implementing the p
- Page 331 and 332: Pop Quiz Answers Animating the canv
- Page 333 and 334: show() or hide() method, triggering
- Page 335 and 336: cssHooks using 239 cssHooks feature
- Page 337 and 338: fading animations 20 flicker effect
- Page 339 and 340: proximity animations about 207 exte
- Page 341 and 342: scaleY 232 skew 232 skewX 232 skewY
- Page 343 and 344: jQuery 1.4 Reference Guide ISBN: 97
Canvas <strong>Animation</strong>s<br />
},<br />
context.lineTo(pos.up.x, pos.up.y - 2);<br />
context.moveTo(pos.down.x, pos.down.y);<br />
context.lineTo(pos.down.x, pos.down.y + 2);<br />
context.stroke();<br />
context.closePath();<br />
height = height + 2;<br />
pos.up.y = pos.up.y - 2;<br />
pos.down.y = pos.down.y + 2;<br />
}<br />
if (width < 200) {<br />
context.beginPath();<br />
context.moveTo(pos.left.x, pos.left.y);<br />
context.lineTo(pos.left.x - 2, pos.left.y);<br />
context.moveTo(pos.right.x, pos.right.y);<br />
context.lineTo(pos.right.x + 2, pos.right.y);<br />
context.stroke();<br />
context.closePath();<br />
width = width + 2<br />
pos.left.x = pos.left.x - 2;<br />
pos.right.x = pos.right.x + 2;<br />
}<br />
} else {<br />
clearInterval(crossInt);<br />
addStripes();<br />
}<br />
},<br />
crossInt = setInterval( function() { growVertical() }, 1);<br />
What just happened?<br />
Again, we have an outer inline function (called redCross()) containing some properties<br />
that set the color and line styles, and some nested functions that will be used to draw the<br />
red cross and the four custom shapes. As with the previous function, we declare width and<br />
height control variables, and an object called pos containing the starting positions for the<br />
lines that make up the cross. The cross is drawn first with the growVertical() function.<br />
This function is very similar to the function in the last section <strong>of</strong> code. We draw four lines<br />
starting in the middle <strong>of</strong> the rectangle which radiate to the top and bottom center, and the<br />
right and left center.<br />
[ 288 ]