Reputation: 3674
I have created this scalable vector graphic.
<svg width="150" height="90" style="stroke: black;">
<rect width="40" height="90" style="fill:white;"></rect>
<polygon points="40,0 40,90 150,90 100,45 150,0" style="fill:blue;"/>
</svg>
I am aiming for the left hand side but the result returns the right hand side.
As you can see the vertical edges have wider strokes than the horizontal. Is this a defect of svg? Is there a way a can mitigate it to achieve a more consistent stroke.
Upvotes: 2
Views: 579
Reputation: 101918
The edges of your shape consincide with the ouside boundary of your SVG. Strokes are drawn so that half their width is on either side of the line.
So whats happening is that half of the top, left and bottom lines are cut off because they are outside of the SVG.
Some solutions would be:
viewBox
that is half the stroke width bigger than your shape. This will have the effect of scaling down your shape so that all the stroke is drawn.overflow="visible"
to your SVG so that that the parts of your shape that are outside the SVG are drawn, and not clipped (as suggested by @enxaneta)Upvotes: 4