jrmuizel / raqote

Rust 2D graphics library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Panics on a LinearGradient with a position outside a 0..1 range

RazrFalcon opened this issue · comments

use raqote::*;

fn main() {
    let mut dt = DrawTarget::new(400, 400);

    let mut pb = PathBuilder::new();
    pb.move_to(200., 200.);
    pb.line_to(300., 300.);
    pb.line_to(200., 300.);

    let path = pb.finish();

    let gradient = Source::LinearGradient(
        Gradient {
            stops: vec![
                GradientStop {
                    position: -1.0, // +1.2 works too
                    color: Color::new(0xff, 0x00, 0xff, 0x00),
                },
            ],
        },
        Spread::Pad,
        Transform::default(),
    );
    dt.fill(&path, &gradient, &DrawOptions::new());

    dt.write_png("out.png").unwrap();
}
thread 'main' panicked at 'index out of bounds: the len is 256 but the index is 256', /home/razr/.cargo/registry/src/github.com-1ecc6299db9ec823/sw-composite-0.7.10/src/lib.rs:324:17