Skip to content

Add normalized RGB values, e.g, 0.1,0.2,0.3, parsing#316

Open
phqb wants to merge 1 commit into
sharkdp:masterfrom
phqb:master
Open

Add normalized RGB values, e.g, 0.1,0.2,0.3, parsing#316
phqb wants to merge 1 commit into
sharkdp:masterfrom
phqb:master

Conversation

@phqb

@phqb phqb commented May 23, 2026

Copy link
Copy Markdown

I need a CLI tool to display RGB colors from normalized format which is used in GLSL shaders code. Then I came across this fantastic tool.

The parse_numeric_rgb() in this repo parses RGB values as double and always divides them by 225 before constructing Color.

This PR add a parse_numeric_rgb_normalized() in which if RGB values are all in range [0,1], then they are considered normalized and used as-is to construct Color.

parse_numeric_rgb_normalized() has higher precedence than parse_numeric_rgb() to workaround the ambiguous values like 0.01 0.01 0.01 could be a rounding error of black color. I think making parse_numeric_rgb() parse values as u8 solves this ambiguity problem, but it is not backward compatible and breaks test cases.

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

Successfully merging this pull request may close these issues.

1 participant