2
0
mirror of https://github.com/PitPik/colorPicker.git synced 2025-08-12 19:52:44 -06:00

bugfix in color conversion

@Martin1887 discovered a bug in color conversion if hue is 0
This commit is contained in:
peterd 2014-10-14 22:00:20 +02:00
parent 54ff2e0159
commit 1870a7cf4a
6 changed files with 13 additions and 12 deletions

4
color.all.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -416,8 +416,9 @@
chroma = r - min; chroma = r - min;
s = r ? (chroma / r) : 0; s = r ? (chroma / r) : 0;
return { return {
h: s < 1e-15 ? ((_colors && _colors.hsl.h) || 0) : chroma ? Math.abs(k + (g - b) / (6 * chroma)) : 0, h: s < 1e-15 ? ((_colors && _colors.hsl && _colors.hsl.h) || 0) :
s: r ? (chroma / r) : ((_colors && _colors.hsv.s) || 0), // ??_colors.hsv.s || 0 chroma ? Math.abs(k + (g - b) / (6 * chroma)) : 0,
s: r ? (chroma / r) : ((_colors && _colors.hsv && _colors.hsv.s) || 0), // ??_colors.hsv.s || 0
v: r v: r
}; };
}, },
@ -450,7 +451,7 @@
return { return {
h: hsv.h, h: hsv.h,
s: !hsv.v && !s ? ((_colors && _colors.hsl.s) || 0) : s, // ??? s: !hsv.v && !s ? ((_colors && _colors.hs && _colors.hsl.s) || 0) : s, // ???
l: l / 2 l: l / 2
}; };
}, },

File diff suppressed because one or more lines are too long

View File

@ -142,7 +142,7 @@
} }
} else if (inputIndex !== -1) { } else if (inputIndex !== -1) {
// ... // ...
} else { } else if (colorPickerUI) {
colorPickerUI.style.display = 'none'; colorPickerUI.style.display = 'none';
} }
}; };

File diff suppressed because one or more lines are too long