Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

hi, is it currently possible to serialize the alpha channel to a percentage value?

i tried color.toString({ name: "hsl", coords: ["<angle>", "<percentage>", "<percentage>"], alpha: "<percentage>" }) but that does not seem to work.

You must be logged in to vote

Oof, unfortunately no, you can only customize how coordinates are serialized but alpha is always a number. That's a pretty big oversight on our part, I'll convert this to an issue so we can implement it, but need to think of the best syntax to expose this nicely.

Replies: 2 comments

Comment options

Oof, unfortunately no, you can only customize how coordinates are serialized but alpha is always a number. That's a pretty big oversight on our part, I'll convert this to an issue so we can implement it, but need to think of the best syntax to expose this nicely.

You must be logged in to vote
0 replies
Answer selected by stefanprobst
Comment options

Color.js serializes alpha as a number because CSS Color 4 says, in Serializing alpha values:

Otherwise, return the result of serializing the given value (as a <number>, not a <percentage>).

So <percentage> is accepted on input but not generated on output.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.