-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicit color conversion methods (#10321)
# Objective Closes #10319 ## Changelog * Added a new `Color::rgba_from_array([f32; 4]) -> Color` method. * Added a new `Color::rgb_from_array([f32; 3]) -> Color` method. * Added a new `Color::rgba_linear_from_array([f32; 4]) -> Color` method. * Added a new `Color::rgb_linear_from_array([f32; 3]) -> Color` method. * Added a new `Color::hsla_from_array([f32; 4]) -> Color` method. * Added a new `Color::hsl_from_array([f32; 3]) -> Color` method. * Added a new `Color::lcha_from_array([f32; 4]) -> Color` method. * Added a new `Color::lch_from_array([f32; 3]) -> Color` method. * Added a new `Color::rgba_to_vec4(&self) -> Vec4` method. * Added a new `Color::rgba_to_array(&self) -> [f32; 4]` method. * Added a new `Color::rgb_to_vec3(&self) -> Vec3` method. * Added a new `Color::rgb_to_array(&self) -> [f32; 3]` method. * Added a new `Color::rgba_linear_to_vec4(&self) -> Vec4` method. * Added a new `Color::rgba_linear_to_array(&self) -> [f32; 4]` method. * Added a new `Color::rgb_linear_to_vec3(&self) -> Vec3` method. * Added a new `Color::rgb_linear_to_array(&self) -> [f32; 3]` method. * Added a new `Color::hsla_to_vec4(&self) -> Vec4` method. * Added a new `Color::hsla_to_array(&self) -> [f32; 4]` method. * Added a new `Color::hsl_to_vec3(&self) -> Vec3` method. * Added a new `Color::hsl_to_array(&self) -> [f32; 3]` method. * Added a new `Color::lcha_to_vec4(&self) -> Vec4` method. * Added a new `Color::lcha_to_array(&self) -> [f32; 4]` method. * Added a new `Color::lch_to_vec3(&self) -> Vec3` method. * Added a new `Color::lch_to_array(&self) -> [f32; 3]` method. ## Migration Guide `Color::from(Vec4)` is now `Color::rgba_from_array(impl Into<[f32; 4]>)` `Vec4::from(Color)` is now `Color::rgba_to_vec4(&self)` Before: ```rust let color_vec4 = Vec4::new(0.5, 0.5, 0.5); let color_from_vec4 = Color::from(color_vec4); let color_array = [0.5, 0.5, 0.5]; let color_from_array = Color::from(color_array); ``` After: ```rust let color_vec4 = Vec4::new(0.5, 0.5, 0.5); let color_from_vec4 = Color::rgba_from_array(color_vec4); let color_array = [0.5, 0.5, 0.5]; let color_from_array = Color::rgba_from_array(color_array); ```
- Loading branch information
Showing
3 changed files
with
160 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters