File: pathLength.svg

package info (click to toggle)
batik 1.16%2Bdfsg-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 29,180 kB
  • sloc: java: 191,940; xml: 19,062; javascript: 1,276; sh: 85; makefile: 5
file content (122 lines) | stat: -rw-r--r-- 4,371 bytes parent folder | download | duplicates (3)
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
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">

<!--

   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

-->
<!-- ====================================================================== -->
<!-- Test of getPathLength, and getPointAtLength interfaces.                -->
<!--                                                                        -->
<!-- @author deweese@apache.org                                             -->
<!-- @version $Id: pathLength.svg 1733420 2016-03-03 07:41:59Z gadams $ -->
<!-- ====================================================================== -->

<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?>  

<svg id="body" width="450" height="500" viewBox="0 0 450 500"
  onload="load(evt)"
     xmlns="http://www.w3.org/2000/svg" 
     xmlns:xlink="http://www.w3.org/1999/xlink">

   <title>Test getPathLength and getPointAtLength interfaces</title>

   <text x="50%" y="40" class="title"
    >Test getPathLength and getPointAtLength interfaces</text>

   <style type="text/css"><![CDATA[
     text { stroke: none }
     circle { stroke: none }
     path   { fill:none }
]]></style>

   <script type="text/ecmascript">
    var svgNamespaceURI = "http://www.w3.org/2000/svg";
    var doc;

    function doLength(cnt, dist) {
      var p = doc.getElementById("p"+cnt);
      var l = doc.getElementById("l"+cnt);
      var c = doc.getElementById("c"+cnt);

      var len, pt;
      len = p.getTotalLength();
      pt  = p.getPointAtLength(dist);
      l.appendChild(doc.createTextNode(("Len: " + len).substring(0, 10)));
      c.setAttribute("cx", ""+pt.getX());
      c.setAttribute("cy", ""+pt.getY());
    }

    function load(evt) {
      doc = evt.target.getOwnerDocument();
      doLength(1, 25);
      doLength(2, 25);
      doLength(3, 25);
      doLength(4, 25);
      doLength(5, 25);
      doLength(6, 25);
      doLength(7, (78.546)/2);
      doLength(8, 25);

    }
   </script>

   <g stroke="black">
      <path id="p1" d="M 20,60 h 50"/>  
      <text id="l1" x="80" y="65"/>
      <circle cx="45" cy="60" r="3" fill="red"/>
      <circle id="c1" cx="0" cy="0" r="1" fill="black"/>

      <path id="p2" d="M 20,60 l 40,30"/>
      <text id="l2" x="70" y="95"/>
      <circle cx="40" cy="75" r="3" fill="red"/>
      <circle id="c2" cx="0" cy="0" r="1" fill="black"/>

      <path id="p3" d="M 20,60 v 50"/>
      <text id="l3" x="30" y="115"/>
      <circle cx="20" cy="85" r="3" fill="red"/>
      <circle id="c3" cx="0" cy="0" r="1" fill="black"/>

      <path id="p4" d="M 170,60 c 15 0 35 0 50 0"/>
      <text id="l4" x="230" y="65"/>
      <circle cx="195" cy="60" r="3" fill="red"/>
      <circle id="c4" cx="0" cy="0" r="1" fill="black"/>

      <path id="p5" d="M 170,60 c 15 0 30 0 30,40"/>
      <text id="l5" x="210" y="105"/>
      <circle cx="192.8" cy="67.3" r="3" fill="red"/>
      <circle id="c5" cx="0" cy="0" r="1" fill="black"/>

      <path id="p6" d="M 20,170 a 10 0 0 0 0 50 0"/>
      <text id="l6" x="80" y="175"/>
      <circle cx="45" cy="170" r="3" fill="red"/>
      <circle id="c6" cx="0" cy="0" r="1" fill="black"/>

      <path id="p7" d="M 20,170 a 10 10 0 0 0 50 0"/>
      <text id="l7" x="80" y="195"/>
      <circle cx="45" cy="195" r="3" fill="red"/>
      <circle id="c7" cx="0" cy="0" r="1" fill="black"/>

      <path id="p8" d="M 170,170 v10h10v-10h10v10"/>
      <text id="l8" x="200" y="180"/>
      <circle cx="180" cy="175" r="3" fill="red"/>
      <circle id="c8" cx="0" cy="0" r="1" fill="black"/>


   </g>
</svg>