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