Skip to content

color.srgbToLinear

Summary

color.srgbToLinear decodes normalized sRGB channels before they are used as linear material or geometry colors. Use color.linearToSrgb for the reverse conversion when sending a linear color to a display or CSS. Alpha passes through both functions unchanged.

Syntax

srgbToLinear(color: Color4): Color4
linearToSrgb(color: Color4): Color4
const linear = WasmGPU.color.srgbToLinear([0.5, 0.4, 0.3, 1]);

Parameters

Name Type Required Description
color Color4 Yes RGBA tuple with normalized RGB channels in the input space.

Returns

Color4 - A new tuple with the RGB channels converted and alpha unchanged. Both functions are also named package exports with the same spelling.

Example

const color = WasmGPU.color;
const linear = color.srgbToLinear([0.5, 0.5, 0.5, 0.8]);
const display = color.linearToSrgb(linear);
console.log(display);

See Also