diff options
Diffstat (limited to 'ksvg/test/ecma/bbox')
-rw-r--r-- | ksvg/test/ecma/bbox/bbox-circle.svg | 13 | ||||
-rw-r--r-- | ksvg/test/ecma/bbox/bbox-ellipse.svg | 14 | ||||
-rw-r--r-- | ksvg/test/ecma/bbox/bbox-line.svg | 35 | ||||
-rw-r--r-- | ksvg/test/ecma/bbox/bbox-path.svg | 15 | ||||
-rw-r--r-- | ksvg/test/ecma/bbox/bbox-path2.svg | 14 | ||||
-rw-r--r-- | ksvg/test/ecma/bbox/bbox-polygon.svg | 13 | ||||
-rw-r--r-- | ksvg/test/ecma/bbox/bbox-polyline.svg | 13 | ||||
-rw-r--r-- | ksvg/test/ecma/bbox/bbox-rect.svg | 15 | ||||
-rw-r--r-- | ksvg/test/ecma/bbox/bbox.js | 103 |
9 files changed, 235 insertions, 0 deletions
diff --git a/ksvg/test/ecma/bbox/bbox-circle.svg b/ksvg/test/ecma/bbox/bbox-circle.svg new file mode 100644 index 00000000..10ff5e3c --- /dev/null +++ b/ksvg/test/ecma/bbox/bbox-circle.svg @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 6)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <circle id="test-0" cx="100" cy="140" r="50" fill="none" stroke="black" />
+ <circle id="test-1" cx="220" cy="140" r="35" fill="red" stroke="black" />
+ <circle id="test-2" cx="340" cy="140" r="20" fill="black" stroke="lime" stroke-width="4" />
+ <circle id="test-3" cx="100" cy="260" r="20" stroke="lime" fill="yellow" stroke-width="4" />
+ <circle id="test-4" cx="220" cy="260" r="35" stroke="none" fill="blue" />
+ <circle id="test-5" cx="340" cy="260" r="50" stroke="red" fill="none" stroke-width="10" />
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-ellipse.svg b/ksvg/test/ecma/bbox/bbox-ellipse.svg new file mode 100644 index 00000000..0fccee5b --- /dev/null +++ b/ksvg/test/ecma/bbox/bbox-ellipse.svg @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 7)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <ellipse id="test-0" fill="none" stroke="#000000" cx="50" cy="135" rx="30" ry="50"/>
+ <ellipse id="test-1" fill="red" cx="160" cy="135" rx="30" ry="50"/>
+ <ellipse id="test-2" fill="none" stroke="#000000" cx="270" cy="140" rx="35" ry="35"/>
+ <ellipse id="test-3" fill="red" cx="370" cy="140" rx="35" ry="35"/>
+ <ellipse id="test-4" fill="none" stroke="#0000FF" stroke-width="8" cx="50" cy="310" rx="30" ry="50"/>
+ <ellipse id="test-5" fill="#00FF00" stroke="#0000FF" stroke-width="8" cx="160" cy="310" rx="30" ry="50"/>
+ <ellipse id="test-6" fill="#00FF00" stroke="#0000FF" stroke-width="8" cx="330" cy="310" rx="70" ry="40"/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-line.svg b/ksvg/test/ecma/bbox/bbox-line.svg new file mode 100644 index 00000000..b9caf551 --- /dev/null +++ b/ksvg/test/ecma/bbox/bbox-line.svg @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 4)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <g id="test-0" transform="translate(0,20)">
+ <line x1="37.5" y1="137" x2="112.5" y2="50" fill="none" stroke="black" stroke-width="1" />
+ <line x1="112.5" y1="137" x2="187.5" y2="50" fill="none" stroke="red" stroke-width="5" />
+ <line x1="187.5" y1="137" x2="262.5" y2="50" fill="none" stroke="green" stroke-width="7.5" />
+ <line x1="262.5" y1="137" x2="337.5" y2="50" fill="none" stroke="blue" stroke-width="10" />
+ <line x1="337.5" y1="137" x2="412.5" y2="50" fill="none" stroke="fuchsia" stroke-width="12.5" />
+ </g>
+ <g id="test-1" stroke="black" stroke-width="1" transform="translate(0,20)">
+ <line x1="125" y1="200" x2="175" y2="200"/>
+ <line x1="175" y1="200" x2="175" y2="250"/>
+ <line x1="175" y1="250" x2="225" y2="250"/>
+ <line x1="225" y1="250" x2="225" y2="200"/>
+ <line x1="225" y1="200" x2="275" y2="200"/>
+ </g>
+ <g id="test-2" stroke="blue" stroke-width="10" transform="translate(0,20)">
+ <line x1="25" y1="300" x2="75" y2="300"/>
+ <line x1="75" y1="300" x2="75" y2="350"/>
+ <line x1="75" y1="350" x2="125" y2="350"/>
+ <line x1="125" y1="350" x2="125" y2="300"/>
+ <line x1="125" y1="300" x2="175" y2="300"/>
+ </g>
+ <g id="test-3" stroke-width="10" transform="translate(0,20)">
+ <line x1="275" y1="350" x2="325" y2="350" stroke="black" />
+ <line x1="325" y1="300" x2="375" y2="300" stroke="fuchsia" />
+ <line x1="225" y1="300" x2="275" y2="300" stroke="blue" />
+ <line x1="275" y1="300" x2="275" y2="350" stroke="green" />
+ <line x1="325" y1="350" x2="325" y2="300" stroke="red" />
+ </g>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-path.svg b/ksvg/test/ecma/bbox/bbox-path.svg new file mode 100644 index 00000000..bdfd24fe --- /dev/null +++ b/ksvg/test/ecma/bbox/bbox-path.svg @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 8)">
+ <script xlink:href="bbox.js"/>
+ <g transform="translate(0,50)">
+ <path id="test-0" fill="#FF0000" stroke="#00C000" d=" M 250 130 C 185 130 150 80 150 80 S 115 25 50 25 m 0 105 c 65 0 100 -50 100 -50 s 35 -55 100 -55 "/>
+ <path id="test-1" fill="none" stroke="#000000" d=" M 300 90 c 0 30 7 50 50 0 c 43 -50 50 -30 50 0 c 0 83 -68 -34 -90 -30 C 300 60 300 90 300 90 z "/>
+ <path id="test-2" fill="none" stroke="#000000" d=" M 100 170 C 120 170 180 170 200 170 Z "/>
+ <path id="test-3" fill="#00C000" stroke="none" d=" M 25 360 C 60 360 80 275 75 260 c -5 15 15 100 50 100 Z "/>
+ <path id="test-4" fill="none" stroke="#000000" d=" m 200 300 c 50 -40 50 -100 25 -100 s -25 60 25 100 "/>
+ <path id="test-5" fill="#0000FF" stroke="#000000" d=" M 320 160 C 380 150 420 190 410 250 "/>
+ <path id="test-6" fill="#FFFF00" stroke="#000000" d=" M 360 280 c 0 20 -16 36 -36 36 s -36 -16 -36 -36 s 16 -36 36 -36 s 36 16 36 36 z "/>
+ <path id="test-7" fill="#F0F0F0" stroke="#FF0000" d=" m 340 425 c -40 -60 95 -100 80 0 z "/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-path2.svg b/ksvg/test/ecma/bbox/bbox-path2.svg new file mode 100644 index 00000000..988641a1 --- /dev/null +++ b/ksvg/test/ecma/bbox/bbox-path2.svg @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="480" onload="gen_buttons(evt, 7)">
+ <script xlink:href="bbox.js"/>
+ <g transform="translate(0,70)">
+ <path id="test-0" fill="none" stroke="#0000FF" stroke-width="3" d=" M 15 20 Q 30 120 130 30 M 180 80 q -75 -100 -163 -60 z "/>
+ <path id="test-1" fill="#FFFF00" stroke="#CF0000" d=" m 350 130 q -100 -80 50 -120 z m 70 0 q 50 -150 -80 -90 Z "/>
+ <path id="test-2" fill="none" stroke="#00FFFF" d=" M 215 115 Q 225 0 295 45 Z "/>
+ <path id="test-3" fill="#00C000" stroke="#000000" d=" M 200 200 Q 250 300 300 200 T 250 150 Q 120 120 200 200 z "/>
+ <path id="test-4" fill="#CF0000" stroke="none" d=" M 60 100 Q -40 150 60 200 Q 160 150 60 100 z "/>
+ <path id="test-5" fill="none" stroke="#FF0000" d=" M 15 320 q 25 -100 50 0 t 50 0 t 50 0 t 50 0 t 50 0 z "/>
+ <path id="test-6" fill="#0000C0" stroke="#00CF00" stroke-width="2" d=" M 350 300 q -100 50 0 50 Q 250 350 350 400 q 100 -50 0 -50 Q 450 350 350 300 z "/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-polygon.svg b/ksvg/test/ecma/bbox/bbox-polygon.svg new file mode 100644 index 00000000..025bdeb5 --- /dev/null +++ b/ksvg/test/ecma/bbox/bbox-polygon.svg @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 6)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <polygon id="test-0" fill="none" stroke="#000000" points="59,75,95,93,108,135,82,169,39,170,11,137,19,95"/>
+ <polygon id="test-1" fill="red" points="179,75,218,93,228,135,202,169,159,170,131,137,139,95,179,75"/>
+ <polygon id="test-2" fill="blue" stroke="black" stroke-width="6" points="350,75 375,110 410,125 375,140 350,175 325,150 290,125 325,100,350,75"/>
+ <polygon id="test-3" fill="none" stroke="#0000FF" stroke-width="8" points="59,225,98,243,108,285,82,319,39,320,11,287,19,245,59,225"/>
+ <polygon id="test-4" fill="#00FF00" stroke="#0000FF" stroke-width="8" points="179,225,218,243,228,285,202,319,159,320,131,287,139,245"/>
+ <polygon id="test-5" fill="none" stroke="#00FF00" stroke-width="8" points="270,265 300,285 320,265 340,285 280,320 390,320 420,280 280,225"/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-polyline.svg b/ksvg/test/ecma/bbox/bbox-polyline.svg new file mode 100644 index 00000000..c60321da --- /dev/null +++ b/ksvg/test/ecma/bbox/bbox-polyline.svg @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 6)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <polyline id="test-0" fill="none" stroke="#000000" points="10,80,35,180,60,80,85,180,110,80,135,180"/>
+ <polyline id="test-1" fill="none" stroke="blue" stroke-width="8" points="220,80,267,114,249,170,190,170,172,114,220,80"/>
+ <polyline id="test-2" fill="blue" stroke="#00FF00" stroke-width="4" points="310,80,335,180,360,80,385,180,410,80,435,180"/>
+ <polyline id="test-3" fill="none" stroke="red" stroke-width="8" points="59,225,98,243,108,285,82,319,39,320,11,287,19,245"/>
+ <polyline id="test-4" fill="#00FF00" stroke="#0000FF" stroke-width="8" points="189,225,228,243,238,285,212,319,169,320,141,287,149,245"/>
+ <polyline id="test-5" fill="#FF00FF" stroke="none" stroke-width="8" points="270,265 300,285 320,265 340,285 280,320 390,320 420,280 280,225"/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox-rect.svg b/ksvg/test/ecma/bbox/bbox-rect.svg new file mode 100644 index 00000000..b35285ec --- /dev/null +++ b/ksvg/test/ecma/bbox/bbox-rect.svg @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
+<svg id="svg-root" width="450" height="450" onload="gen_buttons(evt, 8)">
+ <script xlink:href="bbox.js"/>
+ <g>
+ <rect id="test-0" fill="none" stroke="#000000" x="30" y="86" width="50" height="100"/>
+ <rect id="test-1" fill="red" x="130" y="86" width="50" height="100"/>
+ <rect id="test-2" fill="none" stroke="#000000" x="250" y="86" width="50" height="100" rx="30"/>
+ <rect id="test-3" fill="red" x="350" y="86" width="50" height="100" rx="30"/>
+ <rect id="test-4" fill="none" stroke="#0000FF" stroke-width="8" x="30" y="266" width="50" height="100"/>
+ <rect id="test-5" fill="#00FF00" stroke="#0000FF" stroke-width="8" x="130" y="266" width="50" height="100"/>
+ <rect id="test-6" fill="none" stroke="#0000FF" stroke-width="8" x="250" y="266" width="50" height="100" rx="30" ry="50"/>
+ <rect id="test-7" fill="#00FF00" x="350" y="266" width="50" height="100" rx="30" ry="50"/>
+ </g>
+</svg>
diff --git a/ksvg/test/ecma/bbox/bbox.js b/ksvg/test/ecma/bbox/bbox.js new file mode 100644 index 00000000..2d692694 --- /dev/null +++ b/ksvg/test/ecma/bbox/bbox.js @@ -0,0 +1,103 @@ +function clear_test(evt, number) +{ + for(var i = 0; i < number; i++) + { + var element = evt.target.getOwnerDocument().getElementById("bbox" + (i + 1)); + element.getParentNode().removeChild(element); + } +} + +function bbox_loop(drawit, number) +{ + var doc = evt.target.getOwnerDocument(); + + for(var i = 0; i < number; i++) + { + var shape = doc.getElementById("test-" + i); + var bbox = shape.getBBox(); + + if(drawit == "true") + { + draw_it(doc, bbox, shape, i + 1); + } + else + { + do_string(bbox, i + 1); + } + } +} + +function do_string(shape, number) +{ + var string = "\nShape " + number + "\nX = " + shape.x + "\nY = " + shape.y + "\nW = " + shape.width + "\nH = " + shape.height; + alert(string); +} + +function draw_it(doc, bbox, shape, number) +{ + var element = doc.createElement("rect"); + element.setAttribute("x", bbox.x); + element.setAttribute("y", bbox.y); + element.setAttribute("width", bbox.width); + element.setAttribute("height", bbox.height); + element.setAttribute("fill", "none"); + element.setAttribute("stroke", "red"); + element.setAttribute("stroke-width", "3"); + element.setAttribute("id", "bbox" + number); + + shape.getParentNode().appendChild(element); +} + +function gen_buttons(evt, number) +{ + var doc = evt.target.getOwnerDocument(); + var main = doc.getElementById("svg-root"); + + var aone = doc.createElement("a"); + var atwo = doc.createElement("a"); + var athree = doc.createElement("a"); + + var rect = doc.createElement("rect"); + var text = doc.createElement("text"); + + aone.setAttribute("onclick", "bbox_loop('false'," + number + ")"); + + atwo.setAttribute("onclick", "bbox_loop('true'," + number + ")"); + atwo.setAttribute("transform", "translate(0,22)"); + + athree.setAttribute("onclick", "clear_test(evt," + number + ")"); + athree.setAttribute("transform", "translate(0,44)"); + + rect.setAttribute("x", "0"); + rect.setAttribute("y", "0"); + rect.setAttribute("width", "110"); + rect.setAttribute("height", "20"); + + text.setAttribute("x", "0"); + text.setAttribute("y", "15"); + text.setAttribute("fill", "white"); + + // First button + aone.appendChild(rect.cloneNode(1)); + var aonetext = text.cloneNode(1); + aonetext.appendChild(doc.createTextNode("Calculate bbox")); + aone.appendChild(aonetext); + + main.appendChild(aone); + + // Second button + atwo.appendChild(rect.cloneNode(1)); + var atwotext = text.cloneNode(1); + atwotext.appendChild(doc.createTextNode("Draw bbox")); + atwo.appendChild(atwotext); + + main.appendChild(atwo); + + // Third button + athree.appendChild(rect.cloneNode(1)); + var athreetext = text.cloneNode(1); + athreetext.appendChild(doc.createTextNode("Clear bbox drawing")); + athree.appendChild(athreetext); + + main.appendChild(athree); +} |