Eight Small Lines (Gandhi Quotes demo)
A virtual camera reads eight short lines, then their full stops morph into pebbles and a flower.
What you are seeing
A white panel on black. After Start, the view moves between eight short handwritten lines set at different angles, about patience, small steps and careful work. The lines then spin away while their full stops grow into dark pebbles and reshape into a black eight-petal flower above the title Eight small lines.
How it works
The camera class visits each line in turn, using the bounding box and rotation of the text to frame it.
When a line has been read, a small dot appears on its full stop.
All paths share one command structure, so each dot can morph into a pebble and then a petal by interpolating coordinates.
The text flies out while the shapes move, and a per-letter effect brings in the title.
History
Posted on October 5, 2010, as Gandhi Quotes. The original showed quotations attributed to Gandhi and ended on a portrait drawn by a friend of the author. Those were not cleared, so this version has new text and a new final shape.
Source
/gandhi-quotes/gandhi-quotes.xhtml
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Eight small lines (the Gandhi Quotes demo, with new text)</title>
<meta name="description" content="A virtual camera reads eight short lines of original text, then their full stops morph into pebbles and an eight-petal flower."/>
<link rel="icon" href="../res/2.0/images/favicon.svg" />
<link rel="icon alternate" href="../res/2.0/images/favicon.png" />
<script type="text/javascript" src="../res/3.0/scripts/compat/restore.js"></script>
<script type="text/javascript" src="../res/3.0/scripts/yui/yui/yui-debug.js"></script>
<script type="text/javascript" src="../res/2.0/scripts/dom-utils.js"></script>
<script type="text/javascript" src="../res/3.0/scripts/tools/camera.js"></script>
<script type="text/javascript" src="gandhi.js"></script>
</head>
<body>
<style>
body {
background-color: black;
}
svg {
background-color: white;
max-width: 100%;
height: auto;
border-radius: 5px;
margin-left: auto;
margin-right: auto;
display: block;
margin-top: 16px;
margin-bottom: auto;
}
#playButton {
cursor: pointer;
}
#quotes { pointer-events: none; }
text { font-family: 'Bradley Hand','Segoe Print','Chalkboard SE','Comic Sans MS',cursive; }
.text-effects { text-anchor: middle; }
text, tspan {
text-rendering: geometricPrecision;
}
</style>
<div><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="800px" height="600px" viewBox="0 0 800 600" xml:space="preserve">
<desc>A camera moves between eight short lines of text set at different angles. Their full stops then grow into pebbles, which reshape into a flower with eight petals above the title.</desc>
<g id="Layer_1">
<text id="title" class="text-effects" transform="matrix(1 0 0 1 400 553.3516)" font-size="40" fill-opacity="0">Eight small lines</text>
<g id="cameraTarget">
<g id="quotes" display="none">
<text transform="matrix(1.311342e-07 1 -1 1.311342e-07 462.3037 226.3247)" display="inline" font-size="12" text-anchor="middle"><tspan x="61.9" y="0.00">A small step still counts</tspan><tspan x="61.9" y="14.40">Take it, then take another</tspan><tspan x="61.9" y="28.80">before dark</tspan><tspan fill="#FFFFFF">.</tspan></text>
<text transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 678.9326 312.3652)" display="inline" font-size="15" text-anchor="middle"><tspan x="22.3" y="0.00">Begin</tspan><tspan x="22.3" y="18.00">with one line,</tspan><tspan x="22.3" y="36.00">then add a second</tspan><tspan x="22.3" y="54.00">and see where it goes</tspan><tspan fill="#FFFFFF">.</tspan></text>
<text transform="matrix(0.7071 -0.7071 0.7071 0.7071 490.9541 328.6152)" display="inline" font-size="23" text-anchor="middle"><tspan x="119.4" y="0.00">Look twice at the world</tspan><tspan x="119.4" y="27.60">before you draw it</tspan><tspan fill="#FFFFFF">.</tspan></text>
<text transform="matrix(1 0 0 1 144.9287 244.0127)" display="inline" font-size="25" text-anchor="middle"><tspan x="126.7" y="0.00">Patience is a quiet tool</tspan><tspan x="126.7" y="30.00">that keeps on working</tspan><tspan x="126.7" y="60.00">long after the noise</tspan><tspan x="126.7" y="90.00">has left the room</tspan><tspan fill="#FFFFFF">.</tspan></text>
<text transform="matrix(-4.371139e-08 -1 1 -4.371139e-08 152.0728 213.3799)" display="inline" font-size="11" text-anchor="middle"><tspan x="33.5" y="0.00">Good work</tspan><tspan x="33.5" y="13.20">sounds like</tspan><tspan x="33.5" y="26.40">a quiet room</tspan><tspan x="33.5" y="39.60">where people</tspan><tspan x="33.5" y="52.80">are listening</tspan><tspan fill="#FFFFFF">.</tspan></text>
<text transform="matrix(-1 0 0 -1 367.2056 185.7671)" display="inline" font-size="20" text-anchor="middle"><tspan x="60.9" y="0.00">Mend the fence,</tspan><tspan x="60.9" y="24.00">greet the neighbor</tspan><tspan fill="#FFFFFF">.</tspan></text>
<text transform="matrix(1 0 0 1 481.7959 162.1128)" display="inline" font-size="15"><tspan x="0" y="0.00">One hour at the bench</tspan><tspan x="0" y="18.00">teaches more</tspan><tspan x="0" y="36.00">than a shelf</tspan><tspan x="0" y="54.00">of plans</tspan><tspan fill="#FFFFFF">.</tspan></text>
<text transform="matrix(0.5 0.866 -0.866 0.5 432.9951 156.5605)" display="inline" font-size="16" text-anchor="middle"><tspan x="20.3" y="0.00">Hands</tspan><tspan x="20.3" y="19.20">remember</tspan><tspan x="20.3" y="38.40">everything</tspan><tspan fill="#FFFFFF">.</tspan></text>
</g>
<g id="gandhiFinal_2_" display="none">
<path id="face0Final" display="inline" d="M 400.00 242.00 C 400.00 242.00 411.37 199.60 423.87 153.00 C 436.37 106.40 425.00 64.00 400.00 64.00 C 375.00 64.00 363.63 106.40 376.13 153.00 C 388.63 199.60 400.00 242.00 400.00 242.00 Z"/>
<path id="face1Final" display="inline" d="M 414.14 247.86 C 414.14 247.86 444.13 231.36 477.09 213.22 C 510.05 195.09 526.55 165.10 511.72 150.28 C 496.90 135.45 466.91 151.95 448.78 184.91 C 430.64 217.87 414.14 247.86 414.14 247.86 Z"/>
<path id="face2Final" display="inline" d="M 420.00 262.00 C 420.00 262.00 422.05 262.01 426.01 262.58 C 429.97 263.15 435.84 264.30 443.23 266.20 C 450.62 268.10 459.51 270.76 469.33 273.84 C 479.14 276.93 489.87 280.41 500.79 283.58 C 511.71 286.74 522.81 289.55 533.36 291.24 C 543.90 292.94 553.88 293.50 562.63 292.53 C 571.38 291.56 578.90 289.06 584.67 285.25 C 590.44 281.44 594.47 276.33 596.48 270.70 C 598.50 265.06 598.50 258.94 596.48 253.30 C 594.47 247.67 590.44 242.56 584.67 238.75 C 578.90 234.94 571.38 232.44 562.63 231.47 C 553.88 230.50 543.90 231.06 533.36 232.76 C 522.81 234.45 511.71 237.26 500.79 240.42 C 489.87 243.59 479.14 247.07 469.33 250.16 C 459.51 253.24 450.62 255.90 443.23 257.80 C 435.84 259.70 429.97 260.85 426.01 261.42 C 422.05 261.99 420.00 262.00 420.00 262.00 Z"/>
<path id="face3Final" display="inline" d="M 414.14 276.14 C 414.14 276.14 439.44 338.22 468.94 367.72 C 498.44 397.22 535.22 360.44 505.72 330.94 C 476.22 301.44 414.14 276.14 414.14 276.14 Z"/>
<path id="face4Final" display="inline" d="M 400.00 282.00 C 400.00 282.00 388.63 324.40 376.13 371.00 C 363.63 417.60 375.00 460.00 400.00 460.00 C 425.00 460.00 436.37 417.60 423.87 371.00 C 411.37 324.40 400.00 282.00 400.00 282.00 Z"/>
<path id="face5Final" display="inline" d="M 385.86 276.14 C 385.86 276.14 384.17 277.79 380.42 280.37 C 376.66 282.94 370.82 286.43 363.32 290.35 C 355.82 294.26 346.69 298.61 337.19 303.35 C 327.70 308.08 317.89 313.24 309.34 318.92 C 300.79 324.60 293.54 330.83 288.68 337.38 C 283.82 343.94 281.37 350.82 281.43 357.22 C 281.49 363.61 284.04 369.49 288.28 373.72 C 292.51 377.96 298.39 380.51 304.78 380.57 C 311.18 380.63 318.06 378.18 324.62 373.32 C 331.17 368.46 337.40 361.21 343.08 352.66 C 348.76 344.11 353.92 334.30 358.65 324.81 C 363.39 315.31 367.74 306.18 371.65 298.68 C 375.57 291.18 379.06 285.34 381.63 281.58 C 384.21 277.83 385.86 276.14 385.86 276.14 Z"/>
<path id="face6Final" display="inline" d="M 380.00 262.00 C 380.00 262.00 377.68 261.98 373.23 261.30 C 368.77 260.63 362.17 259.27 353.93 257.06 C 345.69 254.85 335.82 251.79 325.06 248.39 C 314.30 244.98 302.65 241.25 291.00 238.13 C 279.35 235.01 267.70 232.52 256.94 231.51 C 246.18 230.49 236.31 230.98 228.07 233.19 C 219.83 235.40 213.23 239.33 208.77 244.43 C 204.32 249.52 202.00 255.75 202.00 262.00 C 202.00 268.25 204.32 274.48 208.77 279.57 C 213.23 284.67 219.83 288.60 228.07 290.81 C 236.31 293.02 246.18 293.51 256.94 292.49 C 267.70 291.48 279.35 288.99 291.00 285.87 C 302.65 282.75 314.30 279.02 325.06 275.61 C 335.82 272.21 345.69 269.15 353.93 266.94 C 362.17 264.73 368.77 263.37 373.23 262.70 C 377.68 262.02 380.00 262.00 380.00 262.00 Z M 320.10 262.00 C 320.10 262.03 320.08 262.07 320.05 262.09 C 320.02 262.10 319.98 262.10 319.95 262.09 C 319.92 262.07 319.90 262.03 319.90 262.00 C 319.90 261.97 319.92 261.93 319.95 261.91 C 319.98 261.90 320.02 261.90 320.05 261.91 C 320.08 261.93 320.10 261.97 320.10 262.00 Z"/>
<path id="face7Final" display="inline" d="M 385.86 247.86 C 385.86 247.86 385.05 247.05 383.68 245.26 C 382.32 243.47 380.39 240.69 378.13 236.95 C 375.87 233.21 373.27 228.49 370.47 223.02 C 367.66 217.56 364.65 211.36 361.45 204.84 C 358.25 198.32 354.85 191.50 351.22 184.91 C 347.60 178.32 343.73 171.97 339.61 166.37 C 335.50 160.77 331.12 155.93 326.57 152.20 C 322.03 148.48 317.31 145.89 312.65 144.54 C 307.99 143.20 303.39 143.10 299.20 144.13 C 295.01 145.16 291.24 147.31 288.28 150.28 C 285.31 153.24 283.16 157.01 282.13 161.20 C 281.10 165.39 281.20 169.99 282.54 174.65 C 283.89 179.31 286.48 184.03 290.20 188.57 C 293.93 193.12 298.77 197.50 304.37 201.61 C 309.97 205.73 316.32 209.60 322.91 213.22 C 329.50 216.85 336.32 220.25 342.84 223.45 C 349.36 226.65 355.56 229.66 361.02 232.47 C 366.49 235.27 371.21 237.87 374.95 240.13 C 378.69 242.39 381.47 244.32 383.26 245.68 C 385.05 247.05 385.86 247.86 385.86 247.86 Z"/>
</g>
<g id="gandhiSecond" display="none">
<g display="inline">
<path id="face0Second" d="M 415.15 274.93 C 426.43 279.27 418.52 296.10 410.60 302.38 C 405.25 308.05 382.11 304.84 377.12 301.92 C 369.64 297.09 366.11 285.80 373.08 279.10 C 378.29 274.11 407.55 272.09 415.15 274.93 Z"/>
<path id="face1Second" d="M 399.34 317.61 C 425.28 322.27 410.32 359.46 404.25 366.10 C 398.30 372.62 389.80 371.43 381.02 369.89 C 373.98 368.60 371.26 363.90 370.10 359.81 C 368.94 355.68 372.62 312.87 399.34 317.61 Z"/>
<path id="face2Second" d="M 430.57 242.52 C 429.99 241.39 429.95 240.41 429.48 239.88 C 428.37 238.64 428.07 237.68 427.53 237.17 C 427.07 236.72 423.70 231.79 421.07 230.67 C 417.68 229.24 411.45 227.74 407.04 227.55 C 402.98 227.38 405.06 227.67 401.80 227.96 C 398.02 228.31 400.03 228.06 398.38 228.31 C 397.77 228.40 394.50 228.75 392.49 229.04 C 387.70 228.42 385.03 229.62 384.96 229.55 C 378.82 230.90 378.79 235.90 379.13 236.66 C 379.56 237.68 378.71 237.87 380.06 241.39 C 379.62 242.11 380.51 244.01 382.78 246.47 C 383.51 247.27 389.15 249.06 391.78 250.57 C 394.99 252.22 398.23 255.65 405.42 258.63 C 418.01 261.71 423.55 258.20 426.16 255.50 C 428.78 252.80 429.71 251.07 429.70 249.65 C 429.72 249.19 430.89 246.16 431.07 245.40 C 431.31 244.42 431.23 243.64 430.57 242.52 Z"/>
<path id="face3Second" d="M 333.98 307.34 C 334.32 293.40 324.65 285.57 343.94 277.06 C 360.22 270.36 379.05 323.75 363.55 329.77 C 337.67 340.06 333.64 321.29 333.98 307.34 Z"/>
<path id="face4Second" d="M 459.05 310.99 C 474.30 310.25 474.30 320.05 469.22 330.07 C 468.32 331.82 461.14 341.00 459.82 342.44 C 457.34 345.12 426.92 344.94 426.30 340.13 C 424.44 319.35 421.90 313.68 459.05 310.99 Z"/>
<path id="face5Second" d="M 478.50 259.35 C 477.12 260.80 475.14 262.88 471.97 263.74 C 469.30 264.36 467.85 264.04 466.76 263.74 C 465.62 263.43 465.33 263.42 464.63 263.43 C 464.09 263.53 463.71 263.52 463.17 263.59 C 462.32 263.71 462.04 263.76 461.21 263.71 C 459.52 263.77 458.82 263.89 457.93 263.89 C 456.68 263.98 453.41 264.10 450.77 261.31 C 446.13 256.41 450.45 249.34 457.06 242.35 C 460.68 239.20 462.21 239.42 465.73 238.78 C 469.06 237.96 470.13 240.03 473.38 238.98 C 474.75 238.53 477.33 240.42 478.72 240.61 C 479.28 240.70 480.19 241.60 480.45 242.58 C 480.78 243.86 481.68 244.51 482.03 245.64 C 482.92 248.52 482.34 254.56 478.50 259.35 Z"/>
<path id="face6Second" d="M 338.79 235.56 C 338.16 235.64 335.74 234.39 334.79 234.42 C 332.99 234.04 331.12 232.96 329.54 233.11 C 327.94 232.55 326.78 231.48 325.40 231.53 C 323.74 231.60 318.45 230.03 316.42 240.35 C 314.80 248.52 317.38 252.38 318.99 255.39 C 320.08 257.48 321.65 260.48 323.75 261.72 C 325.03 262.48 326.76 264.31 329.49 265.58 C 332.22 266.84 340.29 269.00 346.95 269.70 C 353.32 270.85 359.90 271.33 362.98 271.15 C 363.97 271.09 365.85 270.33 368.98 269.95 C 376.21 269.77 379.90 269.24 378.84 260.62 C 377.67 254.51 373.63 250.68 369.26 247.62 C 366.51 245.72 360.70 243.28 359.06 242.36 C 356.18 240.75 354.59 239.96 354.00 239.67 C 352.21 238.78 351.15 238.60 349.89 238.42 C 346.36 237.62 345.61 237.67 338.79 235.56 Z M 330.59 242.45 C 330.41 242.67 330.35 242.90 330.13 242.73 C 329.91 242.88 329.47 243.03 329.25 242.70 C 328.98 242.60 329.11 242.63 329.22 242.36 C 329.22 242.36 329.30 242.08 329.40 241.90 C 329.56 241.51 329.61 241.69 329.96 241.79 C 330.38 241.87 330.62 242.21 330.59 242.45 Z"/>
<path id="face7Second" d="M 486.36 284.00 C 486.70 285.19 487.16 288.96 487.30 290.16 C 487.69 293.10 487.83 295.73 487.03 298.15 C 485.36 303.23 484.66 304.04 482.20 303.74 C 481.48 303.65 479.20 305.30 475.43 304.21 C 473.30 303.59 473.50 303.98 472.50 303.90 C 469.87 303.69 468.54 304.21 466.46 303.75 C 465.64 303.56 459.07 302.93 455.46 302.43 C 453.50 302.16 443.95 303.41 443.06 303.41 C 437.89 303.41 434.21 301.32 432.55 299.61 C 431.29 298.31 430.81 293.72 430.52 288.98 C 430.11 281.79 435.74 280.47 436.61 280.01 C 439.20 278.02 441.49 276.33 442.63 275.53 C 443.36 275.03 445.00 275.68 445.60 275.53 C 446.30 275.36 447.75 275.75 448.40 275.53 C 449.34 275.20 451.37 275.89 452.53 275.53 C 453.30 275.30 456.91 274.49 459.06 274.67 C 462.68 274.82 461.96 274.82 465.44 274.57 C 468.78 274.34 472.60 275.53 475.91 275.78 C 477.82 275.92 481.30 276.19 483.30 278.36 C 485.75 281.42 486.09 282.84 486.36 284.00 Z"/>
</g>
</g>
<g id="gandhiInitial">
<g>
<path id="face0Initial" display="none" d="M 430.75 317.46 C 431.48 317.77 430.97 318.98 430.46 319.43 C 430.11 319.84 428.62 319.61 428.30 319.40 C 427.82 319.05 427.59 318.24 428.04 317.76 C 428.37 317.40 430.26 317.26 430.75 317.46 Z"/>
<path id="face1Initial" display="none" d="M 575.48 342.53 C 575.39 343.80 574.00 343.22 573.74 342.95 C 573.49 342.69 573.51 342.27 573.54 341.85 C 573.57 341.51 573.73 341.36 573.87 341.29 C 574.01 341.21 575.57 341.22 575.48 342.53 Z"/>
<path id="face2Initial" display="none" d="M 676.94 192.31 C 676.99 192.48 677.01 192.63 677.05 192.70 C 677.15 192.87 677.18 193.02 677.22 193.09 C 677.26 193.15 677.56 193.86 677.77 193.98 C 678.04 194.14 678.53 194.25 678.87 194.19 C 679.18 194.13 679.02 194.13 679.26 194.02 C 679.54 193.89 679.39 193.97 679.52 193.90 C 679.57 193.87 679.81 193.75 679.96 193.67 C 680.33 193.67 680.52 193.43 680.53 193.44 C 680.98 193.10 680.56 192.53 680.53 192.42 C 680.49 192.27 680.53 191.94 680.59 191.64 C 680.62 191.52 680.72 191.08 680.53 190.74 C 680.47 190.63 680.02 190.46 679.81 190.28 C 679.55 190.09 679.27 189.61 678.69 189.29 C 677.70 189.06 677.32 189.72 677.14 190.20 C 676.97 190.68 676.91 190.97 676.93 191.19 C 676.93 191.26 676.87 191.76 676.87 191.88 C 676.87 192.03 676.88 192.15 676.94 192.31 Z"/>
<path id="face3Initial" display="none" d="M 410.06 347.65 C 410.89 348.13 411.98 349.06 411.65 349.46 C 409.51 352.16 408.90 352.84 408.02 349.39 C 407.84 348.68 409.22 347.17 410.06 347.65 Z"/>
<path id="face4Initial" display="none" d="M 208.99 150.76 C 209.39 150.73 209.39 151.18 209.25 151.65 C 209.23 151.73 209.04 152.16 209.01 152.22 C 208.95 152.34 208.16 152.34 208.14 152.11 C 208.10 151.15 208.03 150.88 208.99 150.76 Z"/>
<path id="face5Initial" display="none" d="M 231.44 149.96 C 231.39 150.20 231.31 150.54 231.01 150.83 C 230.75 151.07 230.56 151.13 230.41 151.17 C 230.26 151.21 230.22 151.23 230.14 151.28 C 230.08 151.33 230.04 151.35 229.98 151.39 C 229.89 151.46 229.86 151.48 229.76 151.53 C 229.57 151.65 229.50 151.70 229.39 151.76 C 229.25 151.85 228.88 152.07 228.37 151.96 C 227.47 151.76 227.46 150.76 227.71 149.62 C 227.90 149.06 228.09 148.99 228.45 148.70 C 228.77 148.40 229.05 148.54 229.35 148.23 C 229.48 148.10 229.91 148.12 230.09 148.05 C 230.16 148.02 230.33 148.06 230.43 148.14 C 230.56 148.25 230.71 148.26 230.84 148.35 C 231.16 148.57 231.54 149.22 231.44 149.96 Z"/>
<path id="face6Initial" display="none" d="M 542.48 231.64 C 542.46 231.65 542.40 231.60 542.38 231.61 C 542.34 231.60 542.29 231.56 542.25 231.58 C 542.21 231.56 542.18 231.51 542.15 231.52 C 542.11 231.54 541.98 231.49 541.93 232.10 C 541.90 232.58 541.96 232.79 542.00 232.95 C 542.03 233.06 542.07 233.22 542.12 233.28 C 542.15 233.31 542.20 233.40 542.26 233.45 C 542.33 233.50 542.53 233.56 542.69 233.54 C 542.85 233.55 543.01 233.53 543.09 233.49 C 543.11 233.48 543.16 233.42 543.24 233.37 C 543.42 233.30 543.51 233.24 543.48 232.75 C 543.45 232.41 543.34 232.22 543.23 232.08 C 543.16 231.99 543.02 231.90 542.97 231.86 C 542.90 231.79 542.86 231.76 542.84 231.75 C 542.80 231.71 542.77 231.71 542.74 231.71 C 542.67 231.69 542.65 231.70 542.48 231.64 Z M 542.32 232.25 C 542.29 232.34 542.29 232.37 542.26 232.34 C 542.24 232.38 542.25 232.34 542.19 232.31 C 542.17 232.30 542.15 232.30 542.16 232.19 C 542.17 232.15 542.15 232.12 542.16 232.06 C 542.20 231.94 542.23 232.00 542.26 232.06 C 542.30 232.12 542.32 232.20 542.32 232.25 Z"/>
<path id="face7Initial" display="none" d="M 424.74 224.30 C 424.75 224.39 424.77 224.69 424.78 224.79 C 424.80 225.02 424.80 225.23 424.77 225.42 C 424.70 225.82 424.67 225.89 424.57 225.86 C 424.54 225.85 424.45 225.98 424.30 225.90 C 424.21 225.85 424.22 225.88 424.18 225.88 C 424.07 225.86 424.02 225.90 423.94 225.87 C 423.91 225.86 423.64 225.81 423.50 225.77 C 423.42 225.75 423.04 225.85 423.00 225.85 C 422.79 225.85 422.64 225.68 422.58 225.55 C 422.53 225.45 422.51 225.08 422.50 224.71 C 422.48 224.14 422.71 224.04 422.75 224.00 C 422.85 223.84 422.95 223.71 422.99 223.65 C 423.02 223.61 423.09 223.66 423.11 223.65 C 423.14 223.64 423.20 223.67 423.22 223.65 C 423.26 223.62 423.34 223.68 423.39 223.65 C 423.42 223.63 423.57 223.57 423.65 223.58 C 423.80 223.59 423.77 223.59 423.91 223.57 C 424.04 223.55 424.20 223.65 424.33 223.67 C 424.41 223.68 424.55 223.70 424.63 223.87 C 424.72 224.10 424.73 224.21 424.74 224.30 Z"/>
</g>
</g>
</g>
<g id="playButton" display="none">
<text transform="matrix(0.9814 0 0 1 387.2017 346.0713)" display="inline" font-size="21">play</text>
<g display="inline">
<g>
<path d="M425.73,281.02c13.52,13.66,7.63,33.28-9.54,42.21c-11.27,5.95-24.62,6.63-35.02,0.67
c-10.4-5.95-16.99-16.23-13.35-26.65C374.59,279.12,405.28,260.32,425.73,281.02z"/>
</g>
<g>
<path fill="#FFFFFF" d="M390.95,288.57c-0.62-2.17,1.26-4.02,2.77-4.02c3.17-0.65,6.26,1.58,9.07,2.52
c5.47,1.8,10.37,4.32,14.4,8.14c2.52,1.87,0.58,4.25-1.58,5.62c-7.2,4.61-12.53,10.22-19.66,14.4
c-2.59,1.44-3.57-1.91-3.75-5.37C392.03,306.4,392.29,293.31,390.95,288.57z"/>
</g>
</g>
</g>
<g id="loadingAudio" display="none">
<text transform="matrix(1 0 0 1 362.5684 300)" display="inline" font-size="21">preparing</text>
<g id="loadingDashes" display="inline">
<path id="dash_x5F_c" d="M376.65,310.63c0.43-0.24,1.1,0,1.34,0.43c0.43,2.02-1.58,2.45-2.69,2.88c-4.03,1.15-8.26,1.15-12.53,0
c-0.86-0.19-0.86-0.62-0.86-0.62c-0.24-1.58,1.1-2.93,2.69-2.93C368.63,310.39,372.43,311.3,376.65,310.63z"/>
<path id="dash_x5F_b" d="M393.88,310.63c0.43-0.24,1.1,0,1.34,0.43c0.43,2.02-1.58,2.45-2.69,2.88c-4.03,1.15-8.26,1.15-12.53,0
c-0.86-0.19-0.86-0.62-0.86-0.62c-0.24-1.58,1.1-2.93,2.69-2.93C385.87,310.39,389.66,311.3,393.88,310.63z"/>
<path id="dash_x5F_a" d="M411.11,310.63c0.43-0.24,1.1,0,1.34,0.43c0.43,2.02-1.58,2.45-2.69,2.88c-4.03,1.15-8.26,1.15-12.53,0
c-0.86-0.19-0.86-0.62-0.86-0.62c-0.24-1.58,1.1-2.93,2.69-2.93C403.1,310.39,406.89,311.3,411.11,310.63z"/>
</g>
</g>
</g>
</svg>
</div>
</body>
</html>/gandhi-quotes/gandhi.js
/** =======================================================================
* Vincent Hardy
* License terms: see svg-wow.org
* CC0 http://creativecommons.org/publicdomain/zero/1.0/
* ======================================================================= */
(function () {
/**
* See the YUI.use() call at the end of this script to understand how this
* method is invoked initially.
*
* This demo uses an audio track. To make sure that audio is available
* before animations are allowed to start, the demo shows an animation
* letting the user know audio is loading until the audio loads or is found
* in error.
*
* Once the audio has loaded, a play button is displayed to let the user
* start the animation.
*
* Restoration note: the original quotes, portrait and audio were not cleared
* for reuse. This version shows original text and morphs into a flower.
*
* The demo shows a number of short lines, moving the camera around
* to zoom in on each one in turn. Once all quotes have been shown, the
* camera zooms out and the dots in each quote morph first into a set of
* intermediate shape which then morph into an eight-petal flower.
*
* Finally, a text effect shows the title.
*
* @param Y the YUI instance.
*/
function onScriptsReady (Y) {
var Animate = sw.animation.Animate, Easing = Y.Easing,
TextEffects = sw.TextEffects, fadeAuthor, cx, cy;
// Add an effect to the title text to show when the morphing
// animation ends.
var title = Y.one("#title"),
effect = TextEffects.effects['zoom-out'].applyEffect([title],{
duration: 0.5,
offset: 0.11,
easing: Easing.easingNone
});
effect.setStartState();
/**
* Moves a quote's dot onto the full stop of its line, because the
* replacement text has different metrics from the original.
*/
function alignDot (text, index) {
var el = text._node, n = el.getNumberOfChars(),
shape = document.getElementById('face' + index + 'Initial'),
reference = document.getElementById('cameraTarget'),
d, nums, sumX = 0, sumY = 0, count = 0, start, extent, m,
px, py, dx, dy, isX = true;
if (shape === null || n === 0) {
return;
}
start = el.getStartPositionOfChar(n - 1);
extent = el.getExtentOfChar(n - 1);
m = el.getTransformToElement(reference);
px = start.x + extent.width / 2;
py = start.y - extent.height * 0.08;
d = shape.getAttribute('d');
nums = d.match(/-?[0-9.]+/g);
nums.forEach(function (v, i) {
if (i % 2 === 0) { sumX += Number(v); } else { sumY += Number(v); }
count += 0.5;
});
dx = (m.a * px + m.c * py + m.e) - sumX / count;
dy = (m.b * px + m.d * py + m.f) - sumY / count;
shape.setAttribute('d', d.replace(/-?[0-9.]+/g, function (v) {
var r = Number(v) + (isX ? dx : dy);
isX = !isX;
return r.toFixed(2);
}));
}
SwRestore.startControl({
target: Y.one('svg')._node,
score: {
tempo: 66,
notes: [196, 0, 246.94, 0, 293.66, 0, 246.94, 0,
174.61, 0, 220, 0, 261.63, 0, 220, 0],
bass: [98, 98, 87.31, 87.31]
},
onStart: play
});
// The demo actually starts when the user presses a start button.
// =====================================================================
function play () {
// Prepare the morphing animation.
//
// The morphing is done as so:
// a. By convention, all the shapes to be morphed are found in the
// SVG content and have an id with a predefined prefix.
// b. The code looks for the initial, intermediate and end version
// of the shapes to get the value of their 'd' attribute.
// c. The code creates animations of the d attribute on the initial
// shape which creates the morphing effect.
//
var startShapePrefix = 'face',
startShapeSuffix = 'Initial',
intermediateShapePrefix = 'face',
intermediateShapeSuffix = 'Second',
endShapePrefix = 'face',
endShapeSuffix = 'Final',
animations = [],
easing = function (t, b, c, d) {
return Easing.elasticOut(t, b, c, d, c * 1, d * 1.2);
};
var shapeIndex = -1, startShapeId, endShapeId, startShape,
endShape, anim, anim2, intermediateShapeId, intermediateShape;
/**
* Helper method: checks if there is another shape with the desired
* prefix, and different suffixes for the various states.
*
* In this demo, it looks for face<n>Initial, face<n>Second
* and face<n>Final on the <n>th iteration.
*/
function hasNextShape () {
shapeIndex++;
startShapeId = startShapePrefix + shapeIndex + startShapeSuffix;
intermediateShapeId = intermediateShapePrefix + shapeIndex +
intermediateShapeSuffix;
endShapeId = endShapePrefix + shapeIndex + endShapeSuffix;
startShape = Y.one("#" + startShapeId);
endShape = Y.one("#" + endShapeId);
intermediateShape = Y.one("#" + intermediateShapeId);
if (intermediateShape === null) {
Y.log('intermediate shape ' + intermediateShapeId + ' is null');
}
return startShape !== null &&
endShape !== null &&
intermediateShape !== null;
}
while (hasNextShape()) {
// 'anim' morphs from a small dot (at the end of the quote) to a
// bigger 'blob'.
//
// 'anim2' morphs to the blob to the final shape.
anim = new Animate({
node: startShape,
to: {
d: intermediateShape.getAttribute('d')
},
duration: 6 + 2 * Math.random(),
easing: easing
});
anim2 = new Animate({
node: startShape,
to: {
d: endShape.getAttribute('d')
},
duration: 6 + 2 * Math.random(),
easing: easing
});
anim.onEnd(anim2);
animations.push(anim);
}
var viewportWidth = Number(Y.one('svg').get('width')),
viewportHeight = Number(Y.one('svg').get('height')),
travelSegments = [],
textElements = [],
noInterpolators = {
zoom: Easing.easeNone,
direction: Easing.easeNone ,
position: Easing.easeNone
},
camera = new sw.tools.Camera({
target: Y.one('#cameraTarget'),
viewport: {
width: viewportWidth,
height: viewportHeight
},
frameLength: 1,
position: {
x: viewportWidth / 2,
y: viewportHeight / 2
},
direction: 0,
zoom: 0.1
});
travelSegments.push({
name: "initialZoomPan",
position: {
x: viewportWidth / 2,
y: viewportHeight / 2
},
direction: 0,
zoom: 1,
runLength: 5000,
interpolators: noInterpolators
});
// Get the quotes and create a camera travel segment for each.
var quotes = Y.one("#quotes"), textLength, flyOut = [];
quotes.setStyle("display", "inline");
quotes.setStyle("visibility", "hidden");
quotes.all('text').each(function (node, index, nodeList) {
alignDot(node, index);
var bbox = node._node.getViewportBBox(),
// Compute the scale based on the bbox and the viewport size
zoomX = viewportWidth / bbox.width,
zoomY = viewportHeight / bbox.height,
zoom = Math.min(zoomX, zoomY),
// Extract the rotation from the node's matrix.
m = node._node.getMatrix(),
angle = -Math.atan2(m.b, m.a) * 180 / Math.PI,
// Make the duration dependent on the length of the text.
textLength = node.get("textContent").length,
readDuration = textLength * 120, // 0.12s per char
zoomDelta= 0.2 * textLength / 60,
cx, cy, txf;
textElements.push(node);
travelSegments.push({
name: "segment_" + index,
position: {
x: bbox.x + bbox.width / 2,
y: bbox.y + bbox.height / 2
},
direction: angle,
zoom: zoom * 0.7,
runLength: 2000,
interpolators: noInterpolators
});
travelSegments.push({
name: "pause_" + index,
position: {
x: bbox.x + bbox.width / 2,
y: bbox.y + bbox.height / 2
},
direction: angle,
zoom: zoom * (0.7 + zoomDelta),
runLength: readDuration,
interpolators: noInterpolators
});
bbox = node._node.getBBox();
txf = node._node.getAttribute("transform");
cx = bbox.x + bbox.width / 2;
cy = bbox.y + bbox.height / 2;
// The flyOut animations are used to fade out the quotes when
// the morphing animation starts.
flyOut.push(new Animate({
node: node,
from: {
transform: {tx: 0, ty: 0, r: 0},
'fill-opacity': 1
},
to: {
transform: {
tx: (-1 + 2 * Math.random()) * viewportWidth,
ty: (-1 + 2 * Math.random()) * viewportHeight,
r: 360 * Math.random()
},
'fill-opacity': 0
},
transformTemplate:
txf +
"translate(#tx,#ty)" +
"rotate(#r," + cx + "," + cy + ")",
duration: 2,
easing: Easing.easingNone
}));
flyOut[flyOut.length - 1].onEnd(function () {
node.setStyle('display', 'none');
});
});
// Add a final travel segment to move to a 'full view'
travelSegments.push({
name: "finalPosition",
position: {
x: viewportWidth / 2,
y: viewportHeight / 2
},
direction: 0,
zoom: 0.9,
runLength: 1000,
interpolators: noInterpolators
});
travelSegments.push({
name: "final",
position: {
x: viewportWidth / 2,
y: viewportHeight / 2
},
direction: 0,
zoom: 1,
runLength: 3000,
interpolators: noInterpolators
});
camera.addTravelSegments(travelSegments);
// When a "pause_n" ends, we hide the text at index n and show the
// 'face<n>Initial' shape instead.
camera.on("segmentComplete", function (evt) {
var segment = evt.segment;
if (segment.name.indexOf("pause_") === 0) {
var textIndex = Number(segment.name.substring("pause_".length));
// textElements[textIndex].setStyle("display", "none");
var shape = Y.one("#" + startShapePrefix +
textIndex + startShapeSuffix);
if (shape !== null) {
shape.setStyle("display", "inline");
}
}
});
var morphNow = function () {
var n = animations.length;
Y.Array.each(animations, function (anim) {
anim.run();
});
// At the end of the morphing animations, we show the artist's name and
// Gandhi's full name.
animations[n - 1].onEnd(function () {
effect.run(3);
setTimeout(function () {
SwRestore.replay(Y.one('svg')._node, 0.05);
}, 9000);
});
};
flyOut[0].onBegin(morphNow);
// At the end of the camera, begin the morphing to Gandhi's portrait
camera.on("complete", function () {
for (var i = 0; i < flyOut.length; i++) {
flyOut[i].run(0.5);
}
});
setTimeout(function () {
quotes.setStyle("visibility", "visible");
camera.action();
}, 1000);
}
}
/**
* Main entry point. Refer to the YUI documentation to understand how the
* YUI framework loads scripts and handles dependencies.
*
* The following declares the modules required by the code (such as
* 'anim-svg') and their dependencies.
*
* The onScriptsReady function is called when the DOM tree is ready.
*/
YUI({
groups: {
svg: {
combine: false,
base: "../res/3.0/scripts/yui/",
modules: {
"node-svg": {
path: 'svg/node-svg-debug.js',
requires: ['node']
},
"dom-style-svg": {
path: 'svg/dom-style-svg-debug.js',
requires: ['node', 'dom-svg']
},
"dom-svg": {
path: 'svg/dom-svg-debug.js',
requires: ['dom']
},
"anim-timing": {
path: 'anim-timing/anim-timing-debug.js',
requires: ['anim', 'node-svg']
},
"anim-svg": {
path: 'svg/anim-svg-debug.js',
requires: ['anim', 'dom-style-svg']
},
"text-effects": {
path: '../tools/text-effects.js',
requires: ['anim-svg', 'anim-timing']
}
}
},
utils: {
combine: false,
base: "../res/2.0/scripts/",
modules: {
"dom-utils": {
path: "dom-utils.js"
}
}
}
}// ,
// filter: 'debug',
// timeout: 10000
}).use('anim-svg', 'anim-timing', 'camera', 'text-effects', function(Y) {
Y.on('contentready', function () {
sw.init();
onScriptsReady(Y);
}, 'body');
});
})();/res/3.0/scripts/tools/camera.js
/** =======================================================================
* Vincent Hardy
* License terms: see svg-wow.org
* CC0 http://creativecommons.org/publicdomain/zero/1.0/
* ======================================================================= */
YUI.add("camera", function (Y) {
/**
* Constructor. A <code>Camera</code> makes it easy to move the
* viewpoint in an SVG graphics.
*
* It is used as so:
* <code>
* // Create a new travelling path with the initial camera position
* var ctp = new Camera({
* target: elt, // The SVG element with the target coordinate system.
* position: {x: 10, y: 40},
* zoom: 2,
* direction: 90 // angle made with (1, 0) vector
* viewport: {width: 400, height: 300}, // The camera viewport
* frameLength: 40 // Time between camera movements, in milliseconds
* });
*
* ctp.addTravelSegment({
* position: {x: 80, y: 80},
* zoom: 1,
* direction: 45,
* controlPoints: {
* start: {x: 30, y: 20},
* end: {x: 80, y: 80}
* },
* runLength: 500, // milliseconds
* interpolators: {
* direction: function(p) {},
* zoom: function (p) {},
* position: function (p) {}
* },
* customData: ... // custom data you want to be able to get in the fired events
* );
*
* ctp.action();
* </code>
*
* @param config the initial camera position and target element.
*/
var Camera = function (config) {
var c = {
settings: [{
position: {
x: 0,
y: 0
}
}],
segments: []
};
var fs = c.settings[0];
c.target = config.target;
c.viewport = config.viewport;
c.frameLength = config.frameLength;
fs.position = config.position;
fs.zoom = config.zoom;
fs.direction = config.direction;
this._config = c;
};
Camera.events = {
segmentComplete: "segmentComplete",
complete: "complete"
};
Y.augment(Camera, Y.EventTarget);
/**
* Adds a new travel segment. A travel segment has the following properties:
* - position (x/y)
* - zoom
* - direction (in degrees)
* - controlPoints (start(x/y), end(x/y))
* - length (in millisseconds)
* - interpolators: direction, zoom and position.
*
* @param seg the new segment configuration
*/
Camera.prototype.addTravelSegment = function (seg) {
var previousEndRunLength = 0,
segments = this._config.segments,
nSegments = segments.length;
if (nSegments > 0) {
previousEndRunLength = segments[nSegments - 1].endRunLength;
}
this._config.settings.push({
position: seg.position,
zoom: seg.zoom,
direction: seg.direction
});
this._config.segments.push({
name: seg.name,
controlPoints: seg.controlPoints,
startRunLength: previousEndRunLength,
endRunLength: previousEndRunLength + seg.runLength,
runLength: seg.runLength,
interpolators: seg.interpolators,
customData: (seg.customData ? seg.customData : null)
});
};
/**
* @see #addTravelSegment
*/
Camera.prototype.addTravelSegments = function (segments) {
for (var i = 0; i < segments.length; i++) {
this.addTravelSegment(segments[i]);
}
};
/**
* Runs the camera along the travelling segments.
*/
Camera.prototype.action = function () {
// Move to the initial position
this._travelTo(this._config.settings[0]);
// Now, set a timer to move to the next position after each segment
var that = this;
var curSegmentIndex = 0, curSegment, segments = this._config.segments,
nSegments = segments.length;
var timerId, settings = this._config.settings;
var startTime = (new Date()).getTime();
var moveCamera = function () {
var curTime = (new Date()).getTime();
var curRunLength = curTime - startTime;
var p = 0, setting, s, e, pos, zoom, dir;
// Check if we are still in the current segment
if (curRunLength > curSegment.endRunLength) {
// We have moved past the current segment.
that.fire({
type: Camera.events.segmentComplete,
segmentIndex: curSegmentIndex,
segment: segments[curSegmentIndex]
});
// Move to the next segment
for (var i = curSegmentIndex + 1; i < nSegments; i++) {
if (segments[i].endRunLength >= curRunLength) {
curSegmentIndex = i;
curSegment = segments[curSegmentIndex];
break;
}
}
if (i === nSegments) {
// We ran past the last segment
curSegmentIndex = nSegments - 1;
curSegment = segments[curSegmentIndex];
curRunLength = curSegment.endRunLength;
clearInterval(timerId);
that.fire(Camera.events.complete);
}
}
p = (curRunLength - curSegment.startRunLength) / curSegment.runLength;
pos = curSegment.interpolators.position;
zoom = curSegment.interpolators.zoom;
dir = curSegment.interpolators.direction;
s = settings[curSegmentIndex];
e = settings[curSegmentIndex + 1]; // There is one more settings
setting = {
position: {
x: pos(p, s.position.x, e.position.x - s.position.x, 1),
y: pos(p, s.position.y, e.position.y - s.position.y, 1)
},
direction: dir(p, s.direction, e.direction - s.direction, 1),
zoom: zoom(p, s.zoom, e.zoom - s.zoom, 1)
};
that._travelTo(setting);
};
if (nSegments > 0) {
curSegment = segments[curSegmentIndex];
timerId = setInterval(moveCamera, this._config.frameLength);
}
};
/**
* Moves the camera to the given position
*
* @param setting description with position, angle and scale
*/
Camera.prototype._travelTo = function (setting) {
var t = this._config.target;
var m = t.getMatrix();
var vp = this._config.viewport;
m.toIdentity();
// Move to viewport center
m.translate(vp.width / 2, vp.height / 2);
// Apply scale and rotate
m.scale(setting.zoom).rotate(setting.direction);
// Center on object
m.translate(-setting.position.x, -setting.position.y);
t.setMatrix(m);
};
var sw = window.sw;
if (window.sw === undefined) {
window.sw = {};
sw = window.sw;
}
sw.tools = sw.tools || {};
sw.tools.Camera = Camera;
});/res/3.0/scripts/tools/text-effects.js
/** =======================================================================
* Vincent Hardy
* License terms: see svg-wow.org
* CC0 http://creativecommons.org/publicdomain/zero/1.0/
* ======================================================================= */
(function () {
YUI.add("text-effects",
function (Y) {
var sw = window.sw, Animate = sw.animation.Animate,
Easing = Y.Easing,
effectsLib = {};
sw.TextEffects = {
effects: effectsLib
};
/**
* This class represents a series of animations and actions which can be
* manipulated as a single entity.
*
* @param anims the set of animations composing this effect
*/
function Effect (anims) {
this.anims = anims;
}
Effect.prototype.run = function () {
this.anims[0].run.apply(this.anims[0], arguments);
};
Effect.prototype.onBegin = function () {
this.anims[0].onBegin.apply(this.anims[0], arguments);
};
Effect.prototype.onEnd = function () {
var i = this.anims.length - 1;
this.anims[i].onBegin.apply(this.anims[i], arguments);
};
Effect.prototype.setStartState = function () {
var anims = this.anims, n = anims.length;
for (var i = 0; i < n; i++) {
anims[i].applyStartFrame();
}
};
/**
* Utility method: computes the advance for each character in a
* text string.
*/
function computeTextPositions (text) {
var tc = text.get('textContent'), n = tc.length, i, pos = [],
curPos = null, p, x, y, p0, dx = 0, dy = 0;
// This method uses getStartPositionOfChar. Safari, Opera, FireFox
// do different adjustments on the returned position. To compensate for
// the differences, the following code gets the text's x and y
// coordinates and adds the delta between these values and the
// value getStartPositionOfChar returns for the first character.
x = text.get('x');
y = text.get('y');
text.set('x', 0);
text.set('y', 0);
dx = x;
dy = y;
for (i = 0; i < n; i++) {
p = text._node.getStartPositionOfChar(i);
if (curPos === null ||
p.x !== curPos.p.x || p.y !== curPos.p.y) {
curPos = {
p: {x: p.x + dx, y: p.y + dy},
n: 1
};
pos.push(curPos);
} else {
// Same position, just increase the text run length
curPos.n++;
}
}
text.set('x', x);
text.set('y', y);
return pos;
}
var excludeAttrs = {
id: true,
x: true,
y: true,
dx: true,
dy: true,
'data-text-effect': true
}
/**
* Implementation helper: returns a handle that will set the desired style
* property on the target element.
*
* @param target the element target
* @param property the property to set
* @param val the property value
*/
function getStyleSetter (target, property, value) {
return function () {
target.setStyle(property, value);
}
}
/**
* Implementation helper, used to do nothing on setStartState.
*
*/
function noOp () {
}
/**
* Implementation helper. Merges the two configuration objects.
*
* @param target the default configuration object on which to merge the
* properties. Typically the defaults.
* @param config the user configuration
* @return the merged configuration, with the user defined properties or the
* defaults for unspecified properties.
*/
function mergeConfig (target, config) {
for (var q in config) {
if (config.hasOwnProperty(q)) {
target[q] = config[q];
}
}
return target;
}
/**
* Common utility method for text effects: breaks down the text into individual
* text element, one for each glyph.
*
* @param lines the text element(s) to break down.
* @return an array of text element spans
*/
function toGlyphSpans (lines) {
var spans = [];
Y.each(lines, function (text) {
var tc = text.get('textContent'), s,
ns = text.get('namespaceURI'),
pos = computeTextPositions(text), n = pos.length, p, j = 0,
tg = Y.one(document.createElementNS(ns, 'g')), attrs, item, val;
text.get('parentNode').appendChild(tg);
// Copy all the text element attributes onto the text group
attrs = text._node.attributes;
for (j = 0; j < attrs.length; j++) {
item = attrs.item(j);
val = item.nodeValue;
if (excludeAttrs[item.name] === undefined) {
if (item.name === "class") {
val = val.replace('text-effects', '');
}
if (val.length > 0) {
tg._node.setAttributeNS(item.namespaceURI,
item.name,
val);
}
}
}
tg.removeClass('text-effects');
j = 0;
for (var i = 0; i < n; i++) {
p = pos[i];
s = Y.one(document.createElementNS(ns, 'text'));
s.set('textContent', tc.substring(j, j + p.n));
s.set('x', p.p.x);
s.set('y', p.p.y);
tg.appendChild(s);
spans.push(s);
j += p.n;
}
text.setStyle('display', 'none');
});
return spans;
}
effectsLib['opacity-swipe'] = {
/**
* Applies the effect to the given text element.
*/
applyEffect : function (text, cfg) {
var spans = toGlyphSpans(text), n = spans.length, s, a, anims = [],
config = mergeConfig(this.getConfig(), cfg);
for (var i = 0; i < n; i++) {
s = spans[i];
a = new Animate({
node: s,
from: {'fill-opacity': 0},
to: {'fill-opacity': 1},
duration: config.duration,
easing: config.easing
});
anims.push(a);
}
for (i = 1; i < n; i++) {
anims[0].onBegin(anims[i], i * config.offset);
}
return new Effect(anims);
},
/**
* Configuration
*/
getConfig: function () {
return {
/**
* Duration for each letter
*/
duration: 0.25,
/**
* Offset between the start of each animation
*/
offset: 0.0125,
/**
* Easing method for the letter animationss
*/
easing: Easing.easeIn
};
}
};
effectsLib['color-swipe'] = {
/**
* Applies the effect to the given text element.
*/
applyEffect : function (text, cfg) {
var spans = toGlyphSpans(text), n = spans.length, s, a, anims = [],
config = mergeConfig(this.getConfig(), cfg);
for (var i = 0; i < n; i++) {
s = spans[i];
a = new Animate({
node: s,
from: {'fill': config.startColor, 'fill-opacity': 0},
to: {'fill': config.endColor, 'fill-opacity': 1},
duration: 1,
easing: config.easing
});
anims.push(a);
}
for (i = 1; i < n; i++) {
anims[0].onBegin(anims[i], i * config.offset);
}
return new Effect(anims);
},
/**
* Configuration
*/
getConfig: function () {
return {
/**
* Duration for each letter
*/
duration: 0.25,
/**
* Offset between the start of each animation
*/
offset: 0.03,
/**
* Start color
*/
startColor: 'orange',
/**
* End color
*/
endColor: 'crimson',
/**
* Easing method for the letter animationss
*/
easing: Easing.easeIn
};
}
};
effectsLib.whip = {
/**
* Applies the effect to the given text element.
*/
applyEffect : function (text, cfg) {
var spans = toGlyphSpans(text), n = spans.length, s,
a, anims = [], o, textEffect,
config = mergeConfig(this.getConfig(), cfg);
for (var i = 0; i < n; i++) {
s = spans[i];
o = config.fallHeight;
a = new Animate({
node: s,
from: {dy: o},
to: {dy: 0},
duration: config.duration,
easing: config.easing
});
s.setStyle('fill-opacity', 1);
s.set('dy', o);
anims.push(a);
}
for (i = 1; i < n; i++) {
anims[0].onBegin(anims[i], i * 0.012);
}
return new Effect(anims);
},
/**
* Configuration
*/
getConfig: function () {
return {
/**
* Duration for each letter
*/
duration: 1.2,
/**
* Offset between the start of each animation
*/
offset: 0.012,
/**
* Height of the letter fall
* (may be negative)
*/
fallHeight: -500,
/**
* Easing method for the letter animationss
*/
easing: Easing.elasticOut
};
}
};
effectsLib['bouncing-letters'] = {
/**
* Applies the effect to the given text element.
*/
applyEffect : function (text, cfg) {
var spans = toGlyphSpans(text),
n = spans.length, s, a, anims = [], x, y, textEffect,
config = mergeConfig(this.getConfig(), cfg);
for (var i = 0; i < n; i++) {
s = spans[i];
y = s.get('y');
x = s.get('x');
a = new Animate({
node: s,
from: {transform: {sy: 0}},
to: {transform: {sy: 1}},
transformTemplate: "translate(" + x + "," + y + ")" +
"scale(1,#sy)" +
"translate(" + (-x) + "," + (-y) + ")",
duration: config.duration,
easing: config.easing
});
anims.push(a);
}
for (i = 1; i < n; i++) {
anims[0].onBegin(anims[i], config.offset * i);
}
return new Effect(anims);
},
/**
* Configuration
*/
getConfig: function () {
return {
/**
* Duration for each bounce
*/
duration: 1.2,
/**
* Offset between the start of each letter animation
*/
offset: 0.05,
/**
* Easing method for the flips
*/
easing: Easing.elasticOut
};
}
};
effectsLib.wiggling = {
/**
* Applies the effect to the given text element.
*/
applyEffect : function (text, cfg) {
var spans = toGlyphSpans(text), n = spans.length, s, a, anims = [],
bbox, cx, cy, textEffect,
config = mergeConfig(this.getConfig(), cfg);
for (var i = 0; i < n; i++) {
s = spans[i];
bbox = s._node.getBBox();
cx = bbox.x + bbox.width / 2;
cy = bbox.y + bbox.height / 2;
a = new Animate({
node: s,
from: {transform: {r: 180}},
to: {transform: {r: 0}},
transformTemplate: "translate(" + cx + "," + cy + ")" +
"rotate(#r)" +
"translate(" + (-cx) + "," + (-cy) + ")",
duration: config.duration,
easing: Easing.elasticOut
});
anims.push(a);
a.onBegin(getStyleSetter(s, 'display', 'inline'));
}
for (i = 1; i < n; i++) {
anims[0].onBegin(anims[i], config.offset * i);
}
textEffect = new Effect(anims);
textEffect.setStartState = function () {
for (var i = 0; i < n; i++) {
anims[i].applyStartFrame();
spans[i].setStyle('display', 'none');
}
};
return textEffect;
},
/**
* Configuration
*/
getConfig: function () {
return {
/**
* Duration for each of the flips
*/
duration: 3,
/**
* Offset between the start of each letter flip
*/
offset: 0.05,
/**
* Easing method for the flips
*/
easing: Easing.elasticOut
};
}
};
effectsLib["horizontal-flip"] = {
/**
* Applies the effect to the given text element.
*/
applyEffect : function (text, cfg) {
var spans = toGlyphSpans(text), n = spans.length, s, a, anims = [],
bbox, cx, cy, textEffect,
config = mergeConfig(this.getConfig(), cfg);
for (var i = 0; i < n; i++) {
s = spans[i];
bbox = s._node.getBBox();
cx = bbox.x + bbox.width / 2;
cy = bbox.y + bbox.height / 2;
a = new Animate({
node: s,
from: {transform: {sy: 0}},
to: {transform: {sy: 1}},
transformTemplate: "translate(" + cx + "," + cy + ")" +
"scale(1, #sy)" +
"translate(" + (-cx) + "," + (-cy) + ")",
duration: config.duration,
easing: config.easing
});
anims.push(a);
}
for (i = 1; i < n; i++) {
anims[0].onBegin(anims[i], config.offset * i);
}
return new Effect(anims);
},
/**
* Configuration
*/
getConfig: function () {
return {
/**
* Duration for each of the flips
*/
duration: 0.25,
/**
* Offset between the start of each letter flip
*/
offset: 0.03,
/**
* Easing method for the flips
*/
easing: Easing.easeIn
};
}
};
effectsLib["vertical-flip"] = {
/**
* Applies the effect to the given text element.
*/
applyEffect : function (text, cfg) {
var spans = toGlyphSpans(text), n = spans.length, s, a, anims = [],
bbox, cx, cy, textEffect,
config = mergeConfig(this.getConfig(), cfg);
for (var i = 0; i < n; i++) {
s = spans[i];
bbox = s._node.getBBox();
cx = bbox.x + bbox.width / 2;
cy = bbox.y + bbox.height / 2;
a = new Animate({
node: s,
from: {transform: {sx: 0}},
to: {transform: {sx: 1}},
transformTemplate: "translate(" + cx + "," + cy + ")" +
"scale(#sx, 1)" +
"translate(" + (-cx) + "," + (-cy) + ")",
duration: config.duration,
easing: config.easing
});
anims.push(a);
}
for (i = 1; i < n; i++) {
anims[0].onBegin(anims[i], config.offset * i);
}
return new Effect(anims);
},
/**
* Configuration
*/
getConfig: function () {
return {
/**
* Duration for each of the flips
*/
duration: 0.25,
/**
* Offset between the start of each letter flip
*/
offset: 0.03,
/**
* Easing method for the flips
*/
easing: Easing.easeIn
};
}
};
effectsLib['horizontal-shuffle'] = {
/**
* Applies the effect to the given text element.
*/
applyEffect : function (text, cfg) {
var spans = toGlyphSpans(text), n = spans.length, s,
a, anims = [], o, dir, textEffect,
config = mergeConfig(this.getConfig(), cfg);
for (var i = 0; i < n; i++) {
s = spans[i];
o = config.shuffleWidth;
dir = i % 2 === 0 ? 1 : -1;
a = new Animate({
node: s,
from: {dx: dir * o, 'fill-opacity': 0},
to: {dx: 0, 'fill-opacity': 1},
duration: 0.5 * (1 + Math.random()) * config.duration,
easing: config.easing
});
anims.push(a);
}
for (i = 1; i < n; i++) {
anims[0].onBegin(anims[i], i * config.offset);
}
return new Effect(anims);
},
/**
* Configuration
*/
getConfig: function () {
return {
/**
* Duration for each letter
*/
duration: 1,
/**
* Offset between the start of each animation
*/
offset: 0.012,
/**
* Max width for the shuffle
*/
shuffleWidth: 1000,
/**
* Easing method for the letter animationss
*/
easing: Easing.easeOutStrong
};
}
};
effectsLib['zoom-out'] = {
/**
* Applies the effect to the given text element.
*/
applyEffect : function (text, cfg) {
var spans = toGlyphSpans(text), n = spans.length, s,
a, anims = [], bbox, cx, cy, textEffect,
config = mergeConfig(this.getConfig(), cfg);
for (var i = 0; i < n; i++) {
s = spans[i];
bbox = s._node.getBBox();
cx = bbox.x + bbox.width / 2;
cy = bbox.y + bbox.height / 2;
a = new Animate({
node: s,
from: {transform: {sx: 3, sy: 3}, 'fill-opacity': 0},
to: {transform: {sx: 1, sy: 1}, 'fill-opacity': 1},
duration: 0.5 * (1 + Math.random()) * config.duration,
easing: config.easing,
transformTemplate: "translate(" + cx + "," + cy + ")" +
"scale(#sx, #sy)" +
"translate(" + (-cx) + "," + (-cy) + ")",
transformTemplate2: "scale(#sx, #sy)"
});
anims.push(a);
}
for (i = 1; i < n; i++) {
anims[0].onBegin(anims[i], i * config.offset);
}
return new Effect(anims);
},
/**
* Configuration
*/
getConfig: function () {
return {
/**
* Duration for each letter
*/
duration: 0.25,
/**
* Offset between the start of each animation
*/
offset: 0.05,
/**
* Max width for the shuffle
*/
shuffleWidth: 1000,
/**
* Easing method for the letter animationss
*/
easing: Easing.none
};
}
};
});
})();
/res/2.0/scripts/dom-utils.js
/** =======================================================================
* Vincent Hardy
* License terms: see svg-wow.org
* CC0 http://creativecommons.org/publicdomain/zero/1.0/
* ======================================================================= */
(function () {
// Use the sw (svgWow!) prefix for all the library.
window.sw = window.sw ? window.sw : {};
/**
* Global function for getting an element by id concisely.
*/
if (window.$ === undefined) {
window.$ = function (id) {
return document.getElementById(id);
};
}
// Namespace constants
sw.svgNS = "http://www.w3.org/2000/svg";
sw.xlinkNS = "http://www.w3.org/1999/xlink";
sw.wowNS = "http://www.svgopen.org/2004/svgWow";
sw.xhtmlNS = "http://www.w3.org/1999/xhtml";
// Default namespace prefixes
var defaultNamespacePrefixes = {
svg: sw.svgNS,
xlink: sw.xlinkNS,
sw: sw.wowNS,
xhtml: sw.xhtmlNS
};
// =========================================================================
// DOM Helpers
// =========================================================================
sw.firstElement = function () {
var c = this.firstChild;
var result = null;
while (c !== null) {
if (c.nodeType === Node.ELEMENT_NODE) {
result = c;
break;
}
c = c.nextSibling;
}
return result;
};
sw.nextElement = function () {
var s = this.nextSibling;
var result = null;
while (s !== null) {
if (s.nodeType === Node.ELEMENT_NODE) {
result = s;
break;
}
s = s.nextSibling;
}
return result;
};
sw.prevElement = function () {
var s = this.prevSibling;
var result = null;
while (s !== null) {
if (s.nodeType === Node.ELEMENT_NODE) {
result = s;
break;
}
s = s.prevSibling;
}
return result;
};
sw.removeAllChildren = function () {
var c = this.firstChild;
var nc;
while (c !== null) {
nc = c.nextSibling;
this.removeChild(c);
c = nc;
}
};
sw.getMatrix = function () {
var m = undefined, txf, svg;
if (this.transform !== undefined) {
txf = this.transform.baseVal.consolidate();
if (txf === null) {
svg = this.ownerSVGElement;
m = svg.createSVGMatrix();
txf = this.transform.baseVal.createSVGTransformFromMatrix(m);
this.transform.baseVal.initialize(txf);
} else {
m = txf.matrix;
}
}
return m;
}
sw.setMatrix = function (m) {
var txf, svg;
if (this.transform !== undefined) {
svg = this.ownerSVGElement;
txf = this.transform.baseVal.createSVGTransformFromMatrix(m);
this.transform.baseVal.initialize(txf);
}
return this;
}
sw.getShowHandler = function () {
var that = this;
return function () {
that.setAttribute("display", "inline");
}
};
sw.getHideHandler = function () {
var that = this;
return function () {
that.setAttribute("display", "none");
}
};
/**
* Global function for toggling the current display value.
*
* @param id the id of the element whose display should be toggled between
* 'block' and 'none'
*/
function toggleDisplay(id) {
var elm = $(id);
if(elm) {
elm.style.display = (elm.style.display == "none" ? "block" : "none");
}
}
// =============================================================================
// Simple SVG API
//
// @see: http://www.w3.org/Graphics/SVG/WG/wiki/Simple_SVG_API
// =============================================================================
// List of SVG elements on which the setAttributes method is made available
sw.svgElements = [
"a",
"altGlyph",
"altGlyphDef",
"altGlyphItem",
"animate",
"animateColor",
"animateMotion",
"animateTransform",
"circle",
"clipPath",
"color-profile",
"cursor",
"definition-src",
"defs",
"desc",
"ellipse",
"feBlend",
"feColorMatrix",
"feComponentTransfer",
"feComposite",
"feConvolveMatrix",
"feDiffuseLighting",
"feDisplacementMap",
"feDistantLight",
"feFlood",
"feFuncA",
"feFuncB",
"feFuncG",
"feFuncR",
"feGaussianBlur",
"feImage",
"feMerge",
"feMergeNode",
"feMorphology",
"feOffset",
"fePointLight",
"feSpecularLighting",
"feSpotLight",
"feTile",
"feTurbulence",
"filter",
"font",
"font-face",
"font-face-format",
"font-face-name",
"font-face-src",
"font-face-uri",
"foreignObject",
"g",
"glyph",
"glyphRef",
"hkern",
"image",
"line",
"linearGradient",
"marker",
"mask",
"metadata",
"missing-glyph",
"mpath",
"path",
"pattern",
"polygon",
"polyline",
"radialGradient",
"rect",
"script",
"set",
"stop",
"style",
"svg",
"switch",
"symbol",
"text",
"textPath",
"title",
"tref",
"tspan",
"use",
"view",
"vkern"
];
/**
* This method automatically loads and creates DOM nodes.
*
* The symtax for the object is as follows;
* - the tag property gives the object's tag name
* - the ns property gives the object's namespace. Optional, defaults to the
* SVG namespace.
* - the children property is a set of sub-objects with the same syntax.
*
* @param p_desc the object describing the element to create and initialize.
* @param p_oInsertBefore Optional. the child before which the loaded content
* should be inserted
* @return the element that was created.
*/
sw.loadContent = function (p_desc, p_oInsertBefore) {
var content;
if (typeof p_desc === "string") {
content = document.createTextNode(p_desc);
this.appendChild(document.createTextNode(p_desc));
} else if (typeof p_desc === "object") {
// Save the reserved values first.
var tagOrig = p_desc.tag;
var nsOrig = p_desc.ns;
var childrenOrig = p_desc.children;
// Now, process the element.
var tag = p_desc.tag;
if (tag === undefined) {
throw new Error(
"the element description requires a 'tag' property");
}
var ns = sw.svgNS;
if (p_desc.ns !== undefined) {
ns = p_desc.ns;
}
content = document.createElementNS(ns, tag);
if (content === null || content === undefined) {
throw new Error("was not able to create an element with tag " +
tag + " in namespace " + ns);
}
var children = p_desc.children;
delete p_desc.children;
delete p_desc.tag;
delete p_desc.ns;
content.setAttributes(p_desc);
if (children !== undefined && children !== null) {
var nChildren = children.length;
if (typeof nChildren === "number") {
for (var i = 0; i < nChildren; i++) {
var c = content.loadContent(children[i]);
}
}
}
// Restore
p_desc.children = childrenOrig;
p_desc.tag = tagOrig;
p_desc.ns = nsOrig;
if (p_oInsertBefore === undefined) {
p_oInsertBefore = null;
}
if (this.insertBefore !== undefined) {
this.insertBefore(content, p_oInsertBefore);
}
sw.initIds(content);
} else {
throw new Error("loadContent requires an object or string parameter");
}
return content;
}
/**
* The setAttributes method to be installed on all element classes.
*
* @param attributes an object with the attributes to set on the object this
* method is called on.
*/
sw.setAttributes = function (attributes) {
var value,
ns = null,
nsPrefix,
nsIndex;
for (var p in attributes) {
if (attributes.hasOwnProperty(p) === true) {
nsIndex = p.indexOf(":");
if (nsIndex !== -1) {
nsPrefix = p.substring(0, nsIndex);
ns = this.lookupNamespaceURI(nsPrefix);
if (ns === null) {
// No namespace declaration was found on the node.
// This may be because the node is not in the tree
// yet. The best thing which can be done here is to
// check if we can find the namespace definition on the
// document element.
ns = document.documentElement.lookupNamespaceURI(nsPrefix);
// If the namespace is still not found, check the
// default list of known namespaces
if (defaultNamespacePrefixes[nsPrefix] !== undefined) {
ns = defaultNamespacePrefixes[nsPrefix];
}
}
} else {
ns = null;
}
value = attributes[p];
try {
this.setAttributeNS(ns, p, value);
} catch (e) {
console.log("could not set " + p + " for " + ns + " to " + value);
}
}
}
};
/**
* Get a number of attributes on this element and return them in an object.
*
* @param attr1, ... attrN a variable length list of attributes to retrieve
* from this element.
* @return an object whose properties are the requested attribute values
*/
sw.getAttributes = function () {
var result = {};
var nsIndex = -1;
var attribute;
var ns = null;
var nsPrefix;
for (var i = 0; i < arguments.length; i++) {
attribute = arguments[i];
nsIndex = attribute.indexOf(":");
if (nsIndex !== -1) {
nsPrefix = attribute.substring(0, nsIndex);
ns = this.lookupNamespaceURI(nsPrefix);
if (ns === null) {
ns = svg.lookupNamespaceURI(nsPrefix);
}
} else {
ns = null;
}
result[attribute] = this.getAttributeNS(ns, attribute);
}
return result;
}
/**
* Utility to get the bounds of an object in the nearest viewport space.
*/
sw.getViewportBBox = function () {
var bbox = this.getBBox();
var vBbox = null;
var viewport = this.nearestViewportElement;
var ctm = this.getTransformToElement(viewport);
if (bbox !== null) {
// This is one of the short-comings of SVG: there is no way to get
// the bbox in the desired coordinate space. So we have to transform
// the bounds and compute the box from that, which leads to
// boxes which might be larger than needed (e.g., where there are
// rotations). However, for common cases, this is doing the job.
var points = [
{x: bbox.x, y: bbox.y},
{x: bbox.x + bbox.width, y: bbox.y},
{x: bbox.x, y: bbox.y + bbox.height},
{x: bbox.x + bbox.width, y: bbox.y + bbox.height}
];
var tPoints = [
{}, {}, {}, {}
];
for (var i = 0; i < 4; i++) {
ctm.transformPoint(points[i], tPoints[i]);
}
var minX = tPoints[0].x;
var minY = tPoints[0].y;
var maxX = tPoints[0].x;
var maxY = tPoints[0].y;
for (i = 1; i < 4; i++) {
if (tPoints[i].x < minX) {
minX = tPoints[i].x;
} else if (tPoints[i].x > maxX) {
maxX = tPoints[i].x;
}
if (tPoints[i].y < minY) {
minY = tPoints[i].y;
} else if (tPoints[i].y > maxY) {
maxY = tPoints[i].y;
}
}
vBbox = {
x: minX,
y: minY,
width: maxX - minX,
height: maxY - minY
};
}
return vBbox;
};
/**
* Transforms a point.
*
* @param p_pt an object with x/y properties
* @param p_oResult an object where the transformed point is stored
* @return the result
*/
sw.transformPoint = function (p_pt, p_oResult) {
var result = p_oResult;
if (p_oResult === undefined) {
result = {};
}
result.x = this.a * p_pt.x + this.c * p_pt.y + this.e;
result.y = this.b * p_pt.x + this.d * p_pt.y + this.f;
return result;
};
/**
* Sets the matrix to identity
*/
sw.toIdentity = function () {
this.a = 1;
this.b = 0;
this.c = 0;
this.d = 1;
this.e = 0;
this.f = 0;
return this;
};
/**
* Installs the setAttributes method on the prototype object which holds the
* setAttribute (no 's') method.
*
* @param documentElement if undefined, defaults to document.documentElement,
* assuming an SVG root.
* @param scope if undefined, defaults to the global scope.
*/
sw.init = function (documentElement, scope) {
if (documentElement === undefined) {
documentElement = document.documentElement;
}
if (scope === undefined) {
scope = window;
}
var errors = {};
var hasErrors = false;
for (var i = 0; i < sw.svgElements.length; i++) {
var tag = sw.svgElements[i];
var elt = document.createElementNS(sw.svgNS, tag);
if (elt !== null && elt !== undefined) {
var proto = elt.constructor.prototype;
if (proto.setAttributes === undefined) {
proto.setAttributes = sw.setAttributes;
}
if (proto.getAttributes === undefined) {
proto.getAttributes = sw.getAttributes;
}
if (proto.loadContent === undefined) {
proto.loadContent = sw.loadContent;
}
if (proto.firstElmeent === undefined) {
proto.firstElement = sw.firstElement;
}
if (proto.nextElement === undefined) {
proto.nextElement = sw.nextElement;
}
if (proto.prevElement === undefined) {
proto.prevElement= sw.prevElement;
}
if (proto.removeAllChildren === undefined) {
proto.removeAllChildren = sw.removeAllChildren;
}
if (proto.getMatrix === undefined) {
proto.getMatrix = sw.getMatrix;
}
if (proto.setMatrix === undefined) {
proto.setMatrix = sw.setMatrix;
}
if (proto.getViewportBBox === undefined) {
proto.getViewportBBox = sw.getViewportBBox;
}
if (proto.getHideHandler === undefined) {
proto.getHideHandler = sw.getHideHandler;
}
if (proto.getShowHandler === undefined) {
proto.getShowHandler = sw.getShowHandler;
}
} else {
errors[tag] = "Constructed element was " + elt;
hasErrors = true;
}
}
// Hook a transformPoint and toIdentity on SVGMatrix
var svg = documentElement;
var isSVG = true;
if (svg.nodeName !== "svg") {
svg = document.createElementNS(sw.svgNS, "svg");
isSVG = false;
}
var m = svg.createSVGMatrix();
if (m.constructor.prototype.transformPoint === undefined) {
m.constructor.prototype.transformPoint = sw.transformPoint;
}
if (m.constructor.prototype.toIdentity === undefined) {
m.constructor.prototype.toIdentity = sw.toIdentity;
}
if (hasErrors === true) {
throw new Error("Could not install setAttributes on all elements");
}
document.constructor.prototype.loadContent = sw.loadContent;
sw.initIds(documentElement);
// Make the root 'svg' element available in the global scope
if (isSVG) {
scope.svg = documentElement;
}
}
/**
* Processes ids on elements and sets a variable of that name on their parents.
*
* @param elt the element to process. Its children are processed recursively.
*/
sw.initIds = function (elt) {
var id = elt.id;
if (id !== undefined &&
id !== null &&
id !== "" &&
(typeof id === "string") &&
elt.parentNode !== undefined &&
elt.parentNode !== null &&
elt.parentNode[id] === undefined) {
sw.addElementShortHand(id, elt, elt.parentNode);
}
var c = elt.firstChild;
while (c !== null) {
if (c.nodeType === Node.ELEMENT_NODE) {
sw.initIds(c);
}
c = c.nextSibling;
}
}
/**
* Adds a property of the name "id" to the parent chain, starting with the
* parent parameter. If the parent itself has an id, then the property is set
* on that node. Otherwise, the property is set on the first ancestor with an
* id
*
* @param id the name of the property to set
* @param node the value of the property to set
* @param parent the first candidate parent on which the property might be set
*/
sw.addElementShortHand = function(id, node, parent) {
// Note that parent.id is the value of the 'id' attribute on parent
// whereas parent[id] is the value of the property with the name of the
// id parameter (e.g., 'myRect') on parent.
if (parent.id !== undefined && parent.id !== "") {
if (parent[id] === undefined) {
parent[id] = node;
}
} else if (parent.parentNode !== null && parent.parentNode !== parent) {
sw.addElementShortHand(id, node, parent.parentNode);
} else {
if (document[id] === undefined) {
document[id] = node;
}
}
}
/**
* Helper method to find out if an element is a descendant of a given parent
* node.
*
* @param candidate the element that may be the descendant of the parent.
* @param parent the parent under which the candidate may be
*/
sw.isDescendantOf = function (candidate, parent) {
var isDescendant = false;
var p = candidate;
while (p !== parent && p.parentNode !== null) {
p = p.parentNode;
}
return (p === parent);
}
/**
* Helper method: converts a <code>String</code> to an <code>Element</code>
* and throws an error if the element cannot be found. If the parameter is
* not a string, it is returned as is.
*/
sw.stringToElement = function (p_element) {
var element = p_element;
if (typeof p_element === "string") {
element = document.getElementById(p_element);
}
if (element === null) {
throw new Error ("Could not find element with id " + p_element);
}
return element;
}
})();/res/3.0/scripts/compat/restore.js
/**
* Compatibility layer for the restored YUI 3 demos.
*
* Load this before yui-debug.js. It keeps the YUI loader on this origin,
* restores two SVG DOM members that browsers have removed, and provides the
* start control and the synthesized sound used in place of the original
* music tracks. Sound is created only after a click on a start button.
*/
(function () {
'use strict';
// Never let the loader build a combo URL for the retired YUI CDN.
window.YUI_config = window.YUI_config || {};
window.YUI_config.combine = false;
// Only the -debug builds of the modules were archived.
window.YUI_config.filter = 'debug';
window.YUI_config.debug = false;
window.YUI_config.useBrowserConsole = false;
// =========================================================================
// Removed SVG DOM members
// =========================================================================
var graphics = (window.SVGGraphicsElement || window.SVGElement).prototype;
if (!graphics.getTransformToElement) {
graphics.getTransformToElement = function (target) {
return target.getScreenCTM().inverse().multiply(this.getScreenCTM());
};
}
if (!('nearestViewportElement' in graphics)) {
Object.defineProperty(graphics, 'nearestViewportElement', {
configurable: true,
get: function () { return this.ownerSVGElement; }
});
}
// dom-utils.js only installs this when it is missing. Its own version
// passes an output argument to transformPoint, which DOMMatrix ignores.
graphics.getViewportBBox = function () {
var box = this.getBBox(),
m = this.getTransformToElement(this.nearestViewportElement),
xs = [], ys = [];
[[box.x, box.y], [box.x + box.width, box.y],
[box.x, box.y + box.height], [box.x + box.width, box.y + box.height]
].forEach(function (p) {
xs.push(m.a * p[0] + m.c * p[1] + m.e);
ys.push(m.b * p[0] + m.d * p[1] + m.f);
});
var minX = Math.min.apply(null, xs), minY = Math.min.apply(null, ys);
return {
x: minX,
y: minY,
width: Math.max.apply(null, xs) - minX,
height: Math.max.apply(null, ys) - minY
};
};
// =========================================================================
// Start control, sound toggle and replay button
// =========================================================================
var css = [
'.sw-controls{position:absolute;z-index:20;display:flex;flex-wrap:wrap;gap:8px;',
'justify-content:center;transform:translate(-50%,-50%);width:max-content;max-width:92vw}',
'.sw-controls button,.sw-sound{font:600 15px/1.2 system-ui,-apple-system,"Segoe UI",sans-serif;',
'min-height:44px;padding:10px 18px;border-radius:6px;border:1px solid #202020;',
'background:#202020;color:#fff;cursor:pointer}',
'.sw-controls button.sw-alt{background:#fff;color:#202020}',
'.sw-controls button:hover,.sw-sound:hover{background:#b0122f;border-color:#b0122f;color:#fff}',
'.sw-controls button:focus-visible,.sw-sound:focus-visible{outline:3px solid #ffb000;outline-offset:2px}',
'.sw-sound{position:fixed;top:8px;right:8px;z-index:21;font-size:13px;min-height:36px;padding:6px 12px}'
].join('');
function addStyle() {
if (document.getElementById('sw-restore-style')) { return; }
var style = document.createElement('style');
style.id = 'sw-restore-style';
style.textContent = css;
(document.head || document.documentElement).appendChild(style);
}
function button(label, className, handler) {
var b = document.createElement('button');
b.setAttribute('type', 'button');
if (className) { b.className = className; }
b.textContent = label;
b.addEventListener('click', function (event) {
event.stopPropagation();
handler(event);
});
return b;
}
function placeOver(box, target, at) {
function place() {
var r = target.getBoundingClientRect();
box.style.left = (r.left + window.pageXOffset + r.width / 2) + 'px';
box.style.top = (r.top + window.pageYOffset + r.height * at) + 'px';
}
place();
window.addEventListener('resize', place);
return function () { window.removeEventListener('resize', place); };
}
/**
* Shows "Start" and "Start with sound" over the target element.
*
* @param opts.target the element to centre the buttons on
* @param opts.onStart called once with true when sound was requested
* @param opts.score optional note pattern for the synthesized sound
* @param opts.at vertical position over the target, 0 to 1
*/
function startControl(opts) {
addStyle();
var box = document.createElement('div'), release, primary;
box.className = 'sw-controls';
function go(withSound) {
release();
box.parentNode.removeChild(box);
if (withSound) {
var s = createScore(opts.score);
s.play();
soundToggle(s);
}
opts.onStart(withSound);
}
primary = button('Start', '', function () { go(false); });
box.appendChild(primary);
box.appendChild(button('Start with sound', 'sw-alt', function () { go(true); }));
document.body.appendChild(box);
release = placeOver(box, opts.target, opts.at === undefined ? 0.5 : opts.at);
try { primary.focus({preventScroll: true}); } catch (e) { primary.focus(); }
}
function soundToggle(score) {
var b = button('Sound off', 'sw-sound', function () {
if (score.playing()) {
score.stop();
b.textContent = 'Sound on';
} else {
score.play();
b.textContent = 'Sound off';
}
});
document.body.appendChild(b);
}
/** Shows a "Play again" button, which reloads the document. */
function replay(target, at) {
addStyle();
var box = document.createElement('div');
box.className = 'sw-controls';
box.appendChild(button('Play again', '', function () { window.location.reload(); }));
document.body.appendChild(box);
placeOver(box, target, at === undefined ? 0.92 : at);
}
// =========================================================================
// Synthesized sound: a soft plucked pattern scheduled with Web Audio.
// =========================================================================
var DEFAULT_SCORE = {
tempo: 92,
notes: [220, 0, 261.63, 293.66, 0, 329.63, 293.66, 0,
196, 0, 246.94, 293.66, 0, 329.63, 392, 0],
bass: [110, 110, 98, 98]
};
function createScore(pattern) {
var score = pattern || DEFAULT_SCORE,
stepLength = 60 / score.tempo / 2,
ctx = null, master = null, timer = null, step = 0, nextTime = 0;
function pluck(freq, when, length, level, type) {
var osc = ctx.createOscillator(), gain = ctx.createGain();
osc.type = type;
osc.frequency.value = freq;
gain.gain.setValueAtTime(0.0001, when);
gain.gain.exponentialRampToValueAtTime(level, when + 0.015);
gain.gain.exponentialRampToValueAtTime(0.0001, when + length);
osc.connect(gain);
gain.connect(master);
osc.start(when);
osc.stop(when + length + 0.02);
}
function schedule() {
while (nextTime < ctx.currentTime + 0.25) {
var n = score.notes[step % score.notes.length];
if (n) { pluck(n, nextTime, 0.7, 0.16, 'triangle'); }
if (step % 4 === 0) {
pluck(score.bass[(step / 4) % score.bass.length], nextTime,
stepLength * 3.5, 0.2, 'sine');
}
step++;
nextTime += stepLength;
}
}
return {
play: function () {
var Ctx = window.AudioContext || window.webkitAudioContext;
if (!Ctx || timer !== null) { return; }
if (!ctx) {
ctx = new Ctx();
master = ctx.createGain();
master.gain.value = 0.5;
master.connect(ctx.destination);
}
ctx.resume();
nextTime = ctx.currentTime + 0.05;
schedule();
timer = setInterval(schedule, 80);
},
stop: function () {
if (timer !== null) { clearInterval(timer); timer = null; }
if (ctx) { ctx.suspend(); }
},
playing: function () { return timer !== null; }
};
}
window.SwRestore = {
startControl: startControl,
replay: replay,
createScore: createScore,
reducedMotion: function () {
return !!(window.matchMedia &&
window.matchMedia('(prefers-reduced-motion: reduce)').matches);
}
};
})();
/res/3.0/scripts/yui/anim-timing/anim-timing-debug.js
/** =======================================================================
* Vincent Hardy
* License terms: see svg-wow.org
* CC0 http://creativecommons.org/publicdomain/zero/1.0/
* ======================================================================= */
(function () {
window.sw = window.sw || {};
sw.animation = sw.animation || {};
YUI.add("anim-timing", function (Y) {
// =============================================================================
// Utility class used to manage animation time offsets.
// =============================================================================
var OffsetManager = {
/**
* List of pending offsets
*/
_pendingOffsets: [],
/**
* The most recent timer identifier (used for cancellation
*/
_lastTimerId: -1,
/**
* Adds a new offset client.
*
* @param p_offset {Number} the offset after which callback should be called.
* @param p_callback the callback to invoke after offset expires. Should
* be a function or an animation instance (i.e., an object with a
* 'run' method).
*/
addOffsetListener : function (p_offset, p_callback) {
p_offset = p_offset !== undefined ? p_offset : 0;
if (p_offset === undefined || p_offset <= 0) {
// Invoke callback immediately.
this._invokeCallback(p_callback);
} else {
var currentTime = (new Date()).getTime(),
offset = {
callback: p_callback,
offset: p_offset,
requestedAt: currentTime,
remainingOffset: p_offset * 1000
};
this._updatePendingOffsets(currentTime);
if (this._insertPendingOffset(offset) === 0) {
// the new offset is at index 0, i.e., it is our most immediate
// new timer. Cancel the current timer if one was set.
// In all cases, start a new timeout.
if (this._lastTimerId !== -1) {
clearTimeout(this._lastTimerId);
}
this._startTimer();
}
}
},
/**
* Implementation helper.
* Starts the timer on the most immediate callback. This assumes the
* callbacks have been sorted in time order and that there is at least
* one.
*/
_startTimer : function () {
this._lastTimerId = setTimeout(function () {
OffsetManager._onTimeout();
}, this._pendingOffsets[0].remainingOffset);
},
/**
* setTimeout callback
*
*/
_onTimeout : function () {
this._timerId = -1;
var po = this._pendingOffsets, o,
currentTime = (new Date()).getTime();
this._updatePendingOffsets(currentTime);
o = po[0];
while (o !== undefined && o.remainingOffset <= 0) {
po.splice(0, 1);
this._invokeCallback(o.callback);
o = po[0];
}
if (po.length > 0) {
this._startTimer();
}
},
/**
* Implementation helper.
*
* Updates the remainingOffset on the _pendingOffsets elements.
*
* @param p_currentTime the current time when this call is made
*/
_updatePendingOffsets : function (p_currentTime) {
var po = this._pendingOffsets, o;
var n = po.length;
for (var i = 0; i < n; i++) {
o = po[i];
o.remainingOffset = o.offset * 1000 - (p_currentTime - o.requestedAt);
}
},
/**
* Implementation helper.
*
* Inserts a new timing offset in the array managed by the offset manager.
*
* @param p_offset the new offset object to insert.
* @return the index at which the new offset object was inserted.
*/
_insertPendingOffset : function (p_offset) {
var po = this._pendingOffsets, o;
var n = po.length;
for (var i = 0; i < n; i++) {
o = po[i];
if (o.remainingOffset > p_offset.remainingOffset) {
po.splice(i, 0, p_offset);
break;
}
}
if (i === n) {
po.push(p_offset);
}
return i;
},
/**
* Invokes the callback.
*
* @param p_callback may be a function or an animation instance.
*/
_invokeCallback : function (p_callback) {
if (typeof p_callback === "function") {
p_callback.call();
} else if (typeof p_callback === "object" &&
p_callback !== null &&
typeof p_callback.run === "function") {
p_callback.run();
}
}
};
/**
* Simple extension of the YUI animation classes to handle SVG transforms.
*
* The extension handles the "r", "sx", "sy", "tx" and "ty" pseudo attributes
* by manipulating the transform of the target element using a template.
*
* @param config the configuration
*
* @see http://developer.yahoo.com/yui/docs/YAHOO.util.Anim.html
*/
sw.animation.Animate = function (config) {
sw.animation.Animate.superclass.constructor.apply(this, arguments);
};
sw.animation.Animate.NAME = "sw.animation.Animate";
sw.animation.Animate.ATTRS = {
transformTemplate: {
value: "rotate(#r) scale(#sx, #sy) translate(#tx, #ty)"
}
};
/**
* Work around usage of regexp in YUI to detect which properties should have a
* default unit.
*
* Unfortunately, the default regexp matches stop-opacity with 'top'
*/
Y.Anim.RE_DEFAULT_UNIT = /^width|^height|^top|^right|^bottom|^left|^margin.*|^padding.*|^border.*$/i;
Y.extend(sw.animation.Animate, Y.Anim, {
/**
* Initializer.
* @see Y.Base
*/
initializer : function () {
var _endCallbacks = [],
_beginCallbacks = [];
this._endCallbacks = _endCallbacks;
this._beginCallbacks = _beginCallbacks;
this.on("end", function () {
for (var i = 0; i < _endCallbacks.length; i++) {
OffsetManager.addOffsetListener(_endCallbacks[i].offset,
_endCallbacks[i].callback);
}
});
this.on("start", function () {
for (var i = 0; i < _beginCallbacks.length; i++) {
OffsetManager.addOffsetListener(_beginCallbacks[i].offset,
_beginCallbacks[i].callback);
}
});
// Override the run/stop methods. Since it is initialized in the animate
// class' constructor, we need to do an override in the derived class'
// constructor as well.
this._superRun = sw.animation.Animate.superclass.run;
this._superStop = sw.animation.Animate.superclass.stop;
},
/**
* Override the base class' _runAttrs to fix a bug in reverse mode.
*/
_runAttrs: function(t, d, reverse) {
var attr = this._runtimeAttr,
customAttr = Y.Anim.behaviors,
easing = attr.easing,
lastFrame = d,
attribute,
setter,
i;
if (reverse) {
t = d - t;
lastFrame = 0;
}
for (i in attr) {
if (attr[i].to) {
attribute = attr[i];
setter = (i in customAttr && 'set' in customAttr[i]) ?
customAttr[i].set : Y.Anim.DEFAULT_SETTER;
if (t < d && t > 0) {
setter(this, i, attribute.from, attribute.to, t, d, easing, attribute.unit);
} else {
setter(this, i, attribute.from, attribute.to, lastFrame, d, easing, attribute.unit);
}
}
}
},
/**
* Applies the initial animation value.
*/
applyStartFrame: function() {
this._checkRuntimeAttr();
var d = this._runtimeAttr.duration,
t = 0,
attr = this._runtimeAttr,
customAttr = Y.Anim.behaviors,
easing = attr.easing,
attribute,
setter,
i,
reverse = this.get("reverse");
if (reverse) {
t = d;
}
for (i in attr) {
if (attr[i].to) {
attribute = attr[i];
setter = (i in customAttr && 'set' in customAttr[i]) ?
customAttr[i].set : Y.Anim.DEFAULT_SETTER;
setter(this, i, attribute.from, attribute.to, t, d, easing, attribute.unit);
}
}
},
/**
* Implementation helper: checks that the runtime attributes have been
* initialized. If not, initialize them now.
*/
_checkRuntimeAttr : function () {
if (this._runtimeAttr === undefined) {
this._initAnimAttr();
}
},
/**
* Returns a handler that will run this animation instance when invoked.
*/
getRunHandler : function () {
var that = this;
if (this._runHandler === undefined) {
this._runHandler = function () {
that.run();
};
}
return this._runHandler;
},
/**
* Returns the handler that will stop this animation instance when invoked
*/
getStopHandler : function () {
var that = this;
if (this._stopHandler === undefined) {
this._stopHandler = function () {
that.stop();
};
}
return this._stopHandler;
},
/**
* Adds a function of animation to call or play when this animation ends
*
* @param p_animOrCallback an animation or function to trigger when this
* animation ends
* @param p_oOffset {Number} optional time offset to add before calling the
* end callback.
*/
onEnd : function (p_animOrCallback, p_oOffset) {
this._endCallbacks.push({
callback: p_animOrCallback,
offset: p_oOffset
});
},
/**
* Adds a function of animation to call or play when this animation begins
*
* @param p_animOrCallback an animation or function to trigger when this
* animation begins
* @param p_oOffset {Number} optional time offset to add before calling the
* begin callback.
*/
onBegin : function (p_animOrCallback, p_oOffset) {
this._beginCallbacks.push({
callback: p_animOrCallback,
offset: p_oOffset
});
},
/**
* Starts the animation with the requseted offset. The offset is optional,
* and defaults to zero if unspecified.
*
* @param p_oOffset {Number} optional time offset, in seconds, before
* starting the animation.
*/
run : function (p_offset) {
if (p_offset === undefined || p_offset === 0) {
this._superRun.call(this);
this.applyStartFrame(); // Applies the initial animation frame.
} else {
OffsetManager.addOffsetListener(p_offset, this);
}
},
/**
* Stops the animation with the requested offset. The offset is optional and
* defaults to zero if unspecified.
*
* @param p_oOffset {Number} optional time offset, in seconds, before ending
* the animation.
*/
stop : function (p_offset) {
if (p_offset === undefined || p_offset === 0) {
this._superStop.call(this);
} else {
OffsetManager.addOffsetListener(p_offset, this.getStopHandler());
}
},
/**
* Adds a start condition for this animation.
*
* @param p_evtTarget the event target (DOM object) or animation.
* @param p_evtType the event type. If the target is an animation instance,
* should be "begin" or "end".
* @param p_oOffset an offset after which the animation should begin. In
* seconds.
*/
beginOn : function (p_evtTarget, p_evtType, p_oOffset) {
var that = this;
if (p_evtTarget.run !== undefined) {
if (p_evtType === "begin") {
p_evtTarget.onBegin(this, p_oOffset);
} else if (p_evtType === "end") {
p_evtTarget.onEnd(this, p_oOffset);
}
} else {
p_evtTarget.on(p_evtType, function () {
that.run(p_oOffset);
});
}
},
/**
* Adds an end condition for this animation.
*
* @param p_evtTarget the event target
* @param p_evtType the event type. If the target is an animation instance,
* should be "begin" or "end".
* @param p_oOffset an offset after which the animation should begin In
* seconds.
*/
endOn : function (p_evtTarget, p_evtType, p_oOffset) {
var that = this;
if (p_evtTarget.run !== undefined) {
if (p_evtType === "begin") {
p_evtTarget.onBegin(function () {
that.stop(false);
}, p_oOffset);
} else if (p_evtType === "end") {
p_evtTarget.onEnd(function() {
that.stop(false);
}, p_oOffset);
}
} else {
p_evtTarget.on(p_evtType, function () {
OffsetManager.addOffsetListener(p_oOffset, function () {
that.stop(false);
});
});
}
}
});
});
})();
/res/3.0/scripts/yui/svg/anim-svg-debug.js
/** =======================================================================
* Vincent Hardy
* License terms: see svg-wow.org
* CC0 http://creativecommons.org/publicdomain/zero/1.0/
* ======================================================================= */
YUI.add("anim-svg", function (Y) {
/**
* Object with the names of the transform pseudo attributes.
*/
var PSEUDO_ATTRIBUTES_REGEXP = {
tx: /#tx/g,
ty: /#ty/g,
sx: /#sx/g,
sy: /#sy/g,
r: /#r/g
};
var PSEUDO_ATTRIBUTES_ARRAY = ["tx", "ty", "sx", "sy", "r"];
var N_PSEUDO_ATTRIBUTES = PSEUDO_ATTRIBUTES_ARRAY.length;
var colorBehavior = Y.Anim.behaviors.color;
var svgColors = Y.DOM.SVG_COLORS;
var svgColorBehavior = {
set: function(anim, att, from, to, elapsed, duration, fn) {
if (from in svgColors) {
from = svgColors[from];
}
if (to in svgColors) {
to = svgColors[to];
}
colorBehavior.set(anim, att, from, to, elapsed, duration, fn);
},
get: colorBehavior.get
};
Y.Anim.behaviors.transform = {
set: function (anim, att, from, to, elapsed, duration, fun) {
var txf = anim.get(att + "Template"), val, p,
e = anim._node;
if (txf) {
for (p in to) {
if (to.hasOwnProperty(p)) {
val = fun(elapsed, from[p], to[p] - from[p], duration);
txf = txf.replace(PSEUDO_ATTRIBUTES_REGEXP[p], val);
e[p] = val;
}
}
e.setAttribute(att, txf);
}
},
get: function (anim, att) {
var result = {
tx: 0,
ty: 0,
sx: 1,
sy: 1,
r: 0
};
var e = anim._node;
for (var i = 0; i < N_PSEUDO_ATTRIBUTES; i++) {
var a = PSEUDO_ATTRIBUTES_ARRAY[i];
if (e[a] !== undefined) {
result[a] = e[a];
} else {
e[a] = result[a];
}
}
return result;
}
};
Y.Anim.behaviors.stdDeviation = {
set: function (anim, att, from, to, elapsed, duration, fun) {
var val = [fun(elapsed, from[0], to[0] - from[0], duration),
fun(elapsed, from[1], to[1] - from[1], duration)];
// NOTE: setStdDeviation is more efficient, so use it if available.
// Firefox 3.6 and earlier doesn't have support for setStdDeviation,
// so fallback to setAttribute.
if (anim._node.setStdDeviation) {
anim._node.setStdDeviation(val[0], val[1]);
} else {
anim._node.setAttribute(att, val[0] + " " + val[1]);
}
},
get: function (anim, attr) {
// NOTE: Got errors in {Firefox, Opera, Safari} about stdDeviationX
// not being defined in some cases, fallback to the default value [0,0].
var result = [0, 0];
if (anim._node.stdDeviationX !== null &&
anim._node.stdDeviationY !== undefined) {
result = [anim._node.stdDeviationX.baseVal,
anim._node.stdDeviationY.baseVal];
}
return result;
}
};
var lengthBehavior = {
set: function (anim, att, from, to, elapsed, duration, fun) {
var val = fun(elapsed, Number(from), Number(to) - Number(from), duration);
anim._node.set(att, val);
},
get: function (anim, attr) {
return anim._node.get(attr);
}
};
var pathCommands = {
m: 'm',
M: 'M',
l: 'l',
L: 'L',
h: 'h',
H: 'H',
v: 'v',
V: 'V',
q: 'q',
Q: 'Q',
c: 'c',
C: 'C',
z: 'z',
Z: 'Z',
s: 's',
S: 'S',
t: 't',
T: 'T',
a: 'a',
A: 'A'
};
function parsePath (d) {
var n;
if (typeof d === "string") {
d = d.replace(/([^ ])([hHvVmMlLtTqQsScCaAzZ])/g, '$1 $2')
.replace(/([hHvVmMlLtTqQsScCaAzZ])([^ ])/g, '$1 $2')
.replace(/([^ ,])-/g, '$1,-')
.replace(/[ ]{2,}/g, ' ')
.replace(/[ ]+/g,',').split(',');
n = d.length;
for (var i = 0; i < n; i++) {
if (pathCommands[d[i]] === undefined) {
d[i] = Number(d[i]);
}
}
}
return d;
}
Y.Anim.behaviors.d = {
set: function (anim, att, from, to, elapsed, duration, fun) {
from = parsePath(from);
to = parsePath(to);
// As in the SVG specification, it is a requirement that the path
// segment types match. So we only need to interpolate the coordinates.
var n = to.length,
c,
v = [],
nc,
is,
max;
for (var i = 0; i < n;) {
c = to[i]; // command
v.push(c);
nc = 0;
is = i + 1;
switch (c) {
case 'h':
case 'H':
case 'v':
case 'V':
i++;
do {
i++;
nc++;
} while (typeof to[i] === "number");
break;
case 'm':
case 'M':
case 'l':
case 'L':
case 't':
case 'T':
i++;
do {
i += 2;
nc += 2;
} while (typeof to[i] === "number");
break;
case 'q':
case 'Q':
case 's':
case 'S':
i++;
do {
i += 4;
nc += 4;
} while (typeof to[i] === "number");
break;
case 'c':
case 'C':
i++;
do {
i += 6;
nc += 6;
} while (typeof to[i] === "number");
break;
case 'a':
case 'A':
i++;
do {
i += 7;
nc += 7;
} while (typeof to[i] === "number");
break;
// case 'z':
// case 'Z':
default:
// Includes 'z' and 'Z'
i += 1;
break;
}
max = is + nc;
for (var j = is; j < max; j++) {
v[j] = fun(elapsed, from[j], to[j] - from[j], duration);
if (isNaN(v[j]) === true) {
Y.log('v[' + j + '] is NaN');
}
}
}
anim._node.setAttribute(att, v.join(' '));
},
get: function (anim, attr) {
return parsePath(anim._node.getAttribute(attr));
}
};
Y.Anim.behaviors.fill = svgColorBehavior;
Y.Anim.behaviors.stroke = svgColorBehavior;
Y.Anim.behaviors["stop-color"] = svgColorBehavior;
Y.Anim.behaviors["flood-color"] = svgColorBehavior;
Y.Anim.behaviors["lighting-color"] = svgColorBehavior;
Y.Anim.behaviors.dy = lengthBehavior;
Y.Anim.behaviors.y = lengthBehavior;
Y.Anim.behaviors.dx = lengthBehavior;
Y.Anim.behaviors.x = lengthBehavior;
Y.Anim.behaviors.rotate = lengthBehavior;
Y.Anim.behaviors.width = lengthBehavior;
Y.Anim.behaviors.height = lengthBehavior;
Y.Anim.behaviors.r = lengthBehavior;
Y.Anim.behaviors.rx = lengthBehavior;
Y.Anim.behaviors.ry = lengthBehavior;
Y.Anim.behaviors.cx = lengthBehavior;
Y.Anim.behaviors.cy = lengthBehavior;
Y.Anim.behaviors.x1 = lengthBehavior;
Y.Anim.behaviors.x2 = lengthBehavior;
Y.Anim.behaviors.y1 = lengthBehavior;
Y.Anim.behaviors.y2 = lengthBehavior;
Y.Anim.behaviors.offset = lengthBehavior;
});