How to use the canvas/graphics/Stroke.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 / 04-ants.js View on Github external
draw (i) {

        this.ctx.save();

        this.ctx.beginPath();

        Line(this.ctx, 1, 'butt', 'miter', [5, 5], this.offset); // 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(this.ctx, 32-0.5, 32-0.5);
        Stroke(this.ctx, 255, 255, 0);

        this.ctx.closePath();

        this.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
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);

        this.ctx.closePath();
github photonstorm / lazer-dev / src / canvasgraphics / 10-rectRotate.js View on Github external
draw (i) {

        this.ctx.save();

        this.ctx.beginPath();

        Line(this.ctx, 2);

        //  Rotate from center
        Rectangle(this.ctx, 256, 256, 128, 128, DegToRad(this.angle), true);

        Stroke(this.ctx, 255, 255, 0);

        this.ctx.closePath();

        this.ctx.restore();

    }
github photonstorm / lazer-dev / src / canvasgraphics / 07-ants4.js View on Github external
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 / 03-lineDash.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', [4, 8]);
        Rectangle(ctx, 256, 32);
        Stroke(ctx, 255, 255, 0);

        ctx.closePath();

        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();

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

        this.ctx.save();

        this.ctx.beginPath();

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

        this.ctx.closePath();

        this.ctx.restore();

    }