How to use the canvas/graphics/LineStyle.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 / canvasgraphics / 07-ants4.js View on Github external
draw (i) {

        //  Red

        this.ctx.save();

        this.ctx.beginPath();

        Line(this.ctx, 12, 'round', 'round', [1, 32], this.offsetR);
        Rectangle(this.ctx, 32, 32, 256, 256);
        Stroke(this.ctx, 255, 0, 0, 0.5);

        this.ctx.closePath();

        this.ctx.restore();

        //  Green

        this.ctx.save();

        this.ctx.beginPath();

        Line(this.ctx, 12, 'round', 'round', [1, 32], this.offsetG);
        Rectangle(this.ctx, 32, 32, 256, 256);
        Stroke(this.ctx, 0, 255, 0, 0.5);
github photonstorm / lazer-dev / src / canvasgraphics / 02-lineWidth.js View on Github external
rect2 (ctx) {

        //  cap = butt, round or square
        //  join = bevel, round or miter

        ctx.save();

        ctx.beginPath();

        Line(ctx, 4, 'square', 'miter');
        Rectangle(ctx, 256, 32);
        Stroke(ctx, 255, 255, 0);

        ctx.closePath();

        ctx.restore();

    }
github photonstorm / lazer-dev / src / canvasgraphics / 02-lineWidth.js View on Github external
rect1 (ctx) {

        //  cap = butt, round or square
        //  join = bevel, round or miter

        ctx.save();

        ctx.beginPath();

        Line(ctx, 1, 'butt', 'miter'); // miter = crisp pixels at 1px line width stroke (+ see below)
        //  With a lineWidth of 1 (or any odd number) we need to -0.5 this to retain pixel clarity:
        Rectangle(ctx, 32-0.5, 32-0.5);
        Stroke(ctx, 255, 255, 0);

        ctx.closePath();

        ctx.restore();

    }
github photonstorm / lazer-dev / src / canvasgraphics / 02-lineWidth.js View on Github external
rect3 (ctx) {

        //  cap = butt, round or square
        //  join = bevel, round or miter

        ctx.save();

        ctx.beginPath();

        Line(ctx, 12, 'butt', 'bevel');
        Rectangle(ctx, 32, 256);
        Stroke(ctx, 255, 255, 0);

        ctx.closePath();

        ctx.restore();

    }
github photonstorm / lazer-dev / src / canvasgraphics / 03-lineDash.js View on Github external
rect4 (ctx) {

        //  cap = butt, round or square
        //  join = bevel, round or miter

        ctx.save();

        ctx.beginPath();

        Line(ctx, 12, 'round', 'round', [6, 24]);
        Rectangle(ctx, 256, 256);
        Stroke(ctx, 255, 255, 0);

        ctx.closePath();

        ctx.restore();

    }
github photonstorm / lazer-dev / src / canvasgraphics / 07-ants4.js View on Github external
Line(this.ctx, 12, 'round', 'round', [1, 32], this.offsetR);
        Rectangle(this.ctx, 32, 32, 256, 256);
        Stroke(this.ctx, 255, 0, 0, 0.5);

        this.ctx.closePath();

        this.ctx.restore();

        //  Green

        this.ctx.save();

        this.ctx.beginPath();

        Line(this.ctx, 12, 'round', 'round', [1, 32], this.offsetG);
        Rectangle(this.ctx, 32, 32, 256, 256);
        Stroke(this.ctx, 0, 255, 0, 0.5);

        this.ctx.closePath();

        this.ctx.restore();

        //  Blue

        this.ctx.save();

        this.ctx.beginPath();

        Line(this.ctx, 12, 'round', 'round', [1, 32], this.offsetB);
        Rectangle(this.ctx, 32, 32, 256, 256);
        Stroke(this.ctx, 0, 0, 255, 0.5);
github photonstorm / lazer-dev / src / canvasgraphics / 07-ants4.js View on Github external
Line(this.ctx, 12, 'round', 'round', [1, 32], this.offsetG);
        Rectangle(this.ctx, 32, 32, 256, 256);
        Stroke(this.ctx, 0, 255, 0, 0.5);

        this.ctx.closePath();

        this.ctx.restore();

        //  Blue

        this.ctx.save();

        this.ctx.beginPath();

        Line(this.ctx, 12, 'round', 'round', [1, 32], this.offsetB);
        Rectangle(this.ctx, 32, 32, 256, 256);
        Stroke(this.ctx, 0, 0, 255, 0.5);

        this.ctx.closePath();

        this.ctx.restore();

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

        this.ctx.save();

        this.ctx.beginPath();

        Line(this.ctx, 12, 'round', 'round', [18, 32], this.offset);
        Rectangle(this.ctx, 32, 32, 256, 256);
        Stroke(this.ctx, 255, 255, 0);

        this.ctx.closePath();

        this.ctx.restore();

    }