From e760e879a57c50d9c66af5bb43ab29da947bf1e0 Mon Sep 17 00:00:00 2001 From: "Arend van Beelen jr." Date: Sat, 31 Aug 2024 20:11:04 +0200 Subject: [PATCH] Make more `Color` constructors `const fn` --- crates/bevy_color/src/color.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_color/src/color.rs b/crates/bevy_color/src/color.rs index 92fa2b98fd559..89740f3e356ff 100644 --- a/crates/bevy_color/src/color.rs +++ b/crates/bevy_color/src/color.rs @@ -142,7 +142,7 @@ impl Color { /// Creates a new [`Color`] object storing a [`Srgba`] color from [`u8`] values. /// /// A value of 0 is interpreted as 0.0, and a value of 255 is interpreted as 1.0. - pub fn srgba_u8(red: u8, green: u8, blue: u8, alpha: u8) -> Self { + pub const fn srgba_u8(red: u8, green: u8, blue: u8, alpha: u8) -> Self { Self::Srgba(Srgba { red: red as f32 / 255.0, green: green as f32 / 255.0, @@ -162,7 +162,7 @@ impl Color { /// Creates a new [`Color`] object storing a [`Srgba`] color from [`u8`] values with an alpha of 1.0. /// /// A value of 0 is interpreted as 0.0, and a value of 255 is interpreted as 1.0. - pub fn srgb_u8(red: u8, green: u8, blue: u8) -> Self { + pub const fn srgb_u8(red: u8, green: u8, blue: u8) -> Self { Self::Srgba(Srgba { red: red as f32 / 255.0, green: green as f32 / 255.0,