Skip to content
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

desaturate doesn't work correctly with HSV-created colors #1891

Closed
BrianBelhumeur opened this issue Feb 20, 2014 · 2 comments
Closed

desaturate doesn't work correctly with HSV-created colors #1891

BrianBelhumeur opened this issue Feb 20, 2014 · 2 comments

Comments

@BrianBelhumeur
Copy link

In using 'desaturate' on a color created with hsv(), I find the color that comes out is not what I expect. In the example below, I expect the values for "color" and "background-color" to be identical because the manual assembly of the new hsv() values in "background-color" should be exactly what desaturate() is supposed to be doing in "color". Perhaps Less is running desaturate() as hsl() instead of hsv()?

LESS:

.colortest(@n, @i: 0) when (@i < @n) {
    @color: hsv(259, 30%, 100%);
    @step: 5%;
    @amount: (@step * @i);

    .rule {
        color: desaturate(@color, @amount);
        background-color: hsv(hsvhue(@color), (hsvsaturation(@color) - @amount), hsvvalue(@color));
    }

    .colortest(@n, (@i + 1));
}
.colortest(5);

OUTPUT CSS:

.rule {
  color: #cbb3ff;
  background-color: #cbb3ff;
}
.rule {
  color: #cbb4fd;
  background-color: #d3bfff;
}
.rule {
  color: #ccb6fb;
  background-color: #dcccff;
}
.rule {
  color: #cdb8f9;
  background-color: #e5d9ff;
}
.rule {
  color: #cebaf7;
  background-color: #eee6ff;
}
@seven-phases-max
Copy link
Member

Yes, this is just because desaturate operates in the HSL domain (I guess we're missing this fact in the docs). There's no such thing as a HSL or a HSV color in Less. All Less colors are RGBA internally. See also #1853.

@seven-phases-max
Copy link
Member

OK, I think I close this since it's not a bug and the discussion to improve the situation in general goes at #1853.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants