LearnBoost/stylus — pull request #1526 by kizu (2014-05-14 17:49:09+00:00)
Title: [WIP] Better colors

This is a work-in-progress PR with work on overall better handling colors in Stylus. There are several things I want to do there, some of them I want there for certain, some of them I'm not that certain should be there.

- [x] Support for two arguments in `hsla`. `rgba` already have this, so why not have this in hsla also?
- [ ] Component setters: right now all `red`, `green`, `hue` etc. bifs only return the given component of the given color, we can add setters by adding the second optional argument to the new value, so those functions would return the modified color. `red(rgba(255,0,0,0.5), 128)` should become `rgba(128,0,0,0.5)`. Question is: should we somehow support the modifying the component relatively? Like proposed [there](https://github.com/LearnBoost/stylus/issues/1021). The problem would be that percents are actually ok for rgb/hsl too, but hey.
- [ ] Add `luminance` bif using proper equations.
- [ ] Add `blend` bif for proper blending the colors (existing `mix` does something different).
- [ ] Add some bif/bifs for handling the contrast between colors, using some equations and stuff.
- [ ] Add `transparentify` bif for converting any non-transparent color to a closest transparent one against the given background.

What I'm not still sure I want to do: make `hsl`/`hsla` to return their original values instead of hex/`rgba` fallback. For `hsla` this won't make much difference, but for `hex`/`rgb` to `hsl ` it would mean that the existent code would break in old IE. However, it would be really easy to add fallback from the `hsla` to the current behaviour, so this would mean users would have more control over their code. However, there are some issues with having `hsla`, like that we now convert the percents into numbers and stuff and not saving exact values, also there are rounding issues etc., so there are a lot of things to think about.

If anyone have ideas how to further support how Stylus handles colors, feel free to comment!