animate-path-animation-qQ-tT-inverse.tentative.html (1871B)
1 <!doctype html> 2 <meta charset="utf-8"> 3 <title>Path animation where coordinate modes of start and end differ (q-Q and t-T)</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 q 30 0 30 30 t -30 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 q 30 0 30 30 t -30 30 Z"); 23 animate.setAttribute("to", "M -30 -30 Q 30 -30 30 0 T -30 30 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 q 30 0 30 30 t -30 30 Z"); 33 } 34 35 function sample2() { 36 assert_animated_path_equals(path, "M -30 -30 Q 7.5 -30 7.5 0 T -30 30 Z"); 37 } 38 39 function sample3() { 40 assert_animated_path_equals(path, "M -30 -30 Q 22.5 -30 22.5 0 T -30 30 Z"); 41 } 42 43 function sample4() { 44 assert_animated_path_equals(path, "M -30 -30 Q 29.9925 -30 29.9925 0 T -30 30 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>