What is the difference between SVG and HTML5 Canvas?

前端 未结 10 2077
误落风尘
误落风尘 2020-11-30 18:08

What are the differences between SVG and HTML5 Canvas? They both seem to do the same to me. Basically, they both draw vector artwork using coordinate points.

What am

10条回答
  •  無奈伤痛
    2020-11-30 18:48

    High Level Summary of Canvas vs. SVG

    Canvas

    1. Pixel based (Dynamic .png)
    2. Single HTML element.(Inspect element in Developer tool. You can see only canvas tag)
    3. Modified through script only
    4. Event model/user interaction is granular (x,y)
    5. Performance is better with smaller surface, a larger number of objects (>10k), or both

    SVG

    1. Shape based
    2. Multiple graphical elements, which become part of the DOM
    3. Modified through script and CSS
    4. Event model/user interaction is abstracted (rect, path)
    5. Performance is better with smaller number of objects (<10k), a larger surface, or both

    For detailed difference, read http://msdn.microsoft.com/en-us/library/ie/gg193983(v=vs.85).aspx

提交回复
热议问题