Skip to content

Commit

Permalink
Fix the low percentage problem for Saturation
Browse files Browse the repository at this point in the history
  • Loading branch information
casesandberg committed Aug 17, 2015
1 parent 9980a70 commit 6570053
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions modules/tinycolor2/index.js
Expand Up @@ -317,8 +317,8 @@ function inputToRGB(color) {
format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
}
else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) {
color.s = convertToPercentage(color.s);
color.v = convertToPercentage(color.v);
color.s = convertToPercentage(color.s, 1);
color.v = convertToPercentage(color.v, 1);
rgb = hsvToRgb(color.h, color.s, color.v);
ok = true;
format = "hsv";
Expand Down Expand Up @@ -1020,9 +1020,10 @@ function pad2(c) {
}

// Replace a decimal with it's percentage value
function convertToPercentage(n) {
function convertToPercentage(n, multiplier) {
multiplier = multiplier || 100;
if (n <= 1) {
n = (n * 100) + "%";
n = (n * multiplier) + "%";
}

return n;
Expand Down

0 comments on commit 6570053

Please sign in to comment.