Skip to content

Commit 023b502

Browse files
authored
Implemented Alpha for f32. (#18653)
# Objective `f32` can be used to represent alpha, this streamlines generic code related to colors. ## Solution - Implemented `Alpha` for `f32`.
1 parent 8184591 commit 023b502

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

crates/bevy_color/src/color_ops.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ pub trait Alpha: Sized {
7777
}
7878
}
7979

80+
impl Alpha for f32 {
81+
fn with_alpha(&self, alpha: f32) -> Self {
82+
alpha
83+
}
84+
85+
fn alpha(&self) -> f32 {
86+
*self
87+
}
88+
89+
fn set_alpha(&mut self, alpha: f32) {
90+
*self = alpha;
91+
}
92+
}
93+
8094
/// Trait for manipulating the hue of a color.
8195
pub trait Hue: Sized {
8296
/// Return a new version of this color with the hue channel set to the given value.

0 commit comments

Comments
 (0)