code:
<!DOCTYPE html>
<html>
<head>
<title>hehe</title>
</head>
<body>
<p>Image:</p>
<img id="pic" src="../1.png" alt="pic" width="200" height="200">
<p>Canvas:</p>
<canvas id="myCanvas" width="3000" height="1300" style="border:1px solid red;">
您的浏览器不支持 HTML5 canvas 标签。</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var img=document.getElementById("pic");
img.onload = function() {
for (var i=0;i<10;i++) {
ctx.drawImage(img,300*i,30*i);
}
}
</script>
</body>
</html>
result: