jrmuizel / raqote

Rust 2D graphics library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gradients padded with min or max lut color instead of first and last stop color

jrmuizel opened this issue · comments

e.g.

fn main() {
    let mut dt = DrawTarget::new(200, 200);
    
    let gradient = Source::new_linear_gradient(
        Gradient {
            stops: vec![
                GradientStop {
                    position: 0.0,
                    color: 0xffffffff,
                },
                GradientStop {
                    position: 0.001,
                    color: 0xff000000,
                },
                GradientStop {
                    position: 1.0,
                    color: 0xff000000,
                },
            ],
        },
        Point::new(40., 0.),
        Point::new(100., 0.),
        Spread::Pad,
    );

    let mut pb = PathBuilder::new();
    pb.rect(0., 0., 80., 80.);
    let path = pb.finish();
    dt.fill(&path, &gradient, &DrawOptions::default());

    dt.write_png("out.png").unwrap();
}

This should probably draw a half white half black square. It currently draws all black.