UNPKG

@webviz/subsurface-viewer

Version:

3D visualization component for subsurface reservoir data

20 lines 790 B
/** * Converts a color represented as an array of numbers (either RGB or RGBA) with 8-bit channel values (0-255) * into a normalized RGBA tuple with values in the range [0, 1]. * * @param color - The input color as an array of numbers. It can be either: * - [r, g, b]: An RGB color, where each channel is a number between 0 and 255. * - [r, g, b, a]: An RGBA color, where each channel is a number between 0 and 255. * @returns A tuple [r, g, b, a] where each value is normalized to the range [0, 1]. */ export function toNormalizedColor(color) { return color ? [ color[0] / 255, color[1] / 255, color[2] / 255, color.length === 3 ? 1 : color[3] / 255, ] : undefined; } //# sourceMappingURL=Color.js.map