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
|
<!DOCTYPE html>
<meta charset="UTF-8">
<style>
.container {
display: inline-block;
}
.parent {
stroke: blue;
}
.target {
fill: black;
stroke-width: 8px;
stroke: orange;
color: blue;
}
.expected {
fill: lime;
}
</style>
<body>
<template id="target-template">
<svg width="10" height="100">
<defs>
<linearGradient id="gradient" x1="0" x2="0" y1="0" y2="1">
<stop offset="0" stop-color="black"/>
<stop offset="1" stop-color="blue"/>
</linearGradient>
</defs>
<rect x="0" y="0" width="10" height="100"></rect>
</svg>
</template>
<script src="resources/interpolation-test.js"></script>
<script>
assertInterpolation({
property: 'stroke',
from: '',
to: 'green',
}, [
{at: -0.4, is: 'rgb(255, 180, 0)'},
{at: 0, is: 'rgb(255, 165, 0)'},
{at: 0.2, is: 'rgb(204, 158, 0)'},
{at: 0.6, is: 'rgb(102, 143, 0)'},
{at: 1, is: 'rgb(0, 128, 0)'},
{at: 1.5, is: 'rgb(0, 110, 0)'},
]);
assertNoInterpolation({
property: 'stroke',
from: 'initial',
to: 'green',
});
assertInterpolation({
property: 'stroke',
from: 'inherit',
to: 'green',
}, [
{at: -0.4, is: 'rgb(0, 0, 255)'},
{at: 0, is: 'rgb(0, 0, 255)'},
{at: 0.2, is: 'rgb(0, 26, 204)'},
{at: 0.6, is: 'rgb(0, 77, 102)'},
{at: 1, is: 'rgb(0, 128, 0)'},
{at: 1.5, is: 'rgb(0, 192, 0)'},
]);
assertInterpolation({
property: 'stroke',
from: 'unset',
to: 'green',
}, [
{at: -0.4, is: 'rgb(0, 0, 255)'},
{at: 0, is: 'rgb(0, 0, 255)'},
{at: 0.2, is: 'rgb(0, 26, 204)'},
{at: 0.6, is: 'rgb(0, 77, 102)'},
{at: 1, is: 'rgb(0, 128, 0)'},
{at: 1.5, is: 'rgb(0, 192, 0)'},
]);
assertInterpolation({
property: 'stroke',
from: 'orange',
to: 'blue'
}, [
{at: -0.4, is: '#ffe700'},
{at: 0, is: 'orange'},
{at: 0.2, is: '#cc8433'},
{at: 0.6, is: '#664299'},
{at: 1, is: 'blue'},
{at: 1.5, is: 'blue'}
]);
assertInterpolation({
property: 'stroke',
from: 'orange',
to: 'currentColor'
}, [
{at: 0, is: 'orange'},
{at: 0.2, is: '#cc8433'},
{at: 0.6, is: '#664299'},
{at: 1, is: 'blue'},
]);
assertInterpolation({
property: 'stroke',
from: 'currentColor',
to: 'orange'
}, [
{at: 0, is: 'blue'},
{at: 0.2, is: '#3321cc'},
{at: 0.6, is: '#996366'},
{at: 1, is: 'orange'},
]);
assertNoInterpolation({
property: 'stroke',
from: 'orange',
to: 'url(#gradient)'
});
</script>
</body>
|