Adding a <replicate> tag to SVG (updated Feb. 11, 2011)
If added to the SVG spec, the replicate tag will do for space in SVG what SMIL does for time. It is a declarative drawing extension that allows development of new classes of gradients, patterns and 2.5 dimensional effects with minimized effort for the author.
Before looking at the cool examples below, I suggest looking a bit into our paper or, at least, our talk on the subject.
Also, the script which underlies these examples is now part of a google code project. Please contribute!
Notice how succinct (and intuitive) the code is in these examples.
| Link to demo | Picture (as I think it should appear) | Description | Browsers
(Windows XP) Chrome, Firefox4beta, Internet Explorer 8/ASV3.03, Opera11, Safari |
Sample source |
| demo1 | ![]() |
cylinder, teardrop, tri-colored teardrop |
All five agree, except on stroke-width of tri-colored teardrop: IE misses on smoothness of stroke-width transition. | <ellipse
cy="-100" cx="200" rx="30" ry="50" fill="url(#f)" stroke-width=".5" stroke="none" > <replicate repeatCount="80" > <replicateAttribute attributeName="cy" from="300" to="100" /> <replicateAttribute attributeName="ry" from="100" to="0" /> <replicateAttribute attributeName="rx" from="100" to="0" /> </replicate> </ellipse> |
| demo7 demo8 |
![]() ![]() |
cupcake | All five seem to agree. | <ellipse
cy="-50" fill="url(#f)" stroke="none"> <replicate repeatCount="190" > <replicateAttribute attributeName="cy" from="300" to="100" /> <replicateAttribute attributeName="cx" values="450; 250; 350" /> <replicateAttribute attributeName="ry" values="100;20;20;150;0" /> <replicateAttribute attributeName="rx" values="150;200;0" /> <replicateAttribute attributeName="opacity" values="1;1;0" /> </replicate> </ellipse> |
| demoF | ![]() ![]() |
Using rotation with <replicate> | Same in all five | <ellipse
cy="-1000" cx="400" rx="30" ry="50" fill="url(#f)"> stroke-width=".5" stroke="none" > <replicate repeatCount="140" > <replicateAttribute attributeName="cy" from="300" to="100" /> <replicateAttribute attributeName="transform" from="rotate(0 400 200)" to="rotate(1240 400 200)" /> <replicateAttribute attributeName="ry" from="100" to="15" /> <replicateAttribute attributeName="rx" from="100" to="10" /> <replicateAttribute attributeName="opacity" from="1" to=".5" /> </replicate> </ellipse> |
| twist twist2 plastic |
![]() ![]() |
3D text effects | FF doesn't yet handle textLength and lengthAdjust for some of these |
<text id="T" fill="url(#g)" font-family="serif" stroke="black" |
| demo2 | ![]() |
extruded text | Specifying the font-family is needed to ensure similarity across browsers. | <text
font-size="12" id="WWW" x="-50" y="300" fill="red"> <replicate id="F" repeatCount="80"> <replicateAttribute attributeName="y" from="150" to="290"/> <replicateAttribute attributeName="x" from="90" to="200"/> <replicateAttribute attributeName="font-size" from="9" to="170"/> <replicateAttribute attributeName="fill" from="rgb(0,0,0)" to="rgb(0,123,255)" /> </replicate> TEXT</text> |
| demoA demo3 demo6 gradrep |
![]() ![]() ![]() ![]() |
nonlinear nonradial gradients |
All five appear to agree. | <ellipse
rx="100" ry="150" fill="rgb(255,200,0)" cx="-160" cy="200"> <replicate repeatCount="75" > <replicateAttribute attributeName="cx" from="400" to="350" /> <replicateAttribute attributeName="cy" from="200" to="300" /> <replicateAttribute attributeName="ry" from="150" to="65" /> <replicateAttribute attributeName="rx" from="100" to="150" /> <replicateAttribute attributeName="opacity" from="1" to=".75" /> <replicateAttribute attributeName="stroke-opacity" from=".5" to="0" /> <replicateAttribute attributeName="stroke-width" from="4" to="0" /> <replicateAttribute attributeName="stroke" from="rgb(100,255,120)" to="rgb(0,124,124)" /> <replicateAttribute attributeName="fill" from="rgb(0,128,255)" to="rgb(225,255,220)" /> </replicate> </ellipse> |
| demo9 | ![]() |
spinning top (uses SMIL) | Fine except for no animation in Safari. | <ellipse
cx="300" cy="50" fill="url(#g)" stroke-width=".5" stroke="none" > <replicate repeatCount="70" > <replicateAttribute attributeName="cy" from="300" to="100" /> <replicateAttribute attributeName="ry" values="120;10" /> <replicateAttribute attributeName="rx" values="50;200;60;70;50" /> </replicate> </ellipse> |
| demoB | ![]() |
corkscrew (a la Escher, with SMIL) | Safari handles neither the gradient nor the animation. |
<rect x="-200" width="40" height="40" |
| pathRep | ![]() |
Drawing in 5D | Using the ability of multiple attributes to follow curves. (Extending animatePath into the multivariate arena) | |
| demoC | ![]() |
sprinkles | Safari and Chrome don't see the animation on the seaweed. |
<circle cx="-200" r="40" fill="url(#g)"> |
| demoE | ![]() |
spinning DNA | Six months ago all browsers had problems. Now just Safari (doesn't handle rotation of gradient) and IE/ASV -- gradient is grainy. | a <replicate> similar to Demo B is placed
into a pattern space. |
| demoH | ![]() ![]() |
Using rotation with <replicate> | Good in all five. | <ellipse
cy="-1000" cx="400" rx="30" ry="50"> stroke-width=".5" stroke="none" > <replicate repeatCount="380" > <replicateAttribute attributeName="cy" from="300" to="100" /> <replicateAttribute attributeName="transform" from="rotate(0 400 200)" to="rotate(5080 400 200)" /> <replicateAttribute attributeName="ry" from="100" to="15" /> <replicateAttribute attributeName="rx" values="500; 450;0" /> <replicateAttribute attributeName="fill" from="rgb(45,45,128)" to="rgb(255,233,128)" /> </replicate> </ellipse> |
| demoJ | ![]() |
Using rotation with <replicate> | Good in all five. |
Several more:
FF4 needed for animation. Safari and Chrome not handling animation.
Interpolating between and across multiple colorvalues
- RainbowDonut (all five ok)
- rotating raindrop (C/S no animation)
- Colors1.svg (all five ok)
- Wild Shapes (all five ok)
- KleinishBottle (all five ok)
- HoppingRainbow (C/S no animation)
- NonlinearRainbow (C/S no animation)
- InvertingRainbow (C/S no animation)
- RainbowCD (all)
- Color Spiral (all)
- PulsatingDonut (C/S no animation)
- PulsatingDonut (C/S no animation)
- 3D-rotation (C/S no animation)
Using <replicateModifier> to clone and adjust gradients, animations, patterns, filters as we replicate.
(Chrome, Safari and Opera have trouble with A,B, C, and D )
Nested Replicates
Link to demo Picture (as I think it should appear) Description Sample source nestedReplicates6.svg replicated tiling: no animation in Chrome/Safari. <rect x="-200">
<replicate repeatCount="70">
<replicateAttribute attributeName="height"
values="100;0" />
<replicateAttribute attributeName="y"
values="100;150"/>
<replicateAttribute attributeName="width"
values="100;0" />
<replicateAttribute attributeName="x"
values="100;150"/>
<replicateAttribute attributeName="fill"
from="rgb(0,128,255)" to="rgb(225,255,220)"/>
</replicate>
</rect>nestedReplicates1.svg seven-pointed star
(seems to take forever in FF4)<ellipse cy="-100" cx="200" rx="30" ry="50"
fill="url(#f)" stroke-width=".5" stroke="none" >
<replicate repeatCount="80" >
<replicateAttribute attributeName="cy"
from="300" to="100" />
<replicateAttribute attributeName="ry"
from="100" to="0" />
<replicateAttribute attributeName="rx"
from="100" to="0" />
</replicate>
</ellipse>cobblestones non-affine
cobblestones <g >
<replicate repeatCount="13" >
<replicateAttribute attributeName="transform"
values="scale(1);scale(.75);scale(.55);scale(.40);scale(.30);scale(.25);scale(.2)" />
</replicate>
<path d="M 20 20 100 20 120 50 0 50 z"
stroke="none" transform="scale(2,1.2)" fill="url(#f)" >
<replicate repeatCount="9" >
<replicateAttribute attributeName="d"
values="M 0 400 80 400 100 360 20 360 z; M 800 400 880 400 860 360 780 360 z" />
<replicateModifier modifierType="gradientStop" childNum="2"
attributeName="stop-color"
values=" rgb(244,45,45); rgb(200,233,4); rgb(0,0,255)"/>
</replicate>
</path>
</g>
Nothing shows up in FF4. texture2
texture3Similar but animated. Chrome/Safari don't show animation texture1
texture5Okay everywhere spectralTerrain spectral terrain -- may crash FF4. Nothing in Safari. NorthernLights Northern Lights -- if you whistle at them they dance. Fine in FF,O, ASV
No animation in Chrome. Nothing shows up in Safari.
Cardioid2 (inspired by Eric Elder)
Replicating within a replicate. monkey bars
(slow to load)Triply replicated activebox animated box with Question
(by Eric Elder)tubefy demonstration
(by Israel Eisenberg)also see more by Israel:
a nice color wheel
tubefy with keySplines
http://owl3d.com/svg/tubefy/articles/article1.html
http://owl3d.com/svg/tubefy/articles/article2.html
http://owl3d.com/svg/tubefy/articles/article3.html