im-richard / Scaffold

Extend, combine and compress CSS
http://github.com/IAMRichardT/Scaffold/wiki
161 stars 19 forks source link

A more generic Color extension #14

Open jide opened 14 years ago

jide commented 14 years ago

I see the rewrite has made a lot of progress, and it's brilliant ! I can't wait for the functions to be implemented.

Using Scaffold a lot these times, I was thinking that a generic Color class would be a great thing to have. What I mean by "generic" is a function that would let us manipulate and convert colors from one single function. It would take a color as input, have an output format and return the reformatted color.

This would give "color input" -> "color output" :

background: color(#FF0000, rgb); // would output rgb(XXX, XXX, XXX); background: color(rgb(250, 134, 155), hex); // would output #XXXXXX; background: color(hsla(250, 134, 155, 80), rgba); // would output rgba(XXX, XXX, XXX, XXX); background: color(rgba(250, 134, 155, 50), image); // would output url(path/to/transparent-image.png); and so on...

Another thing that could be great would be the ability to manipulate those colors using rgb or hsl :

background: color(hsl-adjust(#FF0000, +10, -10, +20), rgb); background: color(rgb-adjust(#FF0000, +100, -50, +20), hex);

The implementation is to be thought a little more obviously, but you get the idea. Maybe it could be pluggable to handle some more cases.

Any thought ?

jide commented 14 years ago

I already implemented a hsl-adjust method for the previous version of Scaffold, and I may actually be able to help here.

balupton commented 14 years ago

Sounds great. +1