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

Fix hue for rgb colors if saturation was zero #2135

Merged
merged 1 commit into from
Aug 3, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,12 @@ namespace Sass {
while (h < 0) h += 1;
while (h > 1) h -= 1;

// if saturation is exacly zero, we loose
// information for hue, since it will evaluate
// to zero if converted back from rgb. Setting
// saturation to a very tiny number solves this.
if (s == 0) s = 1e-10;

// Algorithm from the CSS3 spec: http://www.w3.org/TR/css3-color/#hsl-color.
double m2;
if (l <= 0.5) m2 = l*(s+1.0);
Expand Down