Prev Demo
Canvas Background Image
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Canvas background image</title> </head> <body> <h2 style="color:red"><i>Canvas background images</i></h2> <canvas id="canvas" width="400" height="400" style="border:2px solid green;background-color:pink"></canvas> <script> var canvas = document.getElementById("canvas"), context = canvas.getContext("2d"); var background = new Image(); background.src = "http://techfunda.com/HTPictures/Generics/4-635791814942223169.png"; background.onload = function () { context.drawImage(background, 90, 50); } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output