LoginSignup
0
0

More than 3 years have passed since last update.

画像表示

Posted at

連番の画像を一括で表示したいのですが
以下のコードでは1つしか表示されません。
このコードの間違えがわかりません。

教えてください。

filename.rb
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>表示</title>
    </head>
    <body>
        <canvas width="10000" height="22000">
            Canvas対応ブラウザを使用して下さい
        </canvas>
    </body>
</html>

<script>

let xx = 1;
let yy = 1;

for (yy=1; yy<=5; yy++) {
    window.addEventListener("load", function(){
    // Canvas要素を読み出し
    var myCanvas = document.getElementsByTagName("canvas")[0];
    // コンテキストを取得
    var context = myCanvas.getContext("2d");
    if (!context){ return; }
    // 画像を描画する
    var Imageyy = new Image();
    Imageyy.src = 'Image_01_0'+yy+'.jpg';
    Imageyy.onload = function(){
        // 座標とサイズを指定して描画
        context.drawImage(Imageyy, yy*500, 0,500,700);
    }

}, false);

}
</script>

0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0