Let's say I want to draw a sqare in svg which has a diagonal of 1. That means the edges of the square would have a length of a = 1/sqrt(2)
. The coordinates of the square's vertices then would be: (0,0)
, (0,a)
, (a,0)
and (a,a)
. Of course I could approximate a
with a decimal number and use this number. But what if I want the vertices to be mathematically precise, for example because I want them to be exactly on some line I know to go through the intended point?
I'm totally new to SVG. I was reading up on transformations here, hoping to get some pointers, but it got me confused.
Does anyone know if this can be done and if so, how?
SVG doesn't support anything like that.
But you'll get pretty good precision from a floating point approximation. There won't be very many scenarios where you'll see the errors once the SVG is rendered, unless you are magnifying it a lot.
If the svg is embedded in web page - and if you are noticing errors under high magnification - you could consider modifying the SVG dynamically with JavaScript, rather than applying SVG transforms.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With