mirror of
https://github.com/mue/mue.git
synced 2026-07-17 14:04:09 +02:00
soon
This commit is contained in:
@@ -9,8 +9,13 @@ export default function hexToRgb(value) {
|
||||
const valid = hexRegexp.test(value);
|
||||
|
||||
if (valid) {
|
||||
if (value[0] === '#') value = value.slice(1, value.length);
|
||||
if (value.length === 3) value = value.replace(regexp, '$1$1$2$2$3$3');
|
||||
if (value[0] === '#') {
|
||||
value = value.slice(1, value.length);
|
||||
}
|
||||
|
||||
if (value.length === 3){
|
||||
value = value.replace(regexp, '$1$1$2$2$3$3');
|
||||
}
|
||||
|
||||
const red = parseInt(value.substr(0, 2), 16);
|
||||
const green = parseInt(value.substr(2, 2), 16);
|
||||
|
||||
@@ -3,9 +3,17 @@ export default function rgbToHex(red, green, blue) {
|
||||
let g16 = green.toString(16);
|
||||
let b16 = blue.toString(16);
|
||||
|
||||
if (red < 16) r16 = `0${r16}`;
|
||||
if (green < 16) g16 = `0${g16}`;
|
||||
if (blue < 16) b16 = `0${b16}`;
|
||||
if (red < 16) {
|
||||
r16 = `0${r16}`;
|
||||
}
|
||||
|
||||
if (green < 16) {
|
||||
g16 = `0${g16}`;
|
||||
}
|
||||
|
||||
if (blue < 16) {
|
||||
b16 = `0${b16}`;
|
||||
}
|
||||
|
||||
return r16 + g16 + b16;
|
||||
}
|
||||
|
||||
@@ -18,11 +18,19 @@ export default function rgbToHSv({ red, green, blue }) {
|
||||
gg = diffc(gabs);
|
||||
bb = diffc(babs);
|
||||
|
||||
if (rabs === v) h = bb - gg;
|
||||
else if (gabs === v) h = (1 / 3) + rr - bb;
|
||||
else if (babs === v) h = (2 / 3) + gg - rr;
|
||||
if (h < 0) h += 1;
|
||||
else if (h > 1) h -= 1;
|
||||
if (rabs === v){
|
||||
h = bb - gg;
|
||||
} else if (gabs === v) {
|
||||
h = (1 / 3) + rr - bb;
|
||||
} else if (babs === v) {
|
||||
h = (2 / 3) + gg - rr;
|
||||
}
|
||||
|
||||
if (h < 0) {
|
||||
h += 1;
|
||||
} else if (h > 1) {
|
||||
h -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -10,8 +10,10 @@ export default function setRGBA(red, green, blue, alpha) {
|
||||
blue: blue | 0,
|
||||
};
|
||||
|
||||
if (isValidRGBValue(alpha) === true) color.alpha = alpha | 0;
|
||||
// RGBToHSL(color.r, color.g, color.b);
|
||||
if (isValidRGBValue(alpha) === true) {
|
||||
color.alpha = alpha | 0;
|
||||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user