How to use the canvas/DrawImage.js function in canvas

To help you get started, we’ve selected a few canvas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github photonstorm / lazer-dev / src / canvas / canvas21-drawImage2.js View on Github external
loadComplete (file) {

        const ctx = GetContext(this.canvas);

        Fill(ctx, 120, 0, 120);

        //  Draw the image at 400x300
        // DrawImage(ctx, file.data, { x: 400, y: 300 });

        //  Draw the image at 400x300 centered (anchor 0.5)
        DrawImage(ctx, file.data, { x: 400, y: 300, anchorX: 0.5, anchorY: 0.5 });

    }
github photonstorm / lazer-dev / src / transform2d / 09-scaleX.js View on Github external
draw (i) {

        DrawImage(this.ctx, this.image, { x: this.sprite1.x, y: this.sprite1.y, rotate: this.sprite1.rotation, scaleX: this.sprite1.scaleX, scaleY: this.sprite1.scaleY, anchorX: 0.5, anchorY: 0.5 });

    }
github photonstorm / lazer-dev / src / canvas / canvas21-drawImage7.js View on Github external
Smoothing.disable(ctx);

        Fill(ctx, 120, 0, 120);

        DrawImage(ctx, file.data, { 
            x: 200, y: 200, 
            scaleX: 2, scaleY: 2
        });

        DrawImage(ctx, file.data, { 
            x: 350, y: 200, 
            scaleX: 2, scaleY: 2,
            blendMode: 'lighter'
        });

        DrawImage(ctx, file.data, { 
            x: 500, y: 200, 
            scaleX: 2, scaleY: 2,
            blendMode: 'overlay'
        });

    }
github photonstorm / lazer-dev / src / canvas / canvas21-drawImage5.js View on Github external
loadComplete (file) {

        const ctx = GetContext(this.canvas);

        Smoothing.disable(ctx);

        Fill(ctx, 120, 0, 120);

        DrawImage(ctx, file.data, { 
            x: 400, y: 300, 
            width: 16,
            anchorX: 0.5, anchorY: 0.5, 
            scaleX: 4, scaleY: 4, 
            rotate: DegToRad(45) 
        });

    }
github photonstorm / lazer-dev / src / transform2d / 04-rotate.js View on Github external
draw (i) {

        DrawImage(this.ctx, this.image, { x: this.sprite1.x, y: this.sprite1.y, rotate: this.sprite1.rotation, anchorX: 0.5, anchorY: 0.5 });

    }
github photonstorm / lazer-dev / src / transform2d / 05-scale.js View on Github external
draw (i) {

        DrawImage(this.ctx, this.image, { x: this.sprite1.x, y: this.sprite1.y, rotate: this.sprite1.rotation, scaleX: this.sprite1.scaleX, scaleY: this.sprite1.scaleY, anchorX: 0.5, anchorY: 0.5 });

    }
github photonstorm / lazer-dev / src / fx / 06-starfield2d-pattern.js View on Github external
drawStar (layer, x, y) {
        
        DrawImage(this.ctx, this.image, { x, y });

    }