From a014b3e144922a4d41642819a673d6f4e577d4fa Mon Sep 17 00:00:00 2001 From: Steins7 Date: Sun, 10 Mar 2024 13:54:42 +0100 Subject: [PATCH] Fix convertion from Color to Pixel --- src/utils.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index df4d559..79ea72a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -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::() * 255, - g: self.g.to_int_unchecked::() * 255, - b: self.b.to_int_unchecked::() * 255, - a: self.a.to_int_unchecked::() * 255, + r: (self.r * 255.0).to_int_unchecked::(), + g: (self.g * 255.0).to_int_unchecked::(), + b: (self.b * 255.0).to_int_unchecked::(), + a: (self.a * 255.0).to_int_unchecked::(), } } } @@ -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 {