OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>SVGGeometryElement.getPointAtLength method (element detached)</title> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script> |
| 6 test(function() { |
| 7 var pathElement = document.createElementNS("http://www.w3.org/2000/svg", "path
"); |
| 8 |
| 9 function pointAtLength(string) { |
| 10 pathElement.setAttribute("d", string); |
| 11 |
| 12 var point = pathElement.getPointAtLength(700); |
| 13 return [Math.round(point.x), Math.round(point.y)]; |
| 14 } |
| 15 |
| 16 assert_array_equals(pointAtLength('M0,20 L400,20 L640,20'), [640, 20]); |
| 17 assert_array_equals(pointAtLength('M0,20 L400,20 L640,20 z'), [580, 20]); |
| 18 assert_array_equals(pointAtLength('M0,20 L400,20 z M 320,20 L640,20'), [100, 2
0]); |
| 19 assert_array_equals(pointAtLength('M0,20 L20,40'), [20, 40]); |
| 20 }, document.title + " with SVGPathElement"); |
| 21 |
| 22 test(function() { |
| 23 var rectElement = document.createElementNS("http://www.w3.org/2000/svg", "rect
"); |
| 24 |
| 25 function pointAtLength(rx, ry, width, height) { |
| 26 rectElement.setAttribute("rx", rx); |
| 27 rectElement.setAttribute("ry", ry); |
| 28 rectElement.setAttribute("width", width); |
| 29 rectElement.setAttribute("height", height); |
| 30 |
| 31 var point = rectElement.getPointAtLength(300); |
| 32 return [Math.round(point.x), Math.round(point.y)]; |
| 33 } |
| 34 |
| 35 assert_array_equals(pointAtLength(0, 0, 200, 300), [0, 0]); |
| 36 assert_array_equals(pointAtLength(50, 50, 200, 300), [0, 0]); |
| 37 }, document.title + " with SVGRectElement"); |
| 38 |
| 39 test(function() { |
| 40 var circleElement = document.createElementNS("http://www.w3.org/2000/svg", "ci
rcle"); |
| 41 |
| 42 function pointAtLength(radius) { |
| 43 circleElement.setAttribute("r", radius); |
| 44 |
| 45 var point = circleElement.getPointAtLength(100); |
| 46 return [Math.round(point.x), Math.round(point.y)]; |
| 47 } |
| 48 |
| 49 assert_array_equals(pointAtLength(10), [0, 0]); |
| 50 assert_array_equals(pointAtLength(100), [0, 0]); |
| 51 }, document.title + " with SVGCircleElement"); |
| 52 </script> |
OLD | NEW |