I was making a game using HTML5 canvas. Halfway through making my game, I decided to change my game sprite into a spaceship. But as I soon learned, you need to have an image tag to use the c.drawImage function and I did not want to include an image tag in my HTML because it would ruin the margin and padding around my game and I did not want random image dotted around my game just to use a new sprite.
const canvas = document.getElementById("game")
let c = canvas.getContext("2d")
c.drawImage("https://heckapix.com/images/spaceship-clipart-with-background.jpg", 20, 20)
<canvas id="game"></canvas>
So is there a function to draw images from a link or is there a way to make the function work without making an image tag?