Hi,
How can I pass a parameter to the function here? This script draws an image on the canvas. I would like to control the position of the image on the canvas using the paramater.
<canvas id="drawing" width="800" height="800"></canvas>
<script>
var canvas = document.getElementById("drawing");
var ctx = canvas.getContext("2d");
var canvas = document.getElementById('drawing');
var context = canvas.getContext('2d');
var imageObj = new Image();
imageObj.onload = function(x) {
context.drawImage(imageObj, x, 40, 100, 100);
};
imageObj.src = 'rocket.jpg';
</script>
I can do this in a simpler situation but not for this function i.e.
var fun = function(y){
console.log(y);
}
fun("tester");
Thanks