Reputation: 585
I use the ctx.drawImage(image, dx, dy);
method for drawing a svg to my canvas.
Right now I get the SVG from the DOM and convert it to a base64 string to use it as img.src = "convertetsvg"
after the img.onload()
Is there a way to use the SVG from the DOM as the actual image?
In this small example something like image = this._$svgElement[0]
(This is what i aim for but I don't know how to do it or if it is even possible.) I know that the drawImage
accepts SVGImageElement
but I think that this is not the same as the <svg>
from the DOM?
Upvotes: 0
Views: 369
Reputation: 21821
No, there is no interface to render a DOM document to the canvas. You must state an image source.
SVGImageElement
is the interface of the <image>
element that you can use inside SVG content to reference an external image, just the same as you use the <img>
tag in HTML.
Upvotes: 1