Merge things

This commit is contained in:
David Ralph
2020-11-03 19:15:28 +00:00
10 changed files with 199 additions and 42 deletions

View File

@@ -0,0 +1,21 @@
function isValidRGBValue(value) {
return (typeof (value) === 'number' && Number.isNaN(value) === false && value >= 0 && value <= 255);
}
export default function setRGBA(red, green, blue, alpha) {
if (isValidRGBValue(red) && isValidRGBValue(green) && isValidRGBValue(blue)) {
const color = {
red: red | 0,
green: green | 0,
blue: blue | 0,
};
if (isValidRGBValue(alpha) === true) {
color.alpha = alpha | 0;
}
// RGBToHSL(color.r, color.g, color.b);
return color;
}
}