Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

draw image onto canvas js

<body>
<canvas id = "my_canvas"></canvas>
<script>
function setup(){
    var canvas = document.getElementById('my_canvas');
    var ctx = canvas.getContext('2d');
    canvas.width = 800;
    canvas.height = 600;
    var image = new Image();
    image.src = 'a.png';
    ctx.drawImage(image,5,5);
};
window.onload = setup;
setup();

</script>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #draw #image #canvas #js
ADD COMMENT
Topic
Name
5+3 =