Skip to content
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

Made bevy_color a dependency of bevy_render #12105

Merged

Conversation

bushrat011899
Copy link
Contributor

Objective

Solution

  • Split bevy_render::color::colorspace across the various space implementations in bevy_color as appropriate.
  • Moved From implementations involving bevy_render::color::LegacyColor into bevy_render::color

Migration Guide

bevy_render::color::colorspace::SrgbColorSpace::<f32>::linear_to_nonlinear_srgb

Use bevy_color::color::gamma_function_inverse

bevy_render::color::colorspace::SrgbColorSpace::<f32>::nonlinear_to_linear_srgb

Use bevy_color::color::gamma_function

bevy_render::color::colorspace::SrgbColorSpace::<u8>::linear_to_nonlinear_srgb

Modify the u8 value to instead be an f32 (|x| x as f32 / 255.), use bevy_color::color::gamma_function_inverse, and back again.

bevy_render::color::colorspace::SrgbColorSpace::<u8>::nonlinear_to_linear_srgb

Modify the u8 value to instead be an f32 (|x| x as f32 / 255.), use bevy_color::color::gamma_function, and back again.

bevy_render::color::colorspace::HslRepresentation::hsl_to_nonlinear_srgb

Use Hsla's implementation of Into<Srgba>

bevy_render::color::colorspace::HslRepresentation::nonlinear_srgb_to_hsl

Use Srgba's implementation of Into<Hsla>

bevy_render::color::colorspace::LchRepresentation::lch_to_nonlinear_srgb

Use Lcha's implementation of Into<Srgba>

bevy_render::color::colorspace::LchRepresentation::nonlinear_srgb_to_lch

Use Srgba's implementation of Into<Lcha>

Inverts the dependency graph to more appropriately reflect how `bevy_render` and `bevy_color` relate to each other.
@bushrat011899 bushrat011899 added A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change labels Feb 25, 2024
crates/bevy_color/src/srgba.rs Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added the C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide label Feb 25, 2024
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Feb 25, 2024
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 25, 2024
Merged via the queue into bevyengine:main with commit 5e63f68 Feb 25, 2024
26 of 30 checks passed
msvbg pushed a commit to msvbg/bevy that referenced this pull request Feb 26, 2024
# Objective

- Fixes bevyengine#12068

## Solution

- Split `bevy_render::color::colorspace` across the various space
implementations in `bevy_color` as appropriate.
- Moved `From` implementations involving
`bevy_render::color::LegacyColor` into `bevy_render::color`

## Migration Guide

###
`bevy_render::color::colorspace::SrgbColorSpace::<f32>::linear_to_nonlinear_srgb`

Use `bevy_color::color::gamma_function_inverse`

###
`bevy_render::color::colorspace::SrgbColorSpace::<f32>::nonlinear_to_linear_srgb`

Use `bevy_color::color::gamma_function`

###
`bevy_render::color::colorspace::SrgbColorSpace::<u8>::linear_to_nonlinear_srgb`

Modify the `u8` value to instead be an `f32` (`|x| x as f32 / 255.`),
use `bevy_color::color::gamma_function_inverse`, and back again.

###
`bevy_render::color::colorspace::SrgbColorSpace::<u8>::nonlinear_to_linear_srgb`

Modify the `u8` value to instead be an `f32` (`|x| x as f32 / 255.`),
use `bevy_color::color::gamma_function`, and back again.

###
`bevy_render::color::colorspace::HslRepresentation::hsl_to_nonlinear_srgb`

Use `Hsla`'s implementation of `Into<Srgba>`

###
`bevy_render::color::colorspace::HslRepresentation::nonlinear_srgb_to_hsl`

Use `Srgba`'s implementation of `Into<Hsla>`

###
`bevy_render::color::colorspace::LchRepresentation::lch_to_nonlinear_srgb`

Use `Lcha`'s implementation of `Into<Srgba>`

###
`bevy_render::color::colorspace::LchRepresentation::nonlinear_srgb_to_lch`

Use `Srgba`'s implementation of `Into<Lcha>`
msvbg pushed a commit to msvbg/bevy that referenced this pull request Feb 26, 2024
# Objective

- Fixes bevyengine#12068

## Solution

- Split `bevy_render::color::colorspace` across the various space
implementations in `bevy_color` as appropriate.
- Moved `From` implementations involving
`bevy_render::color::LegacyColor` into `bevy_render::color`

## Migration Guide

###
`bevy_render::color::colorspace::SrgbColorSpace::<f32>::linear_to_nonlinear_srgb`

Use `bevy_color::color::gamma_function_inverse`

###
`bevy_render::color::colorspace::SrgbColorSpace::<f32>::nonlinear_to_linear_srgb`

Use `bevy_color::color::gamma_function`

###
`bevy_render::color::colorspace::SrgbColorSpace::<u8>::linear_to_nonlinear_srgb`

Modify the `u8` value to instead be an `f32` (`|x| x as f32 / 255.`),
use `bevy_color::color::gamma_function_inverse`, and back again.

###
`bevy_render::color::colorspace::SrgbColorSpace::<u8>::nonlinear_to_linear_srgb`

Modify the `u8` value to instead be an `f32` (`|x| x as f32 / 255.`),
use `bevy_color::color::gamma_function`, and back again.

###
`bevy_render::color::colorspace::HslRepresentation::hsl_to_nonlinear_srgb`

Use `Hsla`'s implementation of `Into<Srgba>`

###
`bevy_render::color::colorspace::HslRepresentation::nonlinear_srgb_to_hsl`

Use `Srgba`'s implementation of `Into<Hsla>`

###
`bevy_render::color::colorspace::LchRepresentation::lch_to_nonlinear_srgb`

Use `Lcha`'s implementation of `Into<Srgba>`

###
`bevy_render::color::colorspace::LchRepresentation::nonlinear_srgb_to_lch`

Use `Srgba`'s implementation of `Into<Lcha>`
@BD103 BD103 added A-Color Color spaces and color math A-Rendering Drawing game state to the screen and removed A-Rendering Drawing game state to the screen labels May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Color Color spaces and color math A-Rendering Drawing game state to the screen C-Breaking-Change A breaking change to Bevy's public API that needs to be noted in a migration guide C-Code-Quality A section of code that is hard to understand or change S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bevy_color: migrate color conversion code from bevy_render
4 participants