Jump to content

  • Free consultations and support
  • Live chatClick Here for Live Chat
  • Call ico 1888-906-1888
    Phone support: Open

    Ready for your call :)

    Our business hours:

    Mon — Fri, 2am — 8pm (EST)

    US & EU support teams

    Phone support: Closed

    We are back in: 1h 20m

    Our business hours:

    Mon — Fri, 2am — 8pm (EST)

    US & EU support teams


HTML5 Canvas Images

html5 canvas images

  • Please log in to reply
 

#1 OneDes

OneDes

    Senior Member

  • Designer
  • 282 posts

Posted 29 December 2012 - 04:29 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users