Computer Science, asked by MYHEROtimes, 4 months ago

Write a Javascript code to draw a image named "img.png" on a canvas at coordinates 112,132

Answer if you know.
Don't spam ​

Answers

Answered by Mister360
2

Code:-

var myCanvas = document.getElementById("myCanvas"),

ctx = null;

// Check for support - Feature Support and not Browser Support

if ( myCanvas.getContext) {

// Getting the context future 3d ^_^

ctx = myCanvas.getContext("2d");

var googleLogo = new Image();

googleLogo.src = 'img.png';

googleLogo.onload = function(){

// Adding our image..

ctx.drawImage(googleLogo,0,0); // drawImage(image object,x,y)

};

}else{

alert("You don`t have support in CANVAS !");

}

Similar questions