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

Use luminance formula for random colors in example #18

Open
CHiPs44 opened this issue Feb 25, 2023 · 3 comments
Open

Use luminance formula for random colors in example #18

CHiPs44 opened this issue Feb 25, 2023 · 3 comments
Assignees

Comments

@CHiPs44
Copy link
Owner

CHiPs44 commented Feb 25, 2023

cf. https://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale:

luminance = 0.2126 * r + 0.7152 * g + 0.0722 * b

Here we have r, g and b from 0 to 31 and no FPU...

@CHiPs44 CHiPs44 self-assigned this Feb 25, 2023
@CHiPs44
Copy link
Owner Author

CHiPs44 commented Mar 9, 2023

NB: 0.2126 is 2126 / 10000, and so on.

luminance = (2126 * r + 7152 * g + 722 * b) / 100

should be between 0 and 255 if 8 bits and comparable across 2 colors.

@CHiPs44
Copy link
Owner Author

CHiPs44 commented Sep 27, 2023

Formula used for console16 palette, see #26.

@CHiPs44
Copy link
Owner Author

CHiPs44 commented Dec 22, 2023

Have another byte array alongside each palette with luminance values?

Have another byte array alongside each palette with indexes of colors ordered by luminance?

Compute luminance at runtime and keep it another array? Sort it?

Handle only 16 color palettes? 16 and 256 ones? (2 and 4 colors palettes are less used)

NB: with 256 colors, collision may happen more frequently, perhaps compute luminance with 16bits instead of 8.

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

1 participant