fettepalette
fettepalette copied to clipboard
Validate your input ranges and throw errors
For example:
type HSX = [number, number, number];
/**
* function hsv2hsl
* @param h {Number} hue value 0...360
* @param s {Number} saturation 0...1
* @param v {Number} value 0...1
* @returns {Array} h:0...360 s:0...1 l:0...1
*/
export const hsv2hsl = (
h: number,
s: number,
v: number,
l: number = v - (v * s) / 2,
m = Math.min(l, 1 - l)
): HSX => {
if (h < 0 || h > 360) {
throw new Error(
`hsv2hsl() hue parameter is expected to be a number between 0 and 360, \`${h}\` given.`
);
}
// ...
return [h, m ? (v - l) / m : 0, l];
};
i might do that for the HSV2HSL function but the main one does not really have max and min's. But it might be practical to do something like that: https://github.com/bit101/quicksettings
export const optionsAndRanges = {
curveMethod: [
'lamé', 'arc', 'pow', 'powY', 'powX'
],
curveAccent: {
min: -0.095, max: 1, step: 0.001
},
colors: {
min: 3, max: 35, step: 1
},
centerHue: {
min: 0, max: 360, step: 0.1
},
hueCycle: {
min: 0, max: 1.5, step: 0.001
},
offsetTint: {
min: 0, max: 0.4, step: 0.001
},
offsetShade: {
min: 0, max: 0.4, step: 0.001
},
offsetCurveModTint: {
min: 0, max: 0.4, step: 0.0001
},
offsetCurveModShade: {
min: 0, max: 0.4, step: 0.0001
},
tintShadeHueShift: {
min: 0, max: 1, step: 0.001
},
minSaturation: {
min: 0, max: 1, step: 0.001
},
minLight: {
min: 0, max: 1, step: 0.001
},
maxSaturation: {
min: 0, max: 1, step: 0.001
},
maxLight: {
min: 0, max: 1, step: 0.001
},
};
It would be easy to import to use with a settings panel like in the demo or something like
@caillou https://github.com/meodai/fettepalette#saint-options