Skip to content

Circle or ellipse stroke and fill slightly different pixels #2

@ljbade

Description

@ljbade

If you try to draw a filled circle or ellipse over a stroked version with the same dimensions like:

    graphics.draw_circle(
        Circle::new((BUFFER_WIDTH / 2, BUFFER_HEIGHT / 2), 100),
        stroke(RED),
    );
    graphics.draw_circle(
        Circle::new((BUFFER_WIDTH / 2, BUFFER_HEIGHT / 2), 100),
        fill(GREEN),
    );

Then I would expect to see no red pixels if the fill covers the same pixels that the stroke outlines.

However instead I see some red pixels:
Image

I think the problem is that you need to add a half pixel offset when calculating if a a pixel's midpoint is inside the circle.

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