There's lots of stuff out there comparing the HTML elements SVG and Canvas, but I'm still a little confused.
I'm looking for a way to draw an arbitrary shape (like, I have a description of a shape, in coordinates, or in lines and circles, etc.). I want to be able to generate the shape with Javascript (taking inputs from the user, e.g. measurements) and draw the shape I calculated onto an area of the web page.
I currently do this with a <canvas>
, by using .moveTo
and .lineTo
. It gives me the shape I want, but I would love to have the benefits of Scalable Vector Graphics, where it doesn't lose quality when re-sized, and the individual pieces of the shape are more accessible (rather than just being pixels in the canvas, they are each an object I can interact with: modify, register listeners on, etc.)
Is SVG something I can easily manipulate in Javascript, the way one can in a HTML5 Canvas?