Skip to content

Color::INDIGO is not indigo #1193

Closed
Closed

Description

@SeanMcLoughlin

Bevy version

Bevy 4.0.0

Operating system & version

Ubuntu 20.04

What you did

Was looking at the breakout example where a ClearColor resource was added. I noticed the Color struct has some constant values to choose from, including the value INDIGO. When using that value on a simple default app, the color generated is much more purple than indigo. A simple reproducible example:

use bevy::prelude::*;

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_resource(ClearColor(Color::INDIGO))
        .run();
}

What you expected to happen

The background color to be indigo.

What actually happened

The background color was purple.

Additional information

My initial search of a hex value for indigo led to #4B0082, which appears to be the programming for Color::INDIGO. Color pickers seem to show that as more of a purple. However I don't want this issue to get heated over the definition of indigo, so do with this info what you will.

Below is what I see when using Color::INDIGO:

Screenshot from 2021-01-02 12-36-44

From a quick Google search, indigo more closely resembles the color below.
image

Activity

  1. mockersf commented on Jan 2, 2021

    @mockersf
    Member

    The colours where added in #859, and should be the HTML colours, so #4B0082 for indigo (how nice of GitHub to render the colour! Seems to be between the two colours in your issue)
    In #616, there was a difference made between rbg and rgb_linear

    Color::INDIGO is set up using rgb_linear

    pub const INDIGO: Color = Color::rgb_linear(0.29, 0.0, 0.51);

    If I take the same values and use them as rgb, I get the expected colour:

      .add_resource(ClearColor(Color::rgb(0.29, 0.0, 0.51)))

    I'm not very fluent in colour spaces, so would be great if someone that knows those better could take a look at it

  2. added
    C-BugAn unexpected or incorrect behavior
    A-RenderingDrawing game state to the screen
    on Jan 4, 2021
  3. TheZalli commented on Jan 4, 2021

    @TheZalli

    I've read some on color spaces, but to spare you the details (although I do believe every game programmer should understand the basics about sRGB and gamma correction), when describing colors you most often want to avoid using the linear colors that haven't been gamma corrected. They are used only when mixing and blending colors, and when sending them to the screen (most often done automatically by the GPU in a shader).

    When giving color values, they should always be in sRGB (the standard RGB space, aka gamma corrected), and this is the colorspace that all programs use when interfacing with users (the values they give, and what you give).

    TLDR:

    change it from linear to srbg, which is the Color::rgb function.

    Edit: actually looking at it, I guess you can't since Color::rgb_linear is a const function, and Color::rgb isn't, and looking at Rust reference it can't be since it has float operations. I guess just convert the value from sRGB to linear by-hand, and change the function's parameters. And check the other color constants as well, doing the same operation if they're likewise weird looking.

  4. sburris0 commented on Jan 13, 2021

    @sburris0
    Contributor

    I noticed this and did some testing, rgb_linear() seems to always produce much lighter colors than expected
    Color::MIDNIGHT_BLUE is pretty light.

  5. tigregalis commented on Jan 16, 2021

    @tigregalis
    Contributor

    I grabbed the list of 148 (139*) "named colours" in CSS to generate this code using bevy's own Color functions. Do we want this full list?

    This is Indigo:

    use bevy::prelude::*;
    
    #[allow(clippy::excessive_precision)]
    /// #4B0082 Indigo
    pub const INDIGO: Color =
        Color::rgb_linear(0.07036010921001434326171875, 0., 0.223227977752685546875);
    
    fn main() {
        App::build()
            .add_plugins(DefaultPlugins)
            .add_resource(ClearColor(INDIGO))
            .run();
    }

    image
    image

    *duplicates are:

    "#00FFFF": [
        "Aqua",
        "Cyan",
    ],
    "#FF00FF": [
        "Fuchsia",
        "Magenta",
    ],
    "#778899": [
        "Light Slate Gray",
        "Light Slate Grey",
    ],
    "#708090": [
        "Slate Gray",
        "Slate Grey",
    ],
    "#808080": [
        "Gray",
        "Grey",
    ],
    "#A9A9A9": [
        "Dark Gray",
        "Dark Grey",
    ],
    "#D3D3D3": [
        "Light Gray",
        "Light Grey",
    ],
    "#696969": [
        "Dim Gray",
        "Dim Grey",
    ],
    "#2F4F4F": [
        "Dark Slate Gray",
        "Dark Slate Grey",
    ],
  6. mockersf commented on Jan 16, 2021

    @mockersf
    Member

    Do we want this full list?

    Yes... and no 😃

    The full fix would be to have a const function to create colours with standard rgb hex. To do that, this TODO should be done

    // TODO: Separate types for non-linear sRGB and linear sRGB, with conversions between

    But fixing the colours to have the correct value in linear until this is done is better than what we have now.

  7. tigregalis commented on Jan 18, 2021

    @tigregalis
    Contributor

    Do we want this full list?

    Yes... and no 😃

    So the list that's currently in Bevy is a smaller subset of that.
    I'll submit a PR later for all of the CSS colours using the generated values. I personally think it's worth having.

    The full fix would be to have a const function to create colours with standard rgb hex. To do that, this TODO should be done

    // TODO: Separate types for non-linear sRGB and linear sRGB, with conversions between

    But fixing the colours to have the correct value in linear until this is done is better than what we have now.

    Maybe I'll have a go at this a bit later on. What should these types be called?

    Relevant discussion: #688

  8. mockersf commented on Jan 18, 2021

    @mockersf
    Member

    Maybe I'll have a go at this a bit later on. What should these types be called?

    I would go with Color for the standard one that everybody is used to, and LinearColor for the linear variant, that is the one we have currently

  9. added this to the Bevy 0.5 milestone on Feb 17, 2021
  10. added a commit that references this issue on Mar 17, 2021
    bcd5318
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions