-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Added: red() green() and blue() functions #803
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
Conversation
You are right, I didn't read the color.js file closely enough :) |
A simple example of how to build a contrast selector out of these functions: .contrast-color(@sample)
when(
(
(
(red(@sample) * 299)
+ (green(@sample) * 587)
+ (blue(@sample) * 114)
) / 1000
) >= 128
){
color:black;
}
.contrast-color(@sample)
when(
(
(
(red(@sample) * 299)
+ (green(@sample) * 587)
+ (blue(@sample) * 114)
) / 1000
) < 128
){
color:white;
} Algorithm borrowed from http://24ways.org/2010/calculating-color-contrast |
Take a look at #730 for a more flexible (and SASS compatible) contrast function. Got any idea of how best to implement the .luma() method I mention in that? |
contrast has now been added. I still think these functions are useful. @Synchro @MatthewDL what do you think? |
|
Sorry, ignore me, we already have alpha()! |
I've included docs for these in less/old-lesscss.org#22 |
rebased (squashed) and pulled |
These work in a similar fashion to hue() saturation() and lightness(), but return a unit-less scalar between 0 and 255 as expected by the CSS rgb(x, x, x) notation.