1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
<!doctype html>
<html>
<meta charset="utf-8">
<title>A copy of the corresponding W3C-SVG-1.1 test, which dumps the animation at certain times</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/SVGAnimationTestCase-testharness.js"></script>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
<!--======================================================================-->
<!--= Copyright 2000 World Wide Web Consortium, (Massachusetts =-->
<!--= Institute of Technology, Institut National de Recherche en =-->
<!--= Informatique et en Automatique, Keio University). All Rights =-->
<!--= Reserved. See http://www.w3.org/Consortium/Legal/. =-->
<!--======================================================================-->
<!-- =====================================================================-->
<!-- -->
<!-- animation-add-BE-08.svg -->
<!-- renamed for 1.1 suite to animate-elem-07-f.svg -->
<!-- renamed and split for svgt/b to animate-elem-15-t.svg -->
<!-- -->
<!-- Test possible values for 'keyTimes' -->
<!-- -->
<!-- Author : Jon Ferraiolo 11-Aug-2000 -->
<!-- Revised for 1.1 : Mathias Larsson Carlander Feb/12/2002 -->
<!-- Revised for svgt/b: Ola Andersson Jun/26/2002 -->
<!-- -->
<!-- History: -->
<!-- 11-Aug-2000, JF: Serial#1 created. -->
<!-- -->
<!-- =====================================================================-->
<!--======================================================================-->
<!--= Note. After October 2000, revision history is kept as CVS 'commit' =-->
<!--= log messages, and therefore is no longer in the preceding preamble.=-->
<!--======================================================================-->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="svg-root" width="100%" height="100%" viewBox="0 0 480 360" version="1.1" baseProfile="tiny">
<SVGTestCase xmlns="http://www.w3.org/2000/02/svg/testsuite/description/">
<OperatorScript version="$Revision: 1.5 $" testname="animate-elem-15-t.svg">
<Paragraph>
Test 'calcMode'=paced
</Paragraph>
<Paragraph>
One animation has been defined to animate the height of a rectangle. Ruler lines and text are provided
to help show what the correct behavior is. The red text shows the values for the 'calcMode' and 'keyTimes' attributes. The
black text and ruler lines help show the size and movement of the rectangle over time.
</Paragraph>
<Paragraph>
This test shows calcMode="paced" for an animation that has constant velocity, thus showing how 'values'
and 'keyTimes' are ignored.
</Paragraph>
</OperatorScript>
</SVGTestCase>
<title id="test-title">animate-elem-15-t</title>
<desc id="test-desc">Test possible values for 'keyTimes'</desc>
<!--======================================================================-->
<!--Content of Test Case follows... =====================-->
<!--======================================================================-->
<g id="test-body-content">
<text font-family="Arial" fill="red" font-size="40" x="3" y="45">calcMode="paced"</text>
<text font-family="Arial" fill="red" font-size="40" x="3" y="100">keyTimes="0;.25;.5;1"</text>
<g xml:space="preserve" font-family="Arial" font-size="13.5" stroke-width="3" >
<g transform="translate(150,140)">
<text font-size="36" x="-140" y="140">Time (s):</text>
<text font-size="36" x="290" y="140">0</text>
<line x1="300" y1="0" x2="300" y2="100" fill="none" stroke="#880000" />
<text font-size="36" x="230" y="140">1.5</text>
<line x1="255" y1="0" x2="255" y2="100" fill="none" stroke="#880000" />
<text font-size="36" x="170" y="140">4</text>
<line x1="180" y1="0" x2="180" y2="100" fill="none" stroke="#880000" />
<text font-size="36" x="20" y="140">9</text>
<line x1="30" y1="0" x2="30" y2="100" fill="none" stroke="#880000" />
<rect x="0" y="0" width="300" height="80" fill="#44AAFF" stroke="#880088" stroke-width="4" >
<animate id="an1" attributeName="width" calcMode="paced" values="300;255;180;30" keyTimes="0;.25;.5;1" begin="0s" dur="9s" fill="freeze"/>
</rect>
</g>
</g>
</g>
<text id="revision" x="10" y="340" font-size="40" stroke="none" fill="black">$Revision: 1.5 $</text>
<rect id="test-frame" x="1" y="1" width="478" height="358" fill="none" stroke="#000000"/>
<script>
// Pause the animation at t=0.
document.querySelector("svg").pauseAnimations();
</script>
</svg>
<script>
var rootSVGElement = document.querySelector("svg");
var epsilon = 1.0;
// Setup animation test
function sample1() { // From 0s to 2.25s
assert_approx_equals(rect.width.animVal.value, 300, epsilon);
assert_equals(rect.width.baseVal.value, 300);
}
function sample2() { // From 2.25s to 4.5s
assert_approx_equals(rect.width.animVal.value, 232.5, epsilon);
assert_equals(rect.width.baseVal.value, 300);
}
function sample3() { // From 4.5s to 9s
assert_approx_equals(rect.width.animVal.value, 165, epsilon);
assert_equals(rect.width.baseVal.value, 300);
}
function sample4() { // From 9s to 9s
assert_approx_equals(rect.width.animVal.value, 30, epsilon);
assert_equals(rect.width.baseVal.value, 300);
}
smil_async_test((t) => {
rect = rootSVGElement.ownerDocument.getElementsByTagName("rect")[0];
// Sampling according to: keyTimes="0;.25;.5;1" begin="0s" dur="9s"
const expectedValues = [
// [animationId, time, sampleCallback]
["an1", 0.0, sample1],
["an1", 2.249, sample2],
["an1", 2.251, sample2],
["an1", 4.499, sample3],
["an1", 4.501, sample3],
["an1", 8.999, sample4],
["an1", 9.001, sample4],
["an1", 60.0, sample4]
];
runAnimationTest(t, expectedValues);
});
window.animationStartsImmediately = true;
</script>
|