Drawing an SVG file on an HTML5 canvas

HTMLWeb DevelopmentFront End Technology

To drawHTMLImageElements on a canvas element, use the drawImage() method.This method defines an Image variable with src=”mySVG.svg”, anduse drawImage on load.

var myImg = new Image();
myImg.onload = function() {
   ctx.drawImage(myImg, 0, 0);
}
img.src = "http://www.example.com/files/sample.svg ";
raja
Published on 20-Mar-2018 11:32:53
Advertisements