react-native-web-internals
Version:
React Native for Web
19 lines (18 loc) • 733 B
JavaScript
import isWebColor from "../../modules/isWebColor/index.mjs";
import { processColor } from "../../modules/processColor/index.mjs";
const normalizeColor = (color, opacity = 1) => {
if (color == null) return;
if (typeof color == "string" && isWebColor(color)) return color;
const colorInt = processColor(color);
if (colorInt != null) {
const r = colorInt >> 16 & 255,
g = colorInt >> 8 & 255,
b = colorInt & 255,
alpha = ((colorInt >> 24 & 255) / 255 * opacity).toFixed(2);
return `rgba(${r},${g},${b},${alpha})`;
}
if (typeof color == "string") return color;
};
var normalizeColor_default = normalizeColor;
export { normalizeColor_default as default };
//# sourceMappingURL=normalizeColor.mjs.map