Add a way to convert a FillOrStrokeStyle to a raqote Source

For now most of it unimplemented but it'll allow for some more testing
This commit is contained in:
Bastien Orivel 2019-08-08 16:13:45 +02:00
parent 7005c24e40
commit cbe385c7d7

View file

@ -398,3 +398,25 @@ impl Clone for Pattern<'_> {
unimplemented!();
}
}
pub trait ToRaqoteSource<'a> {
fn to_raqote_source(self) -> Option<raqote::Source<'a>>;
}
impl<'a> ToRaqoteSource<'a> for FillOrStrokeStyle {
fn to_raqote_source(self) -> Option<raqote::Source<'a>> {
use canvas_traits::canvas::FillOrStrokeStyle::*;
match self {
Color(rgba) => Some(raqote::Source::Solid(raqote::SolidSource {
r: rgba.red,
g: rgba.green,
b: rgba.blue,
a: rgba.alpha,
})),
LinearGradient(_) => unimplemented!(),
RadialGradient(_) => unimplemented!(),
Surface(_) => unimplemented!(),
}
}
}