I want to have a textbox which a user can paste an image URL into and an enter button which, upon clicking, will draw the image on the canvas. This is my canvas and textbox/enter button.
<body>
<input type="text" id="input"/><input type="button" value="Enter" onclick="useImage()">
<canvas id="canvas" width="600" height="400" style="border:1px solid grey;">
</body>
Then I know I should have a function in my javascript which allows this and references the canvas:
<script>
function useImage(){
var c = document.getElementById("canvas");
var ctx = c.getContext("2d"); //WHAT GOES IN HERE?
ctx.drawImage(img,0,0,600,400);
</script>
But I'm not sure how to make my function work, can anybody help please? I want the image to fill the whole canvas which is 600x400.