Skip to content

context.js strokeRect has an off by one error. #212

@jchristoffvisionary

Description

@jchristoffvisionary

strokeRect(x, y, w, h) {
for (let i = x; i < x + w; i++) {
this.fillPixelWithColor(i, y, this.calculateRGBA_stroke(i, y));
console.log("calculated: " + this.calculateRGBA_stroke(i, y) );
this.fillPixelWithColor(i, y + h, this.calculateRGBA_stroke(i, y + h));
console.log("calculated: " + i + " " + (y + h));

    }
    for (let j = y; j < y + h; j++) {
        this.fillPixelWithColor(x, j, this.calculateRGBA_stroke(x, j));
        this.fillPixelWithColor(x + w, j, this.calculateRGBA_stroke(x + w, j));
    }
}

The second for loop needs to have for (let j = y; j <= y + h; j++) otherwise the lower right most pixel does not get painted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions