| 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 |
<!-- Modification of a path attributes --> |
| 25 |
<!-- --> |
| 26 |
<!-- @author [email protected]> |
| 27 |
<!-- @version $Id$ --> |
| 28 |
<!-- ====================================================================== --> |
| 29 |
<?xml-stylesheet type="text/css" href="../../resources/style/test.css" ?> |
| 30 |
<svg id="body" width="450" height="500" viewBox="0 0 450 500"> |
| 31 |
<title><path> attributes 'onload'</title> |
| 32 |
|
| 33 |
<text text-anchor="middle" x="50%" y="25" class="title"><path> getPathSegList() |
| 34 |
in 'onload'</text> |
| 35 |
|
| 36 |
<script type="text/ecmascript"> |
| 37 |
var SVGNS = "http://www.w3.org/2000/svg"; |
| 38 |
function moveclose(evt) { |
| 39 |
var elt = evt.target; |
| 40 |
var doc = elt.getOwnerDocument(); |
| 41 |
|
| 42 |
var path = doc.createElementNS(SVGNS,"path"); |
| 43 |
//alert(path); |
| 44 |
|
| 45 |
var seg = path.pathSegList; |
| 46 |
//alert(seg); |
| 47 |
//d="M50 50 L100 50 L100 60 L50 60 z m15 20 l20 0 l0 -30 l-20 0 z" |
| 48 |
segment = path.createSVGPathSegMovetoAbs(50,50); |
| 49 |
//alert(segment); |
| 50 |
seg.appendItem(segment); |
| 51 |
seg.appendItem(path.createSVGPathSegLinetoAbs(100,50)); |
| 52 |
seg.appendItem(path.createSVGPathSegLinetoAbs(100,60)); |
| 53 |
seg.appendItem(path.createSVGPathSegLinetoAbs(50,60)); |
| 54 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 55 |
|
| 56 |
seg.appendItem(path.createSVGPathSegMovetoRel(15,20)); |
| 57 |
seg.appendItem(path.createSVGPathSegLinetoRel(20,0)); |
| 58 |
seg.appendItem(path.createSVGPathSegLinetoRel(0,-30)); |
| 59 |
seg.appendItem(path.createSVGPathSegLinetoRel(-20,0)); |
| 60 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 61 |
|
| 62 |
elt.insertBefore(path, elt.getFirstChild()); |
| 63 |
} |
| 64 |
|
| 65 |
function horizonvertic(evt) { |
| 66 |
var elt = evt.target; |
| 67 |
var doc = elt.getOwnerDocument(); |
| 68 |
|
| 69 |
var path = doc.createElementNS(SVGNS,"path"); |
| 70 |
|
| 71 |
var seg = path.getPathSegList(); |
| 72 |
//d="M50 50 H100 V60 H50 z m15 20 h20 v-30 h-20 z" |
| 73 |
seg.appendItem(path.createSVGPathSegMovetoAbs(50,50)); |
| 74 |
seg.appendItem(path.createSVGPathSegLinetoHorizontalAbs(100)); |
| 75 |
seg.appendItem(path.createSVGPathSegLinetoVerticalAbs(60)); |
| 76 |
seg.appendItem(path.createSVGPathSegLinetoHorizontalAbs(50)); |
| 77 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 78 |
|
| 79 |
seg.appendItem(path.createSVGPathSegMovetoRel(15,20)); |
| 80 |
seg.appendItem(path.createSVGPathSegLinetoHorizontalRel(20)); |
| 81 |
seg.appendItem(path.createSVGPathSegLinetoVerticalRel(-30)); |
| 82 |
seg.appendItem(path.createSVGPathSegLinetoHorizontalRel(-20)); |
| 83 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 84 |
|
| 85 |
elt.insertBefore(path, elt.getFirstChild()); |
| 86 |
} |
| 87 |
|
| 88 |
function cubic(evt) { |
| 89 |
var elt = evt.target; |
| 90 |
var doc = elt.getOwnerDocument(); |
| 91 |
|
| 92 |
var path = doc.createElementNS(SVGNS,"path"); |
| 93 |
|
| 94 |
var seg = path.getPathSegList(); |
| 95 |
//d="M50 50C100 50 100 60 50 60z m15 30 c -50 0 -50 -10 0 -10z " |
| 96 |
seg.appendItem(path.createSVGPathSegMovetoAbs(50,50)); |
| 97 |
seg.appendItem(path.createSVGPathSegCurvetoCubicAbs(50,60,100,50,100,60)); |
| 98 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 99 |
|
| 100 |
seg.appendItem(path.createSVGPathSegMovetoRel(15,30)); |
| 101 |
seg.appendItem(path.createSVGPathSegCurvetoCubicRel(0,-10,-50,0,-50,-10)); |
| 102 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 103 |
|
| 104 |
elt.insertBefore(path, elt.getFirstChild()); |
| 105 |
} |
| 106 |
|
| 107 |
function quadra(evt) { |
| 108 |
var elt = evt.target; |
| 109 |
var doc = elt.getOwnerDocument(); |
| 110 |
|
| 111 |
var path = doc.createElementNS(SVGNS,"path"); |
| 112 |
|
| 113 |
var seg = path.getPathSegList(); |
| 114 |
//d="M50 50Q 75 30 100 50z m30 20 q -25 20 -50 0z " |
| 115 |
seg.appendItem(path.createSVGPathSegMovetoAbs(50,50)); |
| 116 |
seg.appendItem(path.createSVGPathSegCurvetoQuadraticAbs(100,50,75,30)); |
| 117 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 118 |
|
| 119 |
seg.appendItem(path.createSVGPathSegMovetoRel(15,20)); |
| 120 |
seg.appendItem(path.createSVGPathSegCurvetoQuadraticRel(-50,0,-25,20)); |
| 121 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 122 |
|
| 123 |
elt.insertBefore(path, elt.getFirstChild()); |
| 124 |
} |
| 125 |
|
| 126 |
function arc(evt) { |
| 127 |
var elt = evt.target; |
| 128 |
var doc = elt.getOwnerDocument(); |
| 129 |
|
| 130 |
var path = doc.createElementNS(SVGNS,"path"); |
| 131 |
|
| 132 |
var seg = path.getPathSegList(); |
| 133 |
//d="M50 50 A50 50 0 0 0 90 90z m10 -10 a50 50 0 0 1 40 40z " |
| 134 |
seg.appendItem(path.createSVGPathSegMovetoAbs(50,50)); |
| 135 |
seg.appendItem(path.createSVGPathSegArcAbs(90,90,50,50,0,false,false)); |
| 136 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 137 |
|
| 138 |
seg.appendItem(path.createSVGPathSegMovetoRel(10,-10)); |
| 139 |
seg.appendItem(path.createSVGPathSegArcRel(40,40,50,50,0,false,true)); |
| 140 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 141 |
|
| 142 |
elt.insertBefore(path, elt.getFirstChild()); |
| 143 |
} |
| 144 |
|
| 145 |
function cubicsmooth(evt) { |
| 146 |
var elt = evt.target; |
| 147 |
var doc = elt.getOwnerDocument(); |
| 148 |
|
| 149 |
var path = doc.createElementNS(SVGNS,"path"); |
| 150 |
|
| 151 |
var seg = path.getPathSegList(); |
| 152 |
//d="M50 30 C60 30 60 55 50 55 S 40 80 50 80z m30 0 c-10 0 -10 25 0 25 s 10 25 0 25z" |
| 153 |
seg.appendItem(path.createSVGPathSegMovetoAbs(50,30)); |
| 154 |
seg.appendItem(path.createSVGPathSegCurvetoCubicAbs(50,55,60,30,60,55)); |
| 155 |
seg.appendItem(path.createSVGPathSegCurvetoCubicSmoothAbs(50,80,40,80)); |
| 156 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 157 |
|
| 158 |
seg.appendItem(path.createSVGPathSegMovetoRel(30,0)); |
| 159 |
seg.appendItem(path.createSVGPathSegCurvetoCubicRel(0,25,-10,0,-10,25)); |
| 160 |
seg.appendItem(path.createSVGPathSegCurvetoCubicSmoothRel(0,25,10,25)); |
| 161 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 162 |
|
| 163 |
elt.insertBefore(path, elt.getFirstChild()); |
| 164 |
} |
| 165 |
|
| 166 |
function quadrasmooth(evt) { |
| 167 |
var elt = evt.target; |
| 168 |
var doc = elt.getOwnerDocument(); |
| 169 |
|
| 170 |
var path = doc.createElementNS(SVGNS,"path"); |
| 171 |
|
| 172 |
var seg = path.getPathSegList(); |
| 173 |
//d="M50 50 Q 62.5 30 75 50 T 100 50z m 0 25 q 12.5 20 25 0t25 0z" |
| 174 |
seg.appendItem(path.createSVGPathSegMovetoAbs(50,50)); |
| 175 |
seg.appendItem(path.createSVGPathSegCurvetoQuadraticAbs(75,50,62.5,30)); |
| 176 |
seg.appendItem(path.createSVGPathSegCurvetoQuadraticSmoothAbs(100,50)); |
| 177 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 178 |
|
| 179 |
seg.appendItem(path.createSVGPathSegMovetoRel(0,25)); |
| 180 |
seg.appendItem(path.createSVGPathSegCurvetoQuadraticRel(25,0,12.5,20)); |
| 181 |
seg.appendItem(path.createSVGPathSegCurvetoQuadraticSmoothRel(25,0)); |
| 182 |
seg.appendItem(path.createSVGPathSegClosePath()); |
| 183 |
|
| 184 |
elt.insertBefore(path, elt.getFirstChild()); |
| 185 |
} |
| 186 |
</script> |
| 187 |
|
| 188 |
<g id="test-content" > |
| 189 |
<g style="fill:gold; stroke:orange; stroke-width:4" > |
| 190 |
<!-- onload="moveclose(evt)" --> |
| 191 |
<g transform="translate(0,20)" onload="moveclose(evt)"> |
| 192 |
<g style="fill:black; stroke:none; text-anchor:middle"> |
| 193 |
<text x="75" y="100" >MoveTo/LineTo/close</text> |
| 194 |
</g> |
| 195 |
</g> |
| 196 |
|
| 197 |
<g transform="translate(150,20)" onload="horizonvertic(evt)"> |
| 198 |
<g style="fill:black; stroke:none; text-anchor:middle"> |
| 199 |
<text x="75" y="100" >MoveTo/HV/close</text> |
| 200 |
</g> |
| 201 |
</g> |
| 202 |
|
| 203 |
<g transform="translate(300,20)" onload="cubic(evt)"> |
| 204 |
<g style="fill:black; stroke:none; text-anchor:middle"> |
| 205 |
<text x="75" y="100" >MoveTo/Cubic</text> |
| 206 |
</g> |
| 207 |
</g> |
| 208 |
|
| 209 |
<g transform="translate(0,150)" onload="quadra(evt)"> |
| 210 |
<g style="fill:black; stroke:none; text-anchor:middle"> |
| 211 |
<text x="75" y="100" >MoveTo/Quadratic</text> |
| 212 |
</g> |
| 213 |
</g> |
| 214 |
|
| 215 |
<g transform="translate(150,150)" onload="cubicsmooth(evt)"> |
| 216 |
<g style="fill:black; stroke:none; text-anchor:middle"> |
| 217 |
<text x="75" y="100" >Cubic/CubicSmooth</text> |
| 218 |
</g> |
| 219 |
</g> |
| 220 |
|
| 221 |
<g transform="translate(300,150)" onload="quadrasmooth(evt)"> |
| 222 |
<g style="fill:black; stroke:none; text-anchor:middle"> |
| 223 |
<text x="75" y="100" >Quadratic/QuadraticSmooth</text> |
| 224 |
</g> |
| 225 |
</g> |
| 226 |
|
| 227 |
<g transform="translate(0,280)" onload="arc(evt)"> |
| 228 |
<g style="fill:black; stroke:none; text-anchor:middle"> |
| 229 |
<text x="75" y="120" >Moveto/Arcto</text> |
| 230 |
</g> |
| 231 |
</g> |
| 232 |
</g> |
| 233 |
</g> |
| 234 |
|
| 235 |
</svg> |