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

Allow specifying alpha as a number from 0 to 255 #9

Open
Richienb opened this issue May 16, 2020 · 5 comments
Open

Allow specifying alpha as a number from 0 to 255 #9

Richienb opened this issue May 16, 2020 · 5 comments

Comments

@Richienb
Copy link
Contributor

Currently, the alpha can only be specified as a decimal or percentage. However, it would be useful if it could be specified as a number from 0 to 255. Conversion back to percentages is: alpha / 255

const rgbHex = require("rgb-hex")

rgbHex(255, 255, 255, 255)
//=> "ffffffff"

cc @sindresorhus

@sindresorhus
Copy link
Owner

What's the use-case? I don't see how that can be done with the suggested API as it's ambigious whether rgbHex(255, 255, 255, 1) means 100% alpha or 1/255%.

@Richienb
Copy link
Contributor Author

@sindresorhus A Uint8ClampedArray encodes red, green, blue and alpha as integers from 0 to 255.

@sindresorhus
Copy link
Owner

Any suggestions on how the API should look like?

@Richienb
Copy link
Contributor Author

Richienb commented May 17, 2020

@sindresorhus We could add an option that changes the behaviour of the alpha parameter.

@sindresorhus
Copy link
Owner

Yeah, I guess.

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