blob: 462acfc4ab08f1f1db7d507ff7f8c7ee10ea17c1 [file] [log] [blame]
<!DOCTYPE html>
<title>SVGPathElement path metrics query w/ pathLength</title>
<script src=../../resources/testharness.js></script>
<script src=../../resources/testharnessreport.js></script>
<script>
setup(function() {
window.path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
path.setAttribute('d', 'M0,0L100,0L100,100');
path.setAttribute('pathLength', '1000');
});
test(function() {
assert_approx_equals(path.getTotalLength(), 200, 1e-5);
}, document.title+', getTotalLength');
test(function() {
var point = path.getPointAtLength(50);
assert_approx_equals(point.x, 50, 1e-5);
assert_approx_equals(point.y, 0, 1e-5);
var point = path.getPointAtLength(150);
assert_approx_equals(point.x, 100, 1e-5);
assert_approx_equals(point.y, 50, 1e-5);
}, document.title+', getPointAtLength');
test(function() {
assert_equals(path.getPathSegAtLength(50), 1);
assert_equals(path.getPathSegAtLength(150), 2);
}, document.title+', getPathSegAtLength');
</script>