We can import external images in an HTML5 canvas element, or simply draw an image using JavaScript code . To import an image from a specified location use this Javascript
var importImg = new Image();
importImg.onload = function(){
cont.drawImage(importImg, 10, 10);
};
importImg.src = "pictures/imagefile.jpg";
This code creates an image object, and specifies what should happen when the image source is loaded. The code sets the "src" source of the image so that it reflects the location and the file name of the imported image. The "onload" function will be run when the image is successfully loaded into the browser, and the code within it will instruct the browser to draw the image source in the canvas element.
HTML5 Canvas Images
We can import external images in an HTML5 canvas element, or simply draw an image using JavaScript code...
html5 canvas images
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users