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`.
This commit is contained in:
parent
818459113e
commit
023b502153
@ -77,6 +77,20 @@ pub trait Alpha: Sized {
|
||||
}
|
||||
}
|
||||
|
||||
impl Alpha for f32 {
|
||||
fn with_alpha(&self, alpha: f32) -> Self {
|
||||
alpha
|
||||
}
|
||||
|
||||
fn alpha(&self) -> f32 {
|
||||
*self
|
||||
}
|
||||
|
||||
fn set_alpha(&mut self, alpha: f32) {
|
||||
*self = alpha;
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for manipulating the hue of a color.
|
||||
pub trait Hue: Sized {
|
||||
/// Return a new version of this color with the hue channel set to the given value.
|
||||
|
Loading…
Reference in New Issue
Block a user