question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

blackness and lightness vs sass darken lighten

See original GitHub issue

I am trying to replicate the results of the sass darken and lighten functions using the css color function, however, I am not getting similar results:

/* color-function */
color(#B6FFD4 blackness(30%)) /* #b3b3b3 */

/* sass darken */
darken(#B6FFD4, 30%) /* #1dff7a */

Basically I want a stronger green, which is what I get using sass darken, but I can’t figure out how to replicate those results. Thanks!

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
cyber-snailcommented, Jul 1, 2016

@perrin4869 Yes, right, SASS darken & lighten just change a lightness of color. You can see this with color in HSL (last argument of hsl-color specifies a lightness):

darken(#b6ffd4, 30%) // => #1dff7a

// #b6ffd4 === hsl(144.7, 100%, 85.7%) 
// #1dff7a === hsl(144.7, 100%, 55.7%) 

lightness make the same thing.

Action of blackness you can imagine as a change of blackness argument in HWB-colors hwb(hue, whiteness %, blackness %).

4reactions
perrin4869commented, Jun 19, 2016

@IvanVS I’ve been playing around just now with the functions some more, got some interesting results.

The closest I’ve been able to get to SASS darken function was to use lightness(-15%). blackness goes the opposite way of what I am trying to achieve. Saturation barely seems to change the color, and it doesn’t matter if I use +,-, or just percentage, it is always in the opposite direction of what I want (red, blue to drop, green to remain 255).

I would say that based on my tests, the closest to sass darken is to do lightness(-%), and lighten, lightness(+%)

I can’t really figure out whan blackness is trying to do, and it almost seems as though a darkness function is missing…

Read more comments on GitHub >

github_iconTop Results From Across the Web

sass:color
Returns a gray color with the same lightness as $color . This is identical to color.change($color, $saturation: 0%) . SCSS; Sass ...
Read more >
Sass lighten() and darken() vs mix() using black and white
Sass has color function to lighten and darken colors, but these don't always behave the way you might expect. Using mix() with black...
Read more >
Using lighten() and darken() in SASS - Falkus.co
As the names suggest, given a colour and percentage, these functions will return a colour lighter or darker respectively.
Read more >
Sass Color Functions - TutorialsTeacher
The last component, value, is a measure of the lightness or darkness of a color. Think of a tree with some of its...
Read more >
Controlling color with Sass color functions - Thoughtbot
Darken & Lighten ... These two adjust the Lightness of the color's HSL values. Sass will parse our hex color variable to hsl,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found