dynamic-mask-01.svg 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <!--
  2. Any copyright is dedicated to the Public Domain.
  3. http://creativecommons.org/publicdomain/zero/1.0/
  4. -->
  5. <svg xmlns="http://www.w3.org/2000/svg" version="1.1"
  6. class="reftest-wait"
  7. onload="startTest()"
  8. xmlns:xlink="http://www.w3.org/1999/xlink">
  9. <title>Testing that dynamic changes to mask attributes are reflected in the mask</title>
  10. <defs>
  11. <mask id="mask1" width="1" height="1">
  12. <rect width="1" height="1" fill="white"/>
  13. </mask>
  14. <mask id="mask2" width="1" height="1">
  15. <rect width="1" height="1" fill="white"/>
  16. </mask>
  17. <mask id="mask3" width="1" height="1">
  18. <rect width="1" height="1" fill="white"/>
  19. </mask>
  20. </defs>
  21. <rect width="100%" height="100%" fill="lime"/>
  22. <g transform="scale(500)">
  23. <rect x=".2" y=".2" width=".2" height=".2" fill="red" mask="url(#mask1)"/>
  24. <rect x=".4" y=".2" width=".2" height=".2" fill="red" mask="url(#mask2)"/>
  25. <rect x=".2" y=".4" width=".2" height=".2" fill="red" mask="url(#mask3)" />
  26. </g>
  27. <script>
  28. function startTest() {
  29. document.addEventListener("MozReftestInvalidate", doTest, false);
  30. setTimeout(doTest, 4000); // fallback for running outside reftest
  31. }
  32. function doTest() {
  33. var mask1 = document.getElementById("mask1");
  34. mask1.width.baseVal.value = 0;
  35. var mask2 = document.getElementById("mask2");
  36. mask2.height.baseVal.value = 0;
  37. var mask3 = document.getElementById("mask3");
  38. mask3.maskUnits.baseVal = SVGUnitTypes.SVG_UNIT_TYPE_USERSPACEONUSE;
  39. document.documentElement.removeAttribute("class");
  40. }
  41. </script>
  42. </svg>