Canvas | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Canvas

How to add image in canvas

24th Jan 2019, 3:51 AM
Praveen Lakra
Praveen Lakra - avatar
1 Answer
+ 1
Try this: var img = new Image(); img.onload = function() { context.drawImage(img, x, y); }; img.src = "example.jpg"; The x and y coordinates are where to insert the image, "example.jpg" is a link to the image.
24th Jan 2019, 4:56 AM
Игорь Яковенко
Игорь Яковенко - avatar