Example 0: (Working in IE, Opera, and (except for the SMIL) FF
HTML SVG
Example 1: (IE Only) In the following, a series of radio buttons allows the user to
investigate values of two parameters of the feTurbulence property which allows
images to be distorted in interesting ways. As the user chooses new values of
“NumOctaves” and “BaseFrequency” the underlying image (in this case a
simple polygon “path” filled with a radial gradient) is automatically
adjusted through appropriate redefinitions of these attribute values. Results of
one such pair of values is illustrated following the code.
HTML page Embedded SVG document <html><head><script>
var svgdoc, TurbProp
function prepare(){
svgdoc = document.sv.getSVGDocument();
TurbProp=svgdoc.getElementById('Turb');
}
function baseF(v){
TurbProp.setAttribute ("baseFrequency", v);
}
function octaves(v){
TurbProp.setAttribute ("numOctaves", v);
}
</script></head><body onload="prepare()">
<embed name="sv" src="sixa.svg" width=500 height=350></embed>
<form name="f">
Base Frequency: .05
<input type="radio" name="b" checked onclick="baseF(.05)">
.10<input type="radio" name="b" onclick="baseF(.10)">
.20<input type="radio" name="b" onclick="baseF(.20)">
| | | | Octaves:
1<input type="radio" name="o" onclick="octaves(1)">
2<input type="radio" name="o"
checked onclick="octaves(2)">
3<input type="radio" name="o" onclick="octaves(3)">
</form></body></html><svg xml:space="preserve"
width="7in" height="5in" viewBox="0 0 450 200">
<defs>
<filter id="Distort">
<feTurbulence id="Turb"
baseFrequency=".05" numOctaves="2" result="turb"/>
<feDisplacementMap in="SourceGraphic"
in2="turb" scale="100" xChannelSelector="R"
yChannelSelector="B"/>
</filter>
<radialGradient id="gradient1"
cx="250" cy="80" r="150" fx="150" fy="80" gradientUnits="userSpaceOnUse">
<stop offset="0" style="stop-color:#FF0088"/>
<stop offset="0.4" style="stop-color:#FFdd88"/>
<stop offset="0.8" style="stop-color:#ddff44"/>
<stop offset="1" style="stop-color:#88aa00"/>
</radialGradient>
</defs>
<g id="image" style="filter:url(#Distort)">
<path id="P"
d="M 50 200 L 350 200 L 280 10 L 250 60 L 180 10z" style="fill:url(#gradient1)"/>
</g>
</svg>
Example2: IE Only
HTML page Embedded SVG document
In this example, each keystroke the user makes in the input field results in a
new “stencil” being cut through which the underlying image may be
viewed.
This is accomplished by first finding the object named “T” inside the SVG,
then locating its first child and then replacing the nodeValue of that with the
user-defined string.