Skip to content

Commit

Permalink
Fix hue modulo operation
Browse files Browse the repository at this point in the history
  • Loading branch information
adroitwhiz authored and Qix- committed Nov 26, 2021
1 parent 65d96a0 commit 9563250
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ cs.get.hsl = function (string) {

if (match) {
var alpha = parseFloat(match[4]);
var h = (parseFloat(match[1]) + 360) % 360;
var h = ((parseFloat(match[1]) % 360) + 360) % 360;
var s = clamp(parseFloat(match[2]), 0, 100);
var l = clamp(parseFloat(match[3]), 0, 100);
var a = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
Expand Down
1 change: 1 addition & 0 deletions test/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ assert.deepEqual(string.get('rgb(100%, 30%, 90%)'), {model: 'rgb', value: [255,
assert.deepEqual(string.get('rgb(100% 30% 90%)'), {model: 'rgb', value: [255, 77, 229, 1]});
assert.deepEqual(string.get('transparent'), {model: 'rgb', value: [0, 0, 0, 0]});
assert.deepEqual(string.get('hsl(240, 100%, 50.5%)'), {model: 'hsl', value: [240, 100, 50.5, 1]});
assert.deepEqual(string.get('hsl(-480, 100%, 50.5%)'), {model: 'hsl', value: [240, 100, 50.5, 1]});
assert.deepEqual(string.get('hsl(240 100% 50.5%)'), {model: 'hsl', value: [240, 100, 50.5, 1]});
assert.deepEqual(string.get('hsl(240deg, 100%, 50.5%)'), {model: 'hsl', value: [240, 100, 50.5, 1]});
assert.deepEqual(string.get('hsl(240deg 100% 50.5%)'), {model: 'hsl', value: [240, 100, 50.5, 1]});
Expand Down

0 comments on commit 9563250

Please sign in to comment.