Incorrect linear gradients
RazrFalcon opened this issue · comments
Yevhenii Reizner commented
use raqote::*;
fn main() {
let mut dt = DrawTarget::new(200, 200);
let mut pb = PathBuilder::new();
pb.move_to( 20.0, 20.0);
pb.line_to(180.0, 20.0);
pb.line_to(180.0, 180.0);
pb.line_to( 20.0, 180.0);
pb.close();
let path = pb.finish();
let gradient = Source::LinearGradient(
Gradient {
stops: vec![
GradientStop {
position: 0.0,
color: 0xff000000,
},
GradientStop {
position: 1.0,
color: 0xffffffff,
},
],
},
Transform::default(),
);
dt.fill(&path, &gradient, &DrawOptions::new());
dt.write_png("test.png").unwrap();
}
Jeff Muizelaar commented
I'm pretty sure this is just an artifact of the implicit with of a linear gradient being 256 device pixels. You should use the 'new_linear_gradient' and 'new_radial_gradient' helpers to get more reasonable results. I suspect we'll eventually want to make Source opaque and just have the helper api's around that do the conversion to the internal representation.