flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
61
VISUALIZACION/node_modules/polished/lib/internalHelpers/_rgbToHsl.js
generated
vendored
Executable file
61
VISUALIZACION/node_modules/polished/lib/internalHelpers/_rgbToHsl.js
generated
vendored
Executable file
|
|
@ -0,0 +1,61 @@
|
|||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = void 0;
|
||||
function rgbToHsl(color) {
|
||||
// make sure rgb are contained in a set of [0, 255]
|
||||
var red = color.red / 255;
|
||||
var green = color.green / 255;
|
||||
var blue = color.blue / 255;
|
||||
var max = Math.max(red, green, blue);
|
||||
var min = Math.min(red, green, blue);
|
||||
var lightness = (max + min) / 2;
|
||||
if (max === min) {
|
||||
// achromatic
|
||||
if (color.alpha !== undefined) {
|
||||
return {
|
||||
hue: 0,
|
||||
saturation: 0,
|
||||
lightness: lightness,
|
||||
alpha: color.alpha
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
hue: 0,
|
||||
saturation: 0,
|
||||
lightness: lightness
|
||||
};
|
||||
}
|
||||
}
|
||||
var hue;
|
||||
var delta = max - min;
|
||||
var saturation = lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
||||
switch (max) {
|
||||
case red:
|
||||
hue = (green - blue) / delta + (green < blue ? 6 : 0);
|
||||
break;
|
||||
case green:
|
||||
hue = (blue - red) / delta + 2;
|
||||
break;
|
||||
default:
|
||||
// blue case
|
||||
hue = (red - green) / delta + 4;
|
||||
break;
|
||||
}
|
||||
hue *= 60;
|
||||
if (color.alpha !== undefined) {
|
||||
return {
|
||||
hue: hue,
|
||||
saturation: saturation,
|
||||
lightness: lightness,
|
||||
alpha: color.alpha
|
||||
};
|
||||
}
|
||||
return {
|
||||
hue: hue,
|
||||
saturation: saturation,
|
||||
lightness: lightness
|
||||
};
|
||||
}
|
||||
var _default = exports["default"] = rgbToHsl;
|
||||
module.exports = exports.default;
|
||||
Loading…
Add table
Add a link
Reference in a new issue