JSFiddle - React, Tailwind, and code Playground

by Jack 0

HTML

<p id="center">
</p>


<hr>

    
    <canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3;">
</canvas>

JavaScript

var img = document.createElement("img");
img.src = "http://xjlin0.github.io/blog/imgs/shipb.gif";
document.getElementById("center").appendChild(img);



var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
ctx.drawImage(img, 100, 10);

function animate(){
  ctx.translate(-100, 10);
};

window.setInterval(animate, 100);