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

Color::from_rgb_str() and Color::rgb_hex() inconsistency #1710

Open
adamgerhant opened this issue Mar 27, 2024 · 1 comment
Open

Color::from_rgb_str() and Color::rgb_hex() inconsistency #1710

adamgerhant opened this issue Mar 27, 2024 · 1 comment

Comments

@adamgerhant
Copy link
Collaborator

adamgerhant commented Mar 27, 2024

When creating a color from a hex string with Color::from_rgb_str(), the hex string returned with Color::rgb_hex() is different.

Example:

let hex_color_before = "cccccc";
use graphene_core::raster::color::Color;
let color = Color::from_rgb_str(hex_color_before).unwrap();
let hex_color_after = color.rgb_hex();
console_log::init_with_level(log::Level::Info);
log::info!("rgb_hex: {:?}", hex_color_after); //logs "999999"

I'm pretty sure this is not intended behavior

@Keavon
Copy link
Member

Keavon commented Mar 27, 2024

This is because Color::from_rgb_str() gets mapped from gamma to linear but Color::rgb_hex() doesn't map it back to gamma before printing the output. So that's definitely a bug, although I'll have to consult with @TrueDoctor to decide which part of that process should be fixed. I'm inclined to say that we want all colors to be linear, meaning we convert back to gamma before printing in Color::rgb_hex() (then we have to trace any other usages of that function where we might be accidentally using the wrong linear/gamma and fix it in those too.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Short-Term
Development

No branches or pull requests

2 participants