Fix convertion from Color to Pixel

This commit is contained in:
Steins7 2024-03-10 13:54:42 +01:00
parent f0ab184ea8
commit a014b3e144

View File

@ -175,10 +175,10 @@ impl Color {
//that the values are within [0.0, 1.0], meaning we won't ever overflow an u8
unsafe {
Pixel {
r: self.r.to_int_unchecked::<u8>() * 255,
g: self.g.to_int_unchecked::<u8>() * 255,
b: self.b.to_int_unchecked::<u8>() * 255,
a: self.a.to_int_unchecked::<u8>() * 255,
r: (self.r * 255.0).to_int_unchecked::<u8>(),
g: (self.g * 255.0).to_int_unchecked::<u8>(),
b: (self.b * 255.0).to_int_unchecked::<u8>(),
a: (self.a * 255.0).to_int_unchecked::<u8>(),
}
}
}
@ -193,7 +193,7 @@ impl Color {
}
pub fn alpha_blend(&self, other: &Self) -> Self {
//apply alpha compisting's "over" operator, see
//apply alpha compositing's "over" operator, see
//[https://en.wikipedia.org/wiki/Alpha_compositing] for more detail
let a = self.a + other.a * (1.0 - self.a);
Self {