1/** 2 * Copyright (c) Expo. 3 * Copyright (c) Nicolas Gallagher. 4 * 5 * This source code is licensed under the MIT license found in the 6 * LICENSE file in the root directory of this source tree. 7 */ 8import { processColor } from 'react-native'; 9const isWebColor = (color) => color === 'currentcolor' || 10 color === 'currentColor' || 11 color === 'inherit' || 12 color.indexOf('var(') === 0; 13export function normalizeColor(color, opacity = 1) { 14 if (color == null) 15 return; 16 if (typeof color === 'string' && isWebColor(color)) { 17 return color; 18 } 19 const colorInt = processColor(color); 20 if (colorInt != null) { 21 const r = (colorInt >> 16) & 255; 22 const g = (colorInt >> 8) & 255; 23 const b = colorInt & 255; 24 const a = ((colorInt >> 24) & 255) / 255; 25 const alpha = (a * opacity).toFixed(2); 26 return `rgba(${r},${g},${b},${alpha})`; 27 } 28} 29//# sourceMappingURL=normalizeColor.js.map