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

[Feature request]: toRgbRatio #227

Open
lukasoppermann opened this issue Sep 9, 2021 · 1 comment
Open

[Feature request]: toRgbRatio #227

lukasoppermann opened this issue Sep 9, 2021 · 1 comment

Comments

@lukasoppermann
Copy link

Hey, in some cases, e.g. when delivering data to iOS you need a ratio rgb color. It would be great if tinycolor could also support toRgbRatio.

I think it would work like this

const color = new TinyColor('red');
color.toRgbRatio(); // { r: 1, g: 0, b: 0, a: 1 }

It should be pretty similar to toPercentageRgb since the ratio is basically a percentage value as a float from 0 to 1.

@matthias-ccri
Copy link

Agreed this is needed, because toRgb rounds values, which loses precision. So there's actually no way to get the exact RGB values out!

See bgrins/TinyColor#278

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