Skip to content

Commit

Permalink
Merge pull request #1139 from mgreter/bugfix/issue_1101
Browse files Browse the repository at this point in the history
Add fix for hsla implementation
xzyfer committed Apr 27, 2015

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
2 parents 89338a7 + 79e8d32 commit 20d8870
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion functions.cpp
Original file line number Diff line number Diff line change
@@ -281,11 +281,18 @@ namespace Sass {
s /= 100.0;
l /= 100.0;

if (l < 0) l = 0;
if (s < 0) s = 0;
if (l > 1) l = 1;
if (s > 1) s = 1;
while (h < 0) h += 1;
while (h > 1) h -= 1;

// 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);
else m2 = (l+s)-(l*s);
double m1 = (l*2)-m2;
double m1 = (l*2.0)-m2;
// round the results -- consider moving this into the Color constructor
double r = (h_to_rgb(m1, m2, h+1.0/3.0) * 255.0);
double g = (h_to_rgb(m1, m2, h) * 255.0);

0 comments on commit 20d8870

Please sign in to comment.