add wrapper for SkColor4f::fitsInBytes()
@@ -249,6 +249,16 @@ impl Color4f {
self.a == 1.0
}
+ // TODO: this is the copied implementation, it would probably be better to call the Skia function.
+
+ pub fn fits_in_bytes(&self) -> bool {
+ debug_assert!(self.a >= 0.0 && self.a <= 1.0);
+ return
+ self.r >= 0.0 && self.r <= 1.0 &&
+ self.g >= 0.0 && self.g <= 1.0 &&
+ self.b >= 0.0 && self.b <= 1.0;
+ }
+
pub fn to_color(&self) -> Color {
fn c(f: f32) -> u8 {
(f.max(0.0).min(1.0) * 255.0) as u8
