mirror of
https://github.com/mue/mue.git
synced 2026-07-23 16:57:25 +02:00
Merge things
This commit is contained in:
21
src/modules/helpers/background/setRgba.js
Normal file
21
src/modules/helpers/background/setRgba.js
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user