1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
|
<svg version="1.1" baseProfile="full" onload="CreatePath();setTimeout('AnimatePath();', 500);" id="svg-root"
width="100%" height="100%" viewBox="0 0 480 360"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!--======================================================================-->
<!--= SVG 1.1 2nd Edition Test Case =-->
<!--======================================================================-->
<!--= Copyright 2009 World Wide Web Consortium, (Massachusetts =-->
<!--= Institute of Technology, European Research Consortium for =-->
<!--= Informatics and Mathematics (ERCIM), Keio University). =-->
<!--= All Rights Reserved. =-->
<!--= See http://www.w3.org/Consortium/Legal/. =-->
<!--======================================================================-->
<d:SVGTestCase xmlns:d="http://www.w3.org/2000/02/svg/testsuite/description/"
template-version="1.4" reviewer="[reviewer]" author="ED" status="created"
version="$Revision: 1.5 $" testname="$RCSfile: paths-dom-02-f.svg,v $">
<d:testDescription xmlns="http://www.w3.org/1999/xhtml" href="http://www.w3.org/TR/SVG11/paths.html#DOMInterfaces">
<p>
This test is designed to test the PathSegList interface. At first a flower-like shape with 6 petals should be displayed.
The roundness and number of petals are then animated using script.
</p>
</d:testDescription>
<d:operatorScript xmlns="http://www.w3.org/1999/xhtml">
<p>
The roundness of the petals is animated from star-like sharp petals to softly rounded petals and back again, and is repeated like that until the animation stops.
The number of petals should increase one by one until the flower has a total of 12 petals, and then go back one by one until it has 6 petals, then increase again one by one until the flower has 9 petals.
Then the animation will stop. The rendered image should look exactly like the reference image.
</p>
<p>
If the flower is clicked after the animation has finished, it will restart the animation and repeat it for some time.
</p>
</d:operatorScript>
<d:passCriteria xmlns="http://www.w3.org/1999/xhtml">
<p>
[[Describe the pass criteria of the test here. The pass criteria is what
should be displayed when the test is run.]]
</p>
</d:passCriteria>
</d:SVGTestCase>
<title id="test-title">$RCSfile: paths-dom-02-f.svg,v $</title>
<defs>
<font-face font-family="SVGFreeSansASCII" unicode-range="U+0-7F">
<font-face-src>
<font-face-uri xlink:href="../resources/SVGFreeSans.svg#ascii"/>
</font-face-src>
</font-face>
</defs>
<g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
<script><![CDATA[
var offset_angle = 90;
var current_shift = 0;
var shift_inc = 1;
var THRESHOLD = 60;
var segments_added = 0;
var seg_diff = 1;
var adjust_count = 0;
var anim_count = 0;
var adjust_count_max = 8;
var anim_count_max = 10;
var stopped = false;
function DegToRad(degs)
{
return (degs * Math.PI) / 180;
}
function CreatePath()
{
var pathelm = document.getElementById("mypath");
var pathlist = pathelm.pathSegList;
var move = pathelm.createSVGPathSegMovetoAbs(240 + 30 * Math.cos(DegToRad(offset_angle - 30)),
180 + 30 * Math.sin(DegToRad(offset_angle - 30)));
pathlist.appendItem(move);
var angle = offset_angle;
for (var i = 0; i < 6; i++)
{
var x, y, xcp, ycp;
x = 240 + 30 * Math.cos(DegToRad(angle + 30));
y = 180 + 30 * Math.sin(DegToRad(angle + 30));
xcp = 240 + 120 * Math.cos(DegToRad(angle));
ycp = 180 + 120 * Math.sin(DegToRad(angle));
var curve = pathelm.createSVGPathSegCurvetoCubicAbs(x, y,
xcp, ycp,
xcp, ycp);
pathlist.appendItem(curve);
angle += 60;
}
pathlist.appendItem(pathelm.createSVGPathSegClosePath());
setTimeout('AdjustPath()', 500);
}
function AddSegment()
{
var pathelm = document.getElementById("mypath");
var pathlist = pathelm.pathSegList;
var segments = pathlist.numberOfItems - 2; // Not MoveTo and Close
var angle = offset_angle;
var inc_angle = 360/(segments+1);
var shift_v_x, shift_v_y, xcp, ycp;
var move = pathlist.getItem(0);
move.x = 240 + 30 * Math.cos(DegToRad(offset_angle - inc_angle/2));
move.y = 180 + 30 * Math.sin(DegToRad(offset_angle - inc_angle/2));
for (var i = 0; i < segments; i++)
{
var curve = pathlist.getItem(1+i);
shift_v_x = current_shift * Math.cos(DegToRad(angle + 90));
shift_v_y = current_shift * Math.sin(DegToRad(angle + 90));
xcp = 240 + 120 * Math.cos(DegToRad(angle));
ycp = 180 + 120 * Math.sin(DegToRad(angle));
curve.x = 240 + 30 * Math.cos(DegToRad(angle + inc_angle/2));
curve.y = 180 + 30 * Math.sin(DegToRad(angle + inc_angle/2));
curve.x1 = xcp - shift_v_x;
curve.y1 = ycp - shift_v_y;
curve.x2 = xcp + shift_v_x;
curve.y2 = ycp + shift_v_y;
angle += inc_angle;
}
shift_v_x = current_shift * Math.cos(DegToRad(angle + 90));
shift_v_y = current_shift * Math.sin(DegToRad(angle + 90));
xcp = 240 + 120 * Math.cos(DegToRad(angle));
ycp = 180 + 120 * Math.sin(DegToRad(angle));
var x = 240 + 30 * Math.cos(DegToRad(angle + inc_angle/2));
var y = 180 + 30 * Math.sin(DegToRad(angle + inc_angle/2));
var curve = pathelm.createSVGPathSegCurvetoCubicAbs(x, y,
xcp - shift_v_x,
ycp - shift_v_y,
xcp + shift_v_x,
ycp + shift_v_y);
pathlist.insertItemBefore(curve, pathlist.numberOfItems-1);
}
function RemoveSegment()
{
var pathelm = document.getElementById("mypath");
var pathlist = pathelm.pathSegList;
var segments = pathlist.numberOfItems - 2; // Not MoveTo and Close
var angle = offset_angle;
var inc_angle = 360/(segments-1);
var shift_v_x, shift_v_y, xcp, ycp;
var move = pathlist.getItem(0);
move.x = 240 + 30 * Math.cos(DegToRad(offset_angle - inc_angle/2));
move.y = 180 + 30 * Math.sin(DegToRad(offset_angle - inc_angle/2));
for (var i = 0; i < segments-1; i++)
{
var curve = pathlist.getItem(1+i);
shift_v_x = current_shift * Math.cos(DegToRad(angle + 90));
shift_v_y = current_shift * Math.sin(DegToRad(angle + 90));
xcp = 240 + 120 * Math.cos(DegToRad(angle));
ycp = 180 + 120 * Math.sin(DegToRad(angle));
curve.x = 240 + 30 * Math.cos(DegToRad(angle + inc_angle/2));
curve.y = 180 + 30 * Math.sin(DegToRad(angle + inc_angle/2));
curve.x1 = xcp - shift_v_x;
curve.y1 = ycp - shift_v_y;
curve.x2 = xcp + shift_v_x;
curve.y2 = ycp + shift_v_y;
angle += inc_angle;
}
pathlist.removeItem(pathlist.numberOfItems-2);
}
function AdjustPath()
{
if (seg_diff > 0)
{
AddSegment();
}
else
{
RemoveSegment();
}
segments_added += seg_diff;
if (segments_added > 5)
seg_diff = -1;
else if (segments_added <= 0)
seg_diff = 1;
if(adjust_count < adjust_count_max)
{
adjust_count++;
setTimeout('AdjustPath()', 500);
}
}
function AnimatePath()
{
var pathelm = document.getElementById("mypath");
var pathlist = pathelm.pathSegList;
var segments = pathlist.numberOfItems - 2; // Not MoveTo and Close
var angle = offset_angle;
var inc_angle = 360/segments;
for (var i = 0; i < segments; i++)
{
var curve = pathlist.getItem(1+i);
var shift_v_x, shift_v_y, xcp, ycp;
shift_v_x = current_shift * Math.cos(DegToRad(angle + 90));
shift_v_y = current_shift * Math.sin(DegToRad(angle + 90));
xcp = 240 + 120 * Math.cos(DegToRad(angle));
ycp = 180 + 120 * Math.sin(DegToRad(angle));
curve.x1 = xcp - shift_v_x;
curve.y1 = ycp - shift_v_y;
curve.x2 = xcp + shift_v_x;
curve.y2 = ycp + shift_v_y;
angle += inc_angle;
}
current_shift += shift_inc;
if (current_shift >= THRESHOLD || current_shift < 0)
shift_inc = -shift_inc;
if(adjust_count >= adjust_count_max)
{
anim_count++;
}
if(anim_count < anim_count_max)
setTimeout('AnimatePath();', 50);
else
document.getElementById("mypath").addEventListener("click", function func() { adjust_count_max=32768;anim_count_max=32768; AdjustPath(); AnimatePath(); }, false);
}
]]></script>
<path d="" id="mypath" stroke="black" fill="blue"/>
</g>
<g font-family="SVGFreeSansASCII,sans-serif" font-size="32">
<text id="revision" x="10" y="340" stroke="none" fill="black">$Revision: 1.5 $</text>
</g>
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000"/>
<!-- comment out this watermark once the test is approved -->
<g id="draft-watermark">
<rect x="1" y="1" width="478" height="20" fill="red" stroke="black" stroke-width="1"/>
<text font-family="SVGFreeSansASCII,sans-serif" font-weight="bold" font-size="20" x="240"
text-anchor="middle" y="18" stroke-width="0.5" stroke="black" fill="white">DRAFT</text>
</g>
</svg>
|