Debian Codegraph @

samples/tests/spec/scripting/intersectionList.svg

raw
1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000802//EN"
3 "http://www.w3.org/TR/2000/CR-SVG-20000802/DTD/svg-20000802.dtd">
4
5 <!--
6
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
21
22 -->
23
24 <!-- ====================================================================== -->
25 <!-- Testing the getIntersectionList interface on the svg:svg element. -->
26 <!-- -->
27 <!-- @author [email protected] -->
28 <!-- @version $Id$ -->
29 <!-- ====================================================================== -->
30
31 <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
32
33 <svg id="body" width="450" height="500" viewBox="0 0 450 500"
34 onload="testIntersection()"
35 xmlns="http://www.w3.org/2000/svg"
36 xmlns:xlink="http://www.w3.org/1999/xlink" >
37
38 <title>Test of getIntersectionList interface</title>
39 <text x="50%" y="45" class="title">Test of getIntersectionList interface</text>
40
41 <script type="text/ecmascript"><![CDATA[
42 var svgns = "http://www.w3.org/2000/svg";
43
44 function doCheck(svg, rect, end, attr, val) {
45 var lst = svg.getIntersectionList(rect, end);
46 var i=0, sz = lst.getLength();
47 while (i < sz) {
48 var e = lst.item(i);
49 e.setAttribute(attr, val);
50 i++;
51 }
52 }
53
54 function setRect(rect, x, y, w, h) {
55 rect.x = x;
56 rect.y = y;
57 rect.width = w;
58 rect.height = h;
59 }
60
61 function makeRect(parent, rect, stroke) {
62 var outline = document.createElementNS(svgns, "rect");
63 outline.setAttribute("x", "" + rect.x);
64 outline.setAttribute("y", "" + rect.y);
65 outline.setAttribute("width", "" + rect.width);
66 outline.setAttribute("height", "" + rect.height);
67 outline.setAttribute("fill", "none");
68 outline.setAttribute("stroke", stroke);
69 parent.appendChild(outline);
70 }
71
72 function checkIntersection(svg, rect, elem, attr, val1, val2) {
73 if (svg.checkIntersection(elem, rect))
74 elem.setAttribute(attr, val1);
75 else
76 elem.setAttribute(attr, val2);
77 }
78
79
80 function testIntersection() {
81 var root = document.getRootElement();
82 var rect = root.createSVGRect();
83 setRect(rect, 50, 95, 50, 50);
84
85 doCheck(root, rect, null, "fill", "blue");
86 makeRect(root, rect, "blue");
87
88 setRect(rect, 45, 90, 60, 60);
89 var middle = root.getElementById("tb1-middle");
90 doCheck(root, rect, middle, "stroke", "red");
91 makeRect(root, rect, "red");
92
93 var tb2 = root.getElementById("testblock2");
94 setRect(rect, 45, 60, 450, 20);
95 doCheck(tb2, rect, null, "fill", "green");
96 makeRect(tb2, rect, "green");
97
98 setRect(rect, 187.5, 139, 224, 10);
99 doCheck(root, rect, null, "stroke", "pink");
100 makeRect(root, rect, "pink");
101
102 setRect(rect, 82.35, 267.15, 35.25, 35.25);
103 doCheck(root, rect, null, "stroke", "lightgreen");
104
105 setRect(rect, 90.65, 275.25, 19, 19);
106 doCheck(root, rect, null, "fill", "purple");
107 makeRect(root, rect, "purple");
108 setRect(rect, 82.35, 267.15, 35.25, 35.25);
109 makeRect(root, rect, "lightgreen");
110
111 var tb5 = root.getElementById("testblock5");
112 var tb5_m = root.getElementById("tb5-middle");
113 setRect(rect, 45, 160, 150, 20);
114 doCheck(tb5, rect, tb5_m, "fill", "crimson");
115 makeRect(tb5, rect, "crimson");
116
117 var ts = root.getElementById("ts");
118 setRect(rect, 235, 200, 2, 50);
119 doCheck(root, rect, ts, "fill", "orange");
120 doCheck(root, rect, null, "text-decoration", "underline");
121 makeRect(root, rect, "orange");
122 setRect(rect, 255, 200, 2, 50);
123 doCheck(root, rect, ts, "stroke", "crimson");
124 makeRect(root, rect, "crimson");
125
126
127
128 var tb6 = root.getElementById("testblock6");
129 var tb6_m = root.getElementById("tb6-middle");
130
131 var tb6_11 = root.getElementById("tb6-11");
132 var tb6_21 = root.getElementById("tb6-21");
133 var tb6_31 = root.getElementById("tb6-31");
134 var tb6_41 = root.getElementById("tb6-41");
135
136 var tb6_12 = root.getElementById("tb6-12");
137 var tb6_22 = root.getElementById("tb6-22");
138 var tb6_32 = root.getElementById("tb6-32");
139 var tb6_42 = root.getElementById("tb6-42");
140
141 var tb6_13 = root.getElementById("tb6-13");
142 var tb6_23 = root.getElementById("tb6-23");
143 var tb6_43 = root.getElementById("tb6-43");
144
145 var tb6_14 = root.getElementById("tb6-14");
146 var tb6_24 = root.getElementById("tb6-24");
147 var tb6_34 = root.getElementById("tb6-34");
148 var tb6_44 = root.getElementById("tb6-44");
149
150 setRect(rect, 190, 300, 70, 70);
151 checkIntersection(root, rect, tb6_11, "fill", "blue", "crimson");
152 checkIntersection(root, rect, tb6_21, "fill", "blue", "crimson");
153 checkIntersection(root, rect, tb6_31, "fill", "blue", "crimson");
154 checkIntersection(root, rect, tb6_41, "fill", "blue", "crimson");
155
156 checkIntersection(root, rect, tb6_12, "fill", "blue", "crimson");
157 checkIntersection(root, rect, tb6_22, "fill", "blue", "crimson");
158 checkIntersection(root, rect, tb6_32, "fill", "blue", "crimson");
159 checkIntersection(root, rect, tb6_42, "fill", "blue", "crimson");
160
161 checkIntersection(root, rect, tb6_13, "fill", "blue", "crimson");
162 checkIntersection(root, rect, tb6_23, "fill", "blue", "crimson");
163 checkIntersection(root, rect, tb6_m, "fill", "blue", "crimson");
164 checkIntersection(root, rect, tb6_43, "fill", "blue", "crimson");
165
166 checkIntersection(root, rect, tb6_14, "fill", "blue", "crimson");
167 checkIntersection(root, rect, tb6_24, "fill", "blue", "crimson");
168 checkIntersection(root, rect, tb6_34, "fill", "blue", "crimson");
169 checkIntersection(root, rect, tb6_44, "fill", "blue", "crimson");
170
171 makeRect(root, rect, "blue");
172
173 }
174 ]]></script>
175
176 <g id="test-content" >
177 <svg id="testblock1" overflow="visible"
178 x="15" y="60" width="120" height="120" viewBox="-.5 -.5 241 241"
179 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
180 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
181
182 <rect x="0" y="0" width="40" height="40"/>
183 <rect x="50" y="0" width="40" height="40"/>
184 <rect x="100" y="0" width="40" height="40"/>
185 <rect x="150" y="0" width="40" height="40"/>
186 <rect x="200" y="0" width="40" height="40"/>
187
188 <rect x="0" y="50" width="40" height="40"/>
189 <rect x="50" y="50" width="40" height="40"/>
190 <rect x="100" y="50" width="40" height="40"/>
191 <rect x="150" y="50" width="40" height="40"/>
192 <rect x="200" y="50" width="40" height="40"/>
193
194 <rect x="0" y="100" width="40" height="40"/>
195 <rect x="50" y="100" width="40" height="40"/>
196 <rect id="tb1-middle" x="100" y="100" width="40" height="40"/>
197 <rect x="150" y="100" width="40" height="40"/>
198 <rect x="200" y="100" width="40" height="40"/>
199
200 <rect x="0" y="150" width="40" height="40"/>
201 <rect x="50" y="150" width="40" height="40"/>
202 <rect x="100" y="150" width="40" height="40"/>
203 <rect x="150" y="150" width="40" height="40"/>
204 <rect x="200" y="150" width="40" height="40"/>
205
206 <rect x="0" y="200" width="40" height="40"/>
207 <rect x="50" y="200" width="40" height="40"/>
208 <rect x="100" y="200" width="40" height="40"/>
209 <rect x="150" y="200" width="40" height="40"/>
210 <rect x="200" y="200" width="40" height="40"/>
211 </svg>
212
213 <svg id="testblock2" overflow="visible"
214 x="165" y="60" width="120" height="120" viewBox="-.5 -.5 241 241"
215 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
216 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
217
218 <rect x="0" y="0" width="40" height="40"/>
219 <rect x="50" y="0" width="40" height="40"/>
220 <rect x="100" y="0" width="40" height="40"/>
221 <rect x="150" y="0" width="40" height="40"/>
222 <rect x="200" y="0" width="40" height="40"/>
223
224 <rect x="0" y="50" width="40" height="40"/>
225 <rect x="50" y="50" width="40" height="40"/>
226 <rect x="100" y="50" width="40" height="40"/>
227 <rect x="150" y="50" width="40" height="40"/>
228 <rect x="200" y="50" width="40" height="40"/>
229
230 <rect x="0" y="100" width="40" height="40"/>
231 <rect x="50" y="100" width="40" height="40"/>
232 <rect id="tb2-middle" x="100" y="100" width="40" height="40"/>
233 <rect x="150" y="100" width="40" height="40"/>
234 <rect x="200" y="100" width="40" height="40"/>
235
236 <rect x="0" y="150" width="40" height="40"/>
237 <rect x="50" y="150" width="40" height="40"/>
238 <rect x="100" y="150" width="40" height="40"/>
239 <rect x="150" y="150" width="40" height="40"/>
240 <rect x="200" y="150" width="40" height="40"/>
241
242 <rect x="0" y="200" width="40" height="40"/>
243 <rect x="50" y="200" width="40" height="40"/>
244 <rect x="100" y="200" width="40" height="40"/>
245 <rect x="150" y="200" width="40" height="40"/>
246 <rect x="200" y="200" width="40" height="40"/>
247 </svg>
248
249 <svg id="testblock3" overflow="visible"
250 x="315" y="60" width="120" height="120" viewBox="-.5 -.5 241 241"
251 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
252 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
253
254 <rect x="0" y="0" width="40" height="40"/>
255 <rect x="50" y="0" width="40" height="40"/>
256 <rect x="100" y="0" width="40" height="40"/>
257 <rect x="150" y="0" width="40" height="40"/>
258 <rect x="200" y="0" width="40" height="40"/>
259
260 <rect x="0" y="50" width="40" height="40"/>
261 <rect x="50" y="50" width="40" height="40"/>
262 <rect x="100" y="50" width="40" height="40"/>
263 <rect x="150" y="50" width="40" height="40"/>
264 <rect x="200" y="50" width="40" height="40"/>
265
266 <rect x="0" y="100" width="40" height="40"/>
267 <rect x="50" y="100" width="40" height="40"/>
268 <rect id="tb3-middle" x="100" y="100" width="40" height="40"/>
269 <rect x="150" y="100" width="40" height="40"/>
270 <rect x="200" y="100" width="40" height="40"/>
271
272 <rect x="0" y="150" width="40" height="40"/>
273 <rect x="50" y="150" width="40" height="40"/>
274 <rect x="100" y="150" width="40" height="40"/>
275 <rect x="150" y="150" width="40" height="40"/>
276 <rect x="200" y="150" width="40" height="40"/>
277
278 <rect x="0" y="200" width="40" height="40"/>
279 <rect x="50" y="200" width="40" height="40"/>
280 <rect x="100" y="200" width="40" height="40"/>
281 <rect x="150" y="200" width="40" height="40"/>
282 <rect x="200" y="200" width="40" height="40"/>
283 </svg>
284
285 <g transform="translate(100,200) rotate(45)">
286 <svg id="testblock4" overflow="visible"
287 width="120" height="120" viewBox="-.5 -.5 241 241"
288 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
289 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
290
291 <rect x="0" y="0" width="40" height="40"/>
292 <rect x="50" y="0" width="40" height="40"/>
293 <rect x="100" y="0" width="40" height="40"/>
294 <rect x="150" y="0" width="40" height="40"/>
295 <rect x="200" y="0" width="40" height="40"/>
296
297 <rect x="0" y="50" width="40" height="40"/>
298 <rect x="50" y="50" width="40" height="40"/>
299 <rect x="100" y="50" width="40" height="40"/>
300 <rect x="150" y="50" width="40" height="40"/>
301 <rect x="200" y="50" width="40" height="40"/>
302
303 <rect x="0" y="100" width="40" height="40"/>
304 <rect x="50" y="100" width="40" height="40"/>
305 <g >
306 <rect id="tb4-middle" x="100" y="100" width="40" height="40"/>
307 </g>
308 <rect x="150" y="100" width="40" height="40"/>
309 <rect x="200" y="100" width="40" height="40"/>
310
311 <rect x="0" y="150" width="40" height="40"/>
312 <rect x="50" y="150" width="40" height="40"/>
313 <rect x="100" y="150" width="40" height="40"/>
314 <rect x="150" y="150" width="40" height="40"/>
315 <rect x="200" y="150" width="40" height="40"/>
316
317 <rect x="0" y="200" width="40" height="40"/>
318 <rect x="50" y="200" width="40" height="40"/>
319 <rect x="100" y="200" width="40" height="40"/>
320 <rect x="150" y="200" width="40" height="40"/>
321 <rect x="200" y="200" width="40" height="40"/>
322 </svg>
323 </g>
324
325 <g transform="translate(350,200) rotate(45)">
326 <svg id="testblock5" overflow="visible"
327 width="120" height="120" viewBox="-.5 -.5 241 241"
328 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
329 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
330
331 <rect x="0" y="0" width="40" height="40"/>
332 <rect x="50" y="0" width="40" height="40"/>
333 <rect x="100" y="0" width="40" height="40"/>
334 <rect x="150" y="0" width="40" height="40"/>
335 <rect x="200" y="0" width="40" height="40"/>
336
337 <rect x="0" y="50" width="40" height="40"/>
338 <rect x="50" y="50" width="40" height="40"/>
339 <rect x="100" y="50" width="40" height="40"/>
340 <rect x="150" y="50" width="40" height="40"/>
341 <rect x="200" y="50" width="40" height="40"/>
342
343 <rect x="0" y="100" width="40" height="40"/>
344 <rect x="50" y="100" width="40" height="40"/>
345 <g >
346 <rect id="tb5-middle" x="100" y="100" width="40" height="40"/>
347 </g>
348 <rect x="150" y="100" width="40" height="40"/>
349 <rect x="200" y="100" width="40" height="40"/>
350
351 <rect x="0" y="150" width="40" height="40"/>
352 <rect x="50" y="150" width="40" height="40"/>
353 <rect x="100" y="150" width="40" height="40"/>
354 <rect x="150" y="150" width="40" height="40"/>
355 <rect x="200" y="150" width="40" height="40"/>
356
357 <rect x="0" y="200" width="40" height="40"/>
358 <rect x="50" y="200" width="40" height="40"/>
359 <rect x="100" y="200" width="40" height="40"/>
360 <rect x="150" y="200" width="40" height="40"/>
361 <rect x="200" y="200" width="40" height="40"/>
362 </svg>
363 </g>
364
365 <g transform="translate(225,285) rotate(45)">
366 <svg id="testblock6" overflow="visible"
367 width="120" height="120" viewBox="-.5 -.5 241 241"
368 style="fill:yellow; stroke:black; stroke-width:2; fill-opacity:.5;">
369 <path d="M 10 10 h 220 v 220 h -220 z m 20 20 v 180 h 180 v -180 z"/>
370
371 <rect id="tb6-11" x="0" y="0" width="40" height="40"/>
372 <rect id="tb6-21" x="50" y="0" width="40" height="40"/>
373 <rect id="tb6-31" x="100" y="0" width="40" height="40"/>
374 <rect id="tb6-41" x="150" y="0" width="40" height="40"/>
375 <rect id="tb6-51" x="200" y="0" width="40" height="40"/>
376
377 <rect id="tb6-12" x="0" y="50" width="40" height="40"/>
378 <rect id="tb6-22" x="50" y="50" width="40" height="40"
379 pointer-events="none"/>
380 <rect id="tb6-32" x="100" y="50" width="40" height="40"/>
381 <rect id="tb6-42" x="150" y="50" width="40" height="40"/>
382 <rect id="tb6-52" x="200" y="50" width="40" height="40"/>
383
384 <rect id="tb6-13" x="0" y="100" width="40" height="40"/>
385 <rect id="tb6-23" x="50" y="100" width="40" height="40"/>
386 <g >
387 <rect id="tb6-middle" x="100" y="100" width="40" height="40"/>
388 </g>
389 <rect id="tb6-43" x="150" y="100" width="40" height="40"/>
390 <rect id="tb6-53" x="200" y="100" width="40" height="40"/>
391
392 <rect id="tb6-14" x="0" y="150" width="40" height="40"/>
393 <rect id="tb6-24" x="50" y="150" width="40" height="40"/>
394 <rect id="tb6-34" x="100" y="150" width="40" height="40"/>
395 <rect id="tb6-44" x="150" y="150" width="40" height="40"/>
396 <rect id="tb6-54" x="200" y="150" width="40" height="40"/>
397
398 <rect id="tb6-15" x="0" y="200" width="40" height="40"/>
399 <rect id="tb6-25" x="50" y="200" width="40" height="40"/>
400 <rect id="tb6-35" x="100" y="200" width="40" height="40"/>
401 <rect id="tb6-45" x="150" y="200" width="40" height="40"/>
402 <rect id="tb6-55" x="200" y="200" width="40" height="40"/>
403 </svg>
404 </g>
405
406 <text x="225" y="220" text-anchor="middle" font-size="15"
407 >This <tspan id="ts" font-weight="bold">is <tspan font-style="italic">a</tspan> test</tspan>
408 <tspan x="225" y="240" text-anchor="middle">of text intersection</tspan></text>
409 </g>
410 </svg>
411
412