OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>SVGPathElement path metrics query w/ pathLength</title> |
| 3 <script src=../../resources/testharness.js></script> |
| 4 <script src=../../resources/testharnessreport.js></script> |
| 5 <script> |
| 6 setup(function() { |
| 7 window.path = document.createElementNS('http://www.w3.org/2000/svg', 'path')
; |
| 8 path.setAttribute('d', 'M0,0L100,0L100,100'); |
| 9 path.setAttribute('pathLength', '1000'); |
| 10 }); |
| 11 |
| 12 test(function() { |
| 13 assert_approx_equals(path.getTotalLength(), 200, 1e-5); |
| 14 }, document.title+', getTotalLength'); |
| 15 |
| 16 test(function() { |
| 17 var point = path.getPointAtLength(50); |
| 18 assert_approx_equals(point.x, 50, 1e-5); |
| 19 assert_approx_equals(point.y, 0, 1e-5); |
| 20 var point = path.getPointAtLength(150); |
| 21 assert_approx_equals(point.x, 100, 1e-5); |
| 22 assert_approx_equals(point.y, 50, 1e-5); |
| 23 }, document.title+', getPointAtLength'); |
| 24 |
| 25 test(function() { |
| 26 assert_equals(path.getPathSegAtLength(50), 1); |
| 27 assert_equals(path.getPathSegAtLength(150), 2); |
| 28 }, document.title+', getPathSegAtLength'); |
| 29 </script> |
OLD | NEW |