+ 3

SVG vs Canvas graphics. Why canvas when you have SVG?

I've been pondering over this for sometime now 🤔. If SVG Graphics are scalable infinitely without loss in resolution and don't need JavaScript, why is there even canvas? I mean, canvas graphics pixel based, which makes them resolution-dependent, while it's the vice versa for SVG. In what way is Canvas graphics better than SVG Graphics 😐? I'm curious! Waiting for your answer! Upvote Discussion!! Oh! And by the way, an SVG code of mine! Leave an upvote! Thanx! https://code.sololearn.com/WRj9kS2bPsT3/?ref=app

23rd May 2018, 11:33 AM
Siddharth
Siddharth - avatar
5 Respuestas
+ 6
It depends on the main purpose for example … if you need to paint pixels to the screen and have concerns about the ability to retrieve and modify yo shapes, canvas is probably the better choice. If, on the other hand, you need to be able to access and chang specific aspects of your graphics, SVG might be more appropriate.
23rd May 2018, 12:14 PM
Andrew Watts
Andrew Watts - avatar
+ 3
SVG is a language for describing 2D graphics in XML. Canvas draws 2D graphics, on the fly (with a JavaScript). SVG is XML based, which means that every element is available within the SVG DOM. ... In canvas, once the graphic is drawn, it is forgotten by the browser.
23rd May 2018, 12:03 PM
Andrew Watts
Andrew Watts - avatar
+ 3
Alright, but how is Canvas better than SVG, is my main question here.
23rd May 2018, 12:05 PM
Siddharth
Siddharth - avatar
+ 2
Based on the HTML tutorial available, canvas is more suitable for graphic-intensive games than svg: https://www.sololearn.com/learn/HTML/2202/
23rd May 2018, 1:05 PM
Hanz
Hanz - avatar
+ 1
I prefer the Canvas, because I learned making "games" with it. Like the getContext("2d") and things like that. I started with it, so naturally it seems easier to me.
23rd May 2018, 8:44 PM
Paul Grasser
Paul Grasser - avatar