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

Wrong color displaying with 0x color #182

Open
ylazy opened this issue Mar 15, 2023 · 3 comments
Open

Wrong color displaying with 0x color #182

ylazy opened this issue Mar 15, 2023 · 3 comments

Comments

@ylazy
Copy link

ylazy commented Mar 15, 2023

Hi!

Color with 4 letters (for example 0xDEAD) should be displayed like 0x00DEAD. Another example: 0xC0DE = 0x00C0DE.
Currently, the extension is displaying wrong colors. Please see the image below. The colors on the right are correct.

image

Thank you for the great extension!

@Ascor8522
Copy link

Color with 4 letters (for example 0xDEAD) should be displayed like 0x00DEAD.

Hex codes with 4 digits are not valid color codes according to the CSS specs. https://www.w3.org/TR/css-color-3/#rgb-color

You could argue the 4th digit stands for the opacity, so the 4 digits would be a shorthand for an RGBA color, which is fair.

However, that behavior should match the one for RGB colors, where the single digit is repeated.

The three-digit RGB notation (#rgb) is converted into six-digit form (#rrggbb) by replicating digits, not by adding zeros. For example, #fb0 expands to #ffbb00. This ensures that white (#ffffff) can be specified with the short notation (#fff) and removes any dependencies on the color depth of the display.

If #DEA becomes #DDEEAA, then #DEAD should become #DDEEAADD, and not #00DEAD

@ylazy
Copy link
Author

ylazy commented Apr 2, 2023

@Ascor8522 I'm talking about a color value that is a Hexadecimal Integer Literal (0xRRGGBB), not String Value ("#RRGGBB").
Try to open the developer tool and enter this in the console:

0xDEAD == 0x00DEAD && 0xDEAD == 0x0000DEAD

Then you will get the result:

image

@Ascor8522
Copy link

Those are just numbers then. They aren't colors.

Maybe the application you were writing was using those numbers as colors, but that's not something standard. It should also depend on the palette used.

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

No branches or pull requests

2 participants