Open erlandsona opened 3 years ago
Not against adding more operators if they have a clear use and are ergonomic.
Could you post a bit of sample code for what you're talking about with invert and widen specifically?
Just off the top of my head:
Forgot to post my side project https://bitbucket.org/erlandsona/resourcery/src/7ec5cf57f783d872a936ea6afe28b97de6bdee81/lib/Colors.elm#lines-435
There's my implementation of "widen". invert should be in there too.
Weirdly enough what I wanted was to think about colors in hsl (as if I was using the additive colors I learned as a kid) but then I just use hsluv to ensure accessibility by "fudging the brightness" of each "top layer" color (non-greyscale) till it meets accessibility requirements.
You can do it in raw hsl but you have to write a loop/recursion/fold (which is weird to think about with colors) and it gets finicky around the boundary cases...
Just throwing this into the world... are there
invertLightness
&widen
functions planned to add to the library?Given HSLuv is so programable it's pretty easy to think up a way to properly "invert" the brightness of a color scheme while maintaining WCAG Accessibility ratings. Not that Accessbility ratings are things people writing colorschemes care about much, but personally I'd love to be able to just pick my favorite additive colors for certain bits of syntax, editor features, and then be able to flip a switch and have all those colors adjust their relative brightness to the background (grayscale light/dark) without having to re-specify each of the colors for both themes.
I've done this in Elm for a personal project already using elm-hsluv but when I noticed Lush supports hsluv I was like, "I wonder if I can do this in my neovim config too!"
I'll prolly port my "invertLightness" & "widen" (flips a color to 49 / 51 then extends the lightness till it meets AA against a bottom layer) from my side project otherwise.