-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
add color functions to raise/lower brightness #1853
Conversation
|
@seven-phases-max I wasn't sure what to name it, since "darken" is already being used to change lightness. Any suggestions? |
@Sinetheta Honestly I don't know too :) |
blacken? |
I think the names work. So presumably this does something significantly |
Yes, HSL and HSV are different color models. Hue is the same, but they have different interpretations of how to move around the "colorfulness" of a particular hue (HSV is more like blending paint, HSL is meant to be more like how humans perceive the difference between colors). For example, today I was working from a Photoshop file provided by a coworker, and to them all the color transitions made sense. A button used a gradient from a color over a range of "brightness", a hover state did the same thing but was 15% less HSB saturated. These kinds of operations were repeated throughout the file. But when it came time to translate that to web, there was a problem. Instead of being write a couple concise mixins, I would need buckets of a variables, all those particular colors which have no simple relationship in another color model. ps: it might actually be more appropriate for me to include 2 functions for modifying saturation in HSB as well.
*just pulling these names out of thing air from painting terms |
Could the same thing be achieved with softlight / darklight and shades of On 6 February 2014 07:26, Kevin Attfield [email protected] wrote:
|
Btw. this is a good idea. When I was in the blending functions I had a thought that some kind of a |
We do already have the I'm torn between having different names for each operation and adding a colorspace param - the latter would clearly allow easy addition of more colorspaces and reduce the proliferation of function names, but OTOH the operations are not exactly analagous in each colorspace - i.e. darken in HSL does not produce the same results as dim in HSB/V. I can see |
I sort of feel like Less.js now has too many color functions natively. These additional functions are useful for smaller and smaller segments of users. If you look at the documentation, it's the one part that can't really be explained briefly (and often aren't explained at all), so it's a barrier for someone just learning the language. IMO much of the color parts of Less.js should be moved to a plugin model (non-core) when such a model actually exists (and is documented). |
thanks @Synchro I never thought of using
It's not exactly pretty, since we can't define our own functions (without a hack?), but it certainly gets the job done without complicating the library. |
We can, via hack or by using the corresponding plugin. As for doing this via math and/or other functions, it will be a bit unfair to not provide
But sure, we definitely need to think of how to bring the iron order to the colour functions subsystem (and their naming especially... We could slowly move forward by marking some old names deprecated and optionally move some of the functions to plugins as suggested by @matthew-dean). For example: (Btw., too bad the CSS4 Colors stuff is still in its early draft stage otherwise we could start to move in this direction. Curiosuly things like |
I'm wondering if perhaps the naming of the functions is part of the reason there are so many currently. For example, |
In fact both Technically it could be even just one function:
(Though I can guess how this could look confusing if the same function returns different things i.e. color vs. number). |
@seven-phases-max also, although the "mixins as functions" trick is neat, I think they still can't be used as arguments to other mixins. So, not much help when the goal is:
|
It's just a matter of formatting:
There's nothing you can't do via mixins and scope. But it is barely on topic (i.e. my remark was just more to "hack / not hack" thing, nothing else). |
I think we would like to provide a function, rather than officially recommend the work-around of calling mixins. The question now is how. @seven-phases-max description of How does that sound to you @Sinetheta ? |
So why not add an optional "color model" to function calls? |
The problem with that is that there are not necessarily exact parallels between the params across color spaces, for example while saturation and hue are the same in HSV and HSL, the lightness/value acts a bit differently. |
Hmm, indeed. But I guess it's not that critical, we don't have to be that restrictive, our goal is just to prevent that enormous amount of potential functions with strange names. E.g. if semantically a shared function name is too confusing we can leave both lightness/hsv-value functions as they are (or they optionally can also accept |
There are probably not that many functions that have properties similar enough to do this with, so we'd need separate functions for them anyway. As an alternative to a colorspace param, could we not derive it from the input color? So brightness would affect L given an HSL value, but V given HSV? I guess that could be confusing if you pass in an RGB value and rely on it being converted into some other space before applying the transformation. |
In Less we don't have HSL or HSV color object actually. Less color object is always just an RGBA color so only a function name or its parameters can guide what to do (i.e. the conversion is always performed anyway). |
v2 supports plugins for new functions. See https://github.com/less/less-plugin-advanced-color-functions Feel free to make a pr against that, I would be happy taking anything useful into that. |
Per my comment earlier in this thread, I would support deprecating existing color blending functions and moving them to the advanced color functions plugin (after a deprecation period), and adding HSB and other special color functions to that plugin. |
brighten(color, amount)
anddim(color, amount)
which use the existing HSV helpers to adjust the brightness of a color.As long as Photoshop remains a dominant force in the design world, we're going to have to deal with HSV (aka HSB). The ability to adjust "brightness" makes dealing with these much easier.