I am Looping through my Images and try to put all in my canvas but I get this error:
My Html:
<div class="container-fluid">
    <canvas id="signature-canvas" class="signature-canvas"></canvas>
</div>
signatures.js:121 Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLImageElement or SVGImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap or OffscreenCanvas)' at Image.images.(anonymous function).onload (http://localhost/app/public/js/signatures.js:121:25)
my javascript
var canvasModule = {
    elements: {
        canvas: document.getElementById('signature-canvas')
    },
    render: function () {
        this.createImageOnCanvas();
    },
    getCanvasContext: function () {
        return this.elements.canvas.getContext('2d');
    },
    getCanvasWidth: function () {
        return this.elements.canvas.width;
    },
    getCanvasHeight: function () {
        return this.elements.canvas.height;
    },
    createImageOnCanvas: function () {
        var itemWidth = this.getCanvasWidth() / 7;
        var itemHeight = this.getCanvasHeight() / 3;
        var u = 0;
        var context = this.getCanvasContext();
        var images = [];
        var imagesWidth = [];
        var imagesHeight = [];
        for (var i = 1; i < 8; i++) {
            images[i] = new Image();
            images[i].src = 'images/sample/1'+i+'.png';
            imagesWidth[i] = images[i].width;
            imagesHeight[i] = images[i].height;
            images[i].onload = function () {
                context.drawImage(images[i], u, 0, itemWidth, itemHeight);
            }
            u = u + itemWidth;
        }
    }
}
$(document).ready(canvasModule.render());
 
    