blob: 8f89b6abc16a2d5021b9a0cd8bc040d64572a364 [file] [log] [blame]
<!DOCTYPE html>
<meta charset="UTF-8">
<style>
.container {
display: inline-block;
margin-right: 1px;
}
.parent {
fill: blue;
}
.target {
color: blue;
stroke-width: 10px;
stroke: black;
fill: orange;
}
.expected {
stroke: green;
}
</style>
<body>
<template id="target-template">
<svg width="40" height="40">
<defs>
<linearGradient id="gradient">
<stop offset="0" stop-color="green"/>
<stop offset="1" stop-color="gold"/>
</linearGradient>
</defs>
<rect x="0" y="0" width="40" height="40" class="target"></rect>
</svg>
</template>
<script src="resources/interpolation-test.js"></script>
<script>
assertInterpolation({
property: 'fill',
from: neutralKeyframe,
to: 'green',
}, [
{at: -5, is: 'rgb(255, 255, 0)'},
{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)'},
]);
assertInterpolation({
property: 'fill',
from: 'initial',
to: 'green',
}, [
{at: -5, is: 'rgb(0, 0, 0)'},
{at: -0.4, is: 'rgb(0, 0, 0)'},
{at: 0, is: 'rgb(0, 0, 0)'},
{at: 0.2, is: 'rgb(0, 26, 0)'},
{at: 0.6, is: 'rgb(0, 77, 0)'},
{at: 1, is: 'rgb(0, 128, 0)'},
{at: 1.5, is: 'rgb(0, 192, 0)'},
]);
assertInterpolation({
property: 'fill',
from: 'inherit',
to: 'green',
}, [
{at: -5, is: 'rgb(0, 0, 255)'},
{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: 'fill',
from: 'unset',
to: 'green',
}, [
{at: -5, is: 'rgb(0, 0, 255)'},
{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: 'fill',
from: 'orange',
to: 'blue',
}, [
{at: -5, is: '#ffff00'},
{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: 'fill',
from: 'orange',
to: 'currentColor',
}, [
{at: 0, is: 'orange'},
{at: 0.2, is: '#cc8433'},
{at: 0.6, is: '#664299'},
{at: 1, is: 'blue'},
]);
assertInterpolation({
property: 'fill',
from: 'currentColor',
to: 'orange',
}, [
{at: 0, is: 'blue'},
{at: 0.2, is: '#3321cc'},
{at: 0.6, is: '#996366'},
{at: 1, is: 'orange'},
]);
assertNoInterpolation({
property: 'fill',
from: 'orange',
to: 'url(#gradient)',
});
</script>
</body>