sharkdp / pastel

A command-line tool to generate, analyze, convert and manipulate colors
Apache License 2.0
5.07k stars 102 forks source link

Add support for setting alpha values / `transparent` color #217

Closed kanielrkirby closed 3 months ago

kanielrkirby commented 5 months ago

I could be overlooking something, but I couldn't find any examples of setting alpha from an existing color, and the workarounds I've tried didn't work very well.

Example of desired functionality:

pastel color red | pastel set alpha 0.5
Hex: #ff000080
RGB: rgba(255, 0, 0, 0.5)
HSL: hsla(0, 100.0%, 50.0%, 0.5)

I tried mixing with white / black / grey with an opacity of 50%, but it results in colors being inaccurate

pastel mix "$(pastel color red)" "$(pastel color #FFFFFF80)"
pastel mix "$(pastel color red)" "$(pastel color #00000080)"
pastel mix "$(pastel color red)" "$(pastel color #80808080)"

Also looked for a color that might not have a direct color value, like transparent or clear, but these don't exist either.

I realize this is could be a pain to implement, so I just wanted to make an issue for it to check if this is something you plan to look into / would accept a PR for, or if this is more work than it's worth. Also if there's a workaround I don't know of, please let me know.

sharkdp commented 5 months ago

Thank you for the report. It's been a while since I worked on this code base, to be honest. I think there is no way to do this, but I agree that pastel set alpha is something that should work. I would hope that it is easy to implement.