I had previously posted creating an image mask to prepare a tiled object.
Something similar can be done with svg, without creating the masking image, which I will post in the future.
This post describes the start of the procedure, with the creation a path as a clipPath.
This is the original image:
and this is the image clipped by a path:
Here is the code:
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head profile=”http://gmpg.org/xfn/11″>
<title>svg test</title>
<style>
body {margin-left:0;margin-right:0;font:normal normal normal 15px Arial;}
a{ text-decoration: }:link { color: rgb(0, 0, 255) }:visited {color :rgb(100, 0,100) }:hover { }:active { }
table{position: absolute; left: 20px; top: 5px}
input{width: 70px; text-align: center}
#svg1{position: absolute; width: 100%; height: 100%; top: 50px;}
#svg2{position: absolute; width: 100%; height: 100%; top: 50px; filter:contrast(100%) saturate(100%)}
#img1{}
</style>
</head>
<body>
<svg id=”svg2″ xmlns=”http://www.w3.org/2000/svg” version=”1.1″>
<defs>
<clipPath id=”pathMask” >
<path
d=”M 12.42,308.00
C 12.42,308.00 16.72,293.00 16.72,293.00
16.72,293.00 20.27,269.00 20.27,269.00
20.27,269.00 28.28,212.00 28.28,212.00
28.28,212.00 37.00,168.00 37.00,168.00
37.00,168.00 46.92,106.00 46.92,106.00
48.23,101.11 50.57,96.62 52.58,92.00
52.58,92.00 61.37,72.00 61.37,72.00
61.37,72.00 78.51,46.00 78.51,46.00
86.36,35.89 104.79,15.74 116.00,10.29
116.00,10.29 131.00,6.12 131.00,6.12
131.00,6.12 151.00,1.21 151.00,1.21
151.00,1.21 165.00,2.85 165.00,2.85
180.87,4.75 187.64,6.34 203.00,10.71
210.38,12.81 232.50,21.44 237.91,25.64
241.40,28.34 250.96,42.63 253.55,47.00
253.55,47.00 259.26,59.00 259.26,59.00
265.54,71.98 273.98,92.17 277.52,106.00
277.52,106.00 282.00,128.00 282.00,128.00
282.00,128.00 286.82,162.00 286.82,162.00
286.82,162.00 280.30,203.00 280.30,203.00
279.08,207.46 274.56,213.88 271.95,218.00
271.95,218.00 254.69,246.00 254.69,246.00
251.97,251.25 251.71,257.25 250.75,263.00
248.59,275.96 247.85,275.66 248.92,289.00
249.24,293.05 249.49,297.08 250.71,301.00
252.52,306.83 260.57,313.57 265.00,318.00
265.00,318.00 279.00,331.72 279.00,331.72
279.00,331.72 302.00,352.00 302.00,352.00
302.00,352.00 0.00,352.00 0.00,352.00
0.00,352.00 12.42,308.00 12.42,308.00 Z” />
</clipPath>
</defs>
<image id=”img2″x=”0″ y=”0″ xlink:href=”SAG.png” style=”clip-path: url(#pathMask)” />
</svg>
</body></html>
A SVG element is created with a clipPath placed withing a tag.
<svg id=”svg2″ xmlns=”http://www.w3.org/2000/svg” version=”1.1″>
<defs>
<clipPath id=”pathMask” >
<path
This is then used to clip an image placed in the SVG:
<image id=”img2″x=”0″ y=”0″ xlink:href=”SAG.png” style=”clip-path: url(#pathMask)” />
The path was obtained by selecting the object from the image using GIMP, converting the image to a path and exporting the path.
In the future I will describe a HTML app I wrote that can create a path from an image without an external graphics application.