1 description("Test ColorMatrixType enumeration animations");
5 var defs
= createSVGElement("defs");
6 rootSVGElement
.appendChild(defs
);
8 var colorMatrix
= createSVGElement("feColorMatrix");
9 colorMatrix
.setAttribute("in", "SourceGraphic");
10 colorMatrix
.setAttribute("type", "matrix");
12 var filter
= createSVGElement("filter");
13 filter
.setAttribute("id", "filter");
14 filter
.setAttribute("filterUnits", "userSpaceOnUse");
15 filter
.setAttribute("x", "0");
16 filter
.setAttribute("y", "0");
17 filter
.setAttribute("width", "700");
18 filter
.setAttribute("height", "200");
19 filter
.appendChild(colorMatrix
);
20 defs
.appendChild(filter
);
22 var rect
= createSVGElement("rect");
23 rect
.setAttribute("id", "rect");
24 rect
.setAttribute("width", "100");
25 rect
.setAttribute("height", "100");
26 rect
.setAttribute("fill", "#408067");
27 rect
.setAttribute("filter", "url(#filter)");
28 rect
.setAttribute("onclick", "executeTest()");
29 rootSVGElement
.appendChild(rect
);
31 var animate
= createSVGElement("animate");
32 animate
.setAttribute("id", "animation");
33 animate
.setAttribute("attributeName", "type");
34 animate
.setAttribute("begin", "rect.click");
35 animate
.setAttribute("dur", "4s");
36 animate
.setAttribute("values", "matrix;saturate;hueRotate;luminanceToAlpha");
37 colorMatrix
.appendChild(animate
);
39 // Setup animation test
41 shouldBe("colorMatrix.type.animVal", "SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_MATRIX");
42 shouldBe("colorMatrix.type.baseVal", "SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_MATRIX");
46 shouldBe("colorMatrix.type.animVal", "SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_SATURATE");
47 shouldBe("colorMatrix.type.baseVal", "SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_MATRIX");
51 shouldBe("colorMatrix.type.animVal", "SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_HUEROTATE");
52 shouldBe("colorMatrix.type.baseVal", "SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_MATRIX");
56 shouldBe("colorMatrix.type.animVal", "SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA");
57 shouldBe("colorMatrix.type.baseVal", "SVGFEColorMatrixElement.SVG_FECOLORMATRIX_TYPE_MATRIX");
60 function executeTest() {
61 const expectedValues
= [
62 // [animationId, time, sampleCallback]
63 ["animation", 0.0, sample1
],
64 ["animation", 0.999, sample1
],
65 ["animation", 1.001, sample2
],
66 ["animation", 1.999, sample2
],
67 ["animation", 2.001, sample3
],
68 ["animation", 2.999, sample3
],
69 ["animation", 3.001, sample4
],
70 ["animation", 3.999, sample4
],
71 ["animation", 4.001, sample1
]
74 runAnimationTest(expectedValues
);
77 var successfullyParsed
= true;