Debian Codegraph @

samples/tests/spec/scripting/pathLength.svg

raw
1 <?xml version="1.0" standalone="no"?>
2 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
3 "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.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 <!-- Test of getPathLength, and getPointAtLength interfaces. -->
25 <!-- -->
26 <!-- @author [email protected] -->
27 <!-- @version $Id$ -->
28 <!-- ====================================================================== -->
29
30 <?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>
31
32 <svg id="body" width="450" height="500" viewBox="0 0 450 500"
33 onload="load(evt)"
34 xmlns="http://www.w3.org/2000/svg"
35 xmlns:xlink="http://www.w3.org/1999/xlink">
36
37 <title>Test getPathLength and getPointAtLength interfaces</title>
38
39 <text x="50%" y="40" class="title"
40 >Test getPathLength and getPointAtLength interfaces</text>
41
42 <style type="text/css"><![CDATA[
43 text { stroke: none }
44 circle { stroke: none }
45 path { fill:none }
46 ]]></style>
47
48 <script type="text/ecmascript">
49 var svgNamespaceURI = "http://www.w3.org/2000/svg";
50 var doc;
51
52 function doLength(cnt, dist) {
53 var p = doc.getElementById("p"+cnt);
54 var l = doc.getElementById("l"+cnt);
55 var c = doc.getElementById("c"+cnt);
56
57 var len, pt;
58 len = p.getTotalLength();
59 pt = p.getPointAtLength(dist);
60 l.appendChild(doc.createTextNode(("Len: " + len).substring(0, 10)));
61 c.setAttribute("cx", ""+pt.getX());
62 c.setAttribute("cy", ""+pt.getY());
63 }
64
65 function load(evt) {
66 doc = evt.target.getOwnerDocument();
67 doLength(1, 25);
68 doLength(2, 25);
69 doLength(3, 25);
70 doLength(4, 25);
71 doLength(5, 25);
72 doLength(6, 25);
73 doLength(7, (78.546)/2);
74 doLength(8, 25);
75
76 }
77 </script>
78
79 <g stroke="black">
80 <path id="p1" d="M 20,60 h 50"/>
81 <text id="l1" x="80" y="65"/>
82 <circle cx="45" cy="60" r="3" fill="red"/>
83 <circle id="c1" cx="0" cy="0" r="1" fill="black"/>
84
85 <path id="p2" d="M 20,60 l 40,30"/>
86 <text id="l2" x="70" y="95"/>
87 <circle cx="40" cy="75" r="3" fill="red"/>
88 <circle id="c2" cx="0" cy="0" r="1" fill="black"/>
89
90 <path id="p3" d="M 20,60 v 50"/>
91 <text id="l3" x="30" y="115"/>
92 <circle cx="20" cy="85" r="3" fill="red"/>
93 <circle id="c3" cx="0" cy="0" r="1" fill="black"/>
94
95 <path id="p4" d="M 170,60 c 15 0 35 0 50 0"/>
96 <text id="l4" x="230" y="65"/>
97 <circle cx="195" cy="60" r="3" fill="red"/>
98 <circle id="c4" cx="0" cy="0" r="1" fill="black"/>
99
100 <path id="p5" d="M 170,60 c 15 0 30 0 30,40"/>
101 <text id="l5" x="210" y="105"/>
102 <circle cx="192.8" cy="67.3" r="3" fill="red"/>
103 <circle id="c5" cx="0" cy="0" r="1" fill="black"/>
104
105 <path id="p6" d="M 20,170 a 10 0 0 0 0 50 0"/>
106 <text id="l6" x="80" y="175"/>
107 <circle cx="45" cy="170" r="3" fill="red"/>
108 <circle id="c6" cx="0" cy="0" r="1" fill="black"/>
109
110 <path id="p7" d="M 20,170 a 10 10 0 0 0 50 0"/>
111 <text id="l7" x="80" y="195"/>
112 <circle cx="45" cy="195" r="3" fill="red"/>
113 <circle id="c7" cx="0" cy="0" r="1" fill="black"/>
114
115 <path id="p8" d="M 170,170 v10h10v-10h10v10"/>
116 <text id="l8" x="200" y="180"/>
117 <circle cx="180" cy="175" r="3" fill="red"/>
118 <circle id="c8" cx="0" cy="0" r="1" fill="black"/>
119
120
121 </g>
122 </svg>