Skip to content

Commit

Permalink
Merge branch 'ozan-spin-no-effect'
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrins committed Nov 28, 2015
2 parents 71379c1 + c769578 commit 442010e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,12 @@ test("Spin", function () {
equal (Math.round(tinycolor("#f00").spin(10).toHsl().h), 10, "Spinning 10 works");
equal (Math.round(tinycolor("#f00").spin(360).toHsl().h), 0, "Spinning 360 works");
equal (Math.round(tinycolor("#f00").spin(2345).toHsl().h), 185, "Spinning 2345 works");

[-360, 0, 360].forEach(function (delta) {
Object.keys(tinycolor.names).forEach(function (name) {
equal(tinycolor(name).toHex(), tinycolor(name).spin(delta).toHex(), "Spinning " + delta.toString() + " has no effect")
})
})
});

test("Mix", function () {
Expand Down
2 changes: 1 addition & 1 deletion tinycolor.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ function darken (color, amount) {
// Values outside of this range will be wrapped into this range.
function spin(color, amount) {
var hsl = tinycolor(color).toHsl();
var hue = (mathRound(hsl.h) + amount) % 360;
var hue = (hsl.h + amount) % 360;
hsl.h = hue < 0 ? 360 + hue : hue;
return tinycolor(hsl);
}
Expand Down

0 comments on commit 442010e

Please sign in to comment.