Skip to content

Concave shapes are filled incorrectly #30

@xTibor

Description

@xTibor

When the turtle draws a concave shape with Turtle::begin_fill and Turtle::end_fill the fill color bleeds out of the bounds of the shape.

Build information:
rustc -V: rustc 1.23.0-nightly (827cb0d61 2017-11-26)
turtle: b3d0ef0
Host: KDE neon 5.11 (Ubuntu 16.04 LTS)

Screenshot:
screenshot_20171129_192821

Reproduction:

extern crate turtle;
use turtle::Turtle;

fn star(turtle: &mut Turtle, radius: f64, color: &str) {
    let side = radius * ((5.0 / 8.0) - (5.0f64.sqrt() / 8.0)).sqrt() * (5.0f64.sqrt() - 1.0);

    turtle.pen_up();
    turtle.forward(radius);
    turtle.right(162.0);

    turtle.set_pen_color("black");
    turtle.set_fill_color(color);
    turtle.pen_down();
    turtle.begin_fill();
    for _ in 0..5 {
        turtle.forward(side);
        turtle.left(72.0);
        turtle.forward(side);
        turtle.right(144.0);
    }
    turtle.end_fill();

    turtle.pen_up();
    turtle.left(162.0);
    turtle.backward(radius);
}

fn main() {
    let mut turtle = Turtle::new();
    star(&mut turtle, 200.0, "yellow");
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions