Math for colors #966
SimonLeclercq
started this conversation in
Ideas
Replies: 2 comments 6 replies
-
Would definitely need this! Thanks 🙏 |
Beta Was this translation helpful? Give feedback.
0 replies
-
Material UI React library has some good util functions for color manipulation. This one for instance is really useful. /**
* Darken or lighten a color, depending on its luminance.
* Light colors are darkened, dark colors are lightened.
* @param {string} color - CSS color, i.e. one of: #nnn, #nnnnnn, rgb(), rgba(), hsl(), hsla(), color()
* @param {number} coefficient=0.15 - multiplier in the range 0 - 1
* @returns {string} A CSS color string. Hex input values are returned as rgb
*/
export function emphasize(color, coefficient = 0.15) {
return getLuminance(color) > 0.5 ? darken(color, coefficient) : lighten(color, coefficient);
} |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello there,
First of all, thank you for the excellent work on the topic!
Within the framework of the generation of automated theme from a pallet, would it be possible to manage math directly since the creation of the
.color
, by attacking the valuesH
,S
,L
,A
of analias
directly?I could for example reduce the opacity of an alias to manage the cases of transparency, or play on the light to manage the state colors.
in a utility mindset, we could imagine details on the Hue, Saturation and Light, and then increment or decrement them.
as a picture may be worth 1,000 words, find bellow what I would be able to do:
In the same way, It could be useful to be able to modify opacity (A) for any color.
Have a good day
Beta Was this translation helpful? Give feedback.
All reactions