animate-path-animation-lL-vV-hH-inverse.tentative.html (1839B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>Path animation where coordinate modes of start and end differ (l-L, v-V and h-H)</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="/resources/SVGAnimationTestCase-testharness.js"></script> 7 <script src="support/animated-path-helpers.js"></script> 8 <svg></svg> 9 <script> 10 var rootSVGElement = document.querySelector("svg"); 11 12 // Setup test document 13 var path = createSVGElement("path"); 14 path.setAttribute("id", "path"); 15 path.setAttribute("d", "M 30 30 l -60 -30 v -30 h 30 Z"); 16 path.setAttribute("fill", "green"); 17 path.setAttribute("transform", "translate(50, 50)"); 18 19 var animate = createSVGElement("animate"); 20 animate.setAttribute("id", "animation"); 21 animate.setAttribute("attributeName", "d"); 22 animate.setAttribute("from", "M 30 30 l -60 -30 v -30 h 30 Z"); 23 animate.setAttribute("to", "M -30 -30 L 30 0 V 30 H 0 Z"); 24 animate.setAttribute("begin", "0s"); 25 animate.setAttribute("dur", "4s"); 26 path.appendChild(animate); 27 rootSVGElement.appendChild(path); 28 29 // Setup animation test 30 function sample1() { 31 // Check initial/end conditions 32 assert_animated_path_equals(path, "M 30 30 l -60 -30 v -30 h 30 Z"); 33 } 34 35 function sample2() { 36 assert_animated_path_equals(path, "M 15 15 L -15 0 V -15 H 0 Z"); 37 } 38 39 function sample3() { 40 assert_animated_path_equals(path, "M -15 -15 L 15 0 V 15 H 0 Z"); 41 } 42 43 function sample4() { 44 assert_animated_path_equals(path, "M -29.985 -29.985 L 29.985 0 V 29.985 H 0 Z"); 45 } 46 47 smil_async_test(t => { 48 const expectedValues = [ 49 // [animationId, time, sampleCallback] 50 ["animation", 0.0, sample1], 51 ["animation", 1.0, sample2], 52 ["animation", 3.0, sample3], 53 ["animation", 3.999, sample4], 54 ["animation", 4.001, sample1] 55 ]; 56 runAnimationTest(t, expectedValues); 57 }); 58 </script>