Make Color alpha functions const

This commit is contained in:
mars 2022-11-18 12:43:10 -07:00
parent 7de22f9bd4
commit 2aadd0d57a
1 changed files with 2 additions and 2 deletions

View File

@ -173,13 +173,13 @@ impl Color {
)
}
pub fn alpha_multiply(&self, mul: u8) -> Self {
pub const fn alpha_multiply(&self, mul: u8) -> Self {
let a = self.0 as u8 as u16;
let multiplied = ((a * (mul as u16)) >> 8) as u8;
self.with_alpha(multiplied)
}
pub fn with_alpha(&self, alpha: u8) -> Self {
pub const fn with_alpha(&self, alpha: u8) -> Self {
Self(self.0 & 0xffffff00 | alpha as u32)
}