-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Color::as_lcha
#7757
Labels
A-Rendering
Drawing game state to the screen
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
D-Trivial
Nice and easy! A great choice to get started with Bevy
Milestone
Comments
LiamGallagher737
added
C-Feature
A new feature, making something new possible
S-Needs-Triage
This issue needs to be labelled
labels
Feb 20, 2023
alice-i-cecile
added
D-Trivial
Nice and easy! A great choice to get started with Bevy
A-Rendering
Drawing game state to the screen
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
and removed
C-Feature
A new feature, making something new possible
S-Needs-Triage
This issue needs to be labelled
labels
Feb 20, 2023
I can try to do it if it is still free |
Still free |
iwek7
added a commit
to iwek7/bevy
that referenced
this issue
Feb 20, 2023
iwek7
added a commit
to iwek7/bevy
that referenced
this issue
Feb 20, 2023
iwek7
added a commit
to iwek7/bevy
that referenced
this issue
Feb 20, 2023
iwek7
added a commit
to iwek7/bevy
that referenced
this issue
Feb 20, 2023
iwek7
added a commit
to iwek7/bevy
that referenced
this issue
Feb 20, 2023
Shfty
pushed a commit
to shfty-rust/bevy
that referenced
this issue
Mar 19, 2023
# Objective Fixes bevyengine#7757 New function `Color::as_lcha` was added and `Color::as_lch_f32` changed name to `Color::as_lcha_f32`. ---- As a side note I did it as in every other Color function, that is I created very simillar code in `as_lcha` as was in `as_lcha_f32`. However it is totally possible to avoid this code duplication in LCHA and other color variants by doing something like : ``` pub fn as_lcha(self: &Color) -> Color { let (lightness, chroma, hue, alpha) = self.as_lcha_f32(); return Color::Lcha { lightness, chroma, hue, alpha }; } ``` This is maybe slightly less efficient but it avoids copy-pasting this huge match expression which is error prone. Anyways since it is my first commit here I wanted to be consistent with the rest of code but can refactor all variants in separate PR if somebody thinks it is good idea.
Shfty
pushed a commit
to shfty-rust/bevy
that referenced
this issue
Mar 19, 2023
# Objective Fixes bevyengine#7757 New function `Color::as_lcha` was added and `Color::as_lch_f32` changed name to `Color::as_lcha_f32`. ---- As a side note I did it as in every other Color function, that is I created very simillar code in `as_lcha` as was in `as_lcha_f32`. However it is totally possible to avoid this code duplication in LCHA and other color variants by doing something like : ``` pub fn as_lcha(self: &Color) -> Color { let (lightness, chroma, hue, alpha) = self.as_lcha_f32(); return Color::Lcha { lightness, chroma, hue, alpha }; } ``` This is maybe slightly less efficient but it avoids copy-pasting this huge match expression which is error prone. Anyways since it is my first commit here I wanted to be consistent with the rest of code but can refactor all variants in separate PR if somebody thinks it is good idea.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-Rendering
Drawing game state to the screen
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
D-Trivial
Nice and easy! A great choice to get started with Bevy
Problem
Other color spaces have a
as_xxx
with returns aColor
and aas_xxx_f32
that returns a[f32; 4]
, the lch color space only has aas_lch_f32
that returns a[f32; 4]
.Solution
Add a new method,
as_lcha
, forbevy_render::Color
for converting anyColor
type into aColor::Lcha
variant.Note
Alongside this it would also make sense to rename
as_lch_f32
toas_lcha_f32
as it also returns the alpha, not really big enough for its own issue.The text was updated successfully, but these errors were encountered: