Home > Article > Web Front-end > Draw SVG files on HTML5 canvas
To draw HTMLImageElements on a canvas element, use the drawImage() method. This method defines an Image variable using src="mySVG.svg" and uses drawImage when loading.
var myImg = new Image(); myImg.onload = function() { ctx.drawImage(myImg, 0, 0); } img.src = "http://www.example.com/files/sample.svg ";
The above is the detailed content of Draw SVG files on HTML5 canvas. For more information, please follow other related articles on the PHP Chinese website!