Quantcast
Channel: User spraff - Stack Overflow
Viewing all articles
Browse latest Browse all 55

Why is the image in my svg pattern not tiling?

$
0
0

Here's my test svg

<?xml version="1.0" encoding="UTF-8"?><svg version="1.1"  viewBox="-1 -1 2 2" width="100" height="100"  xmlns="http://www.w3.org/2000/svg"><defs><pattern id="img1" width="1" height="1"><image                href="file:///tmp/test.png"                patternUnits="userSpaceOnUse"                /></pattern></defs><polygon points="0.0,0.0 1,-1, 1,1" fill="url(#img1)" /></svg>

this is test.png, it is 2x2 pixels

enter image description here

The whole thing renders like this

enter image description here

I want the background test.png to tile infinitely in both directions, and I want to scale it.

My coordinate system for drawing is (0,0) at the centre to +/- 1 unit in the x and y directions. Ideally I can specify things relatively, e.g. if I scale the image to 5% then I expect it to repeat 20 times (1÷5%) across the whole image.

Initially I tried adding `width="50%" height="50%" and it renders like this

enter image description here

It seems to have shrunk as expected, but it doesn't seem to be repeating so most of it is disappearing to the left of the central (0,0) point. If I shrink the width and height percentages it progressively shrinks out of view to the top left, leaving the polygon empty.

Why isn't this tiling?


Viewing all articles
Browse latest Browse all 55

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>