Drawing a modified SVG to a canvas

后端 未结 2 687
自闭症患者
自闭症患者 2021-01-06 18:50

I want to load an SVG image, do some manipulations to its .contentDocument, and then draw it to a canvas.

A good example for drawing an SVG to a canvas

2条回答
  •  不要未来只要你来
    2021-01-06 19:17

    Convert the svg's xml content into string data, then make a data uri out of it. You should be able to load that as an image. Something like this:

    new Image("data:image/svg+xml," + svgdata);
    

    Now you should be able to draw it to the canvas.

提交回复
热议问题