You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Objective
Fixes#12200 .
## Solution
I added a Hue Trait with the rotate_hue method to enable hue rotation.
Additionally, I modified the implementation of animations in the
animated_material sample.
---
## Changelog
- Added a `Hue` trait to `bevy_color/src/color_ops.rs`.
- Added the `Hue` trait implementation to `Hsla`, `Hsva`, `Hwba`,
`Lcha`, and `Oklcha`.
- Updated animated_material sample.
## Migration Guide
Users of Oklcha need to change their usage to use the with_hue method
instead of the with_h method.
---------
Co-authored-by: Pablo Reinhardt <126117294+pablo-lua@users.noreply.github.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Copy file name to clipboardExpand all lines: crates/bevy_color/src/color_ops.rs
+36Lines changed: 36 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,24 @@ pub trait Alpha: Sized {
62
62
}
63
63
}
64
64
65
+
/// Trait for manipulating the hue of a color.
66
+
pubtraitHue:Sized{
67
+
/// Return a new version of this color with the hue channel set to the given value.
68
+
fnwith_hue(&self,hue:f32) -> Self;
69
+
70
+
/// Return the hue of this color [0.0, 360.0].
71
+
fnhue(&self) -> f32;
72
+
73
+
/// Sets the hue of this color.
74
+
fnset_hue(&mutself,hue:f32);
75
+
76
+
/// Return a new version of this color with the hue channel rotated by the given degrees.
77
+
fnrotate_hue(&self,degrees:f32) -> Self{
78
+
let rotated_hue = (self.hue() + degrees).rem_euclid(360.);
79
+
self.with_hue(rotated_hue)
80
+
}
81
+
}
82
+
65
83
/// Trait with methods for asserting a colorspace is within bounds.
66
84
///
67
85
/// During ordinary usage (e.g. reading images from disk, rendering images, picking colors for UI), colors should always be within their ordinary bounds (such as 0 to 1 for RGB colors).
0 commit comments