I'm currently working on a project that is using the HTML5 Canvas API and I'm encountering a few problems, one of which is disappearing opacity masks used to add texture to an element in Adobe Illustrator.
To be clear, in Illustrator with the transparency menu open I do the following:
Copy image that I want to mask to clipboard
Select shape to use as mask
Click Make Mask
Click black square and paste image from clipboard
Now I select the artwork and export the selection from the file menu.
The resulting svg file can be opened with a browser and renders correctly including the opacity mask, however, if I try to paint this svg file on the canvas via JavaScript and the HTML5 Canvas API anything that is an opacity mask is missing from the rendered image.
Here is an example image from the browser rendered (file opened with) svg file:
The door shape with wood effect is the opacity mask;
This is the svg file:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="203" height="257" viewBox="0 0 203 257"><defs><filter id="luminosity-invert" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feColorMatrix values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0"/></filter><mask id="mask" x="15" y="17" width="180" height="260" maskUnits="userSpaceOnUse"><g style="filter:url(#luminosity-invert)"><image width="1920" height="1280" transform="translate(15 17) scale(0.09 0.2)" xlink:href="../../../../Adobe/distressed%20textures/free-templates/9%20Wood%20Textures/Texture1.jpg"/></g></mask></defs><title>opacity-mask</title><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><g style="mask:url(#mask)"><path d="M19.5,255.5V92.5s11-59,83-59,71,54,71,54v169Z" style="fill:#42210b;stroke:#000;stroke-miterlimit:10"/></g><rect x="0.5" y="0.5" width="202" height="16" style="fill:#42210b;stroke:#000;stroke-miterlimit:10"/></g></g></svg>
Now when I try to include this image programmatically on the HTML Canvas the opacity mask is missing and all I get is the solid brown bar (added to test) at the top.
I could paste some code to show this but, the problem is not in code but an underlying problem with rendering opacity masks, for example, if I import the svg file into vectr.com, I experience the same problem.
Does anyone have a clue how to resolve this, I'm flummoxed!
Thanks in advance if you can help.