Skip to content

Commit

Permalink
Allow creating Colors in a const context. (#135)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel McNab <[email protected]>
  • Loading branch information
jeffreyrosenbluth and DJMcNab authored Dec 10, 2024
1 parent f2b9d09 commit fdac4c2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,20 @@ impl Color {
a: NV_ONE,
};

/// Creates a new color from 4 components.
///
/// # Safety
///
/// All values must be in 0..=1 range.
pub const unsafe fn from_rgba_unchecked(r: f32, g: f32, b: f32, a: f32) -> Self {
Color {
r: NormalizedF32::new_unchecked(r),
g: NormalizedF32::new_unchecked(g),
b: NormalizedF32::new_unchecked(b),
a: NormalizedF32::new_unchecked(a),
}
}

/// Creates a new color from 4 components.
///
/// All values must be in 0..=1 range.
Expand Down

0 comments on commit fdac4c2

Please sign in to comment.