5 ms·
Why would you draw the vector manually with canvas when the browser can do it (SVG)?
by iso8859-1 13y ago
Why would you draw the vector manually with canvas when the browser can do it (SVG)?
- tehwalrus 13y agoI suggested canvas because that's how I've generated programmatic images from my own "vector" formats (scientific datafiles,) and rendered them at arbitrary zoom. Generating the relevant shapes and lines for a simple logo would be easy this way, although probably would require a larger download vs. a vector image, since the canvas method would need to load extra javascript to duplicate the SVG support built in to the browser. I'm not saying it is necessarily a better idea, just that I've had more success with canvas drawing methods than trying to actually make a vector image.
- iso8859-1 13y agoMaking a vector image is piece of cake. The SVG syntax is a bit concise, but that's about it. See http://blogs.sitepointstatic.com/examples/tech/svg-curves/cubic-curve.html http://blogs.sitepointstatic.com/examples/tech/svg-curves/cu... . Regarding arbitrary zoom, it's just a matter of changing the viewbox: http://www.justinmccandless.com/blog/Making+Sense+of+SVG+viewBox's+Madness http://www.justinmccandless.com/blog/Making+Sense+of+SVG+vie... (it's no madness though) And you don't even have to redraw (that's the benefit of SVG, it has a scene graph unlike canvas). Remember, a vector image doesn't need to have any inherit width or height! In fact, if you don't specify it, the browser will resize the image so that the viewbox fills the browser viewport! Another advantage is that you can handle generated images as images, not as code, without converting them to raster bitmaps (which I guess you'd be forced to when when dumping the canvas).