@pbroom/color-kitConversion

linearToSrgbInto

Convert linear RGB (0-1) to sRGB (0-255, rounded and clamped), writing into out (allocation-free). out may be the same object as linear.

functionimport { linearToSrgbInto } from '@pbroom/color-kit';srgb.ts:79
function linearToSrgbInto(  out: Rgb, ,  linear: LinearRgb,): Rgb;

Parameters

outRgb
Object to write the result into
linearLinearRgb
Linear-light RGB color

Returns

Rgbout

Example

TypeScript
import { linearToSrgbInto } from '@pbroom/color-kit';

const rgb = { r: 0, g: 0, b: 0, alpha: 1 };
linearToSrgbInto(rgb, { r: 1, g: 0.2, b: 0, alpha: 1 });
rgb; // → { r: 255, g: 124, b: 0, alpha: 1 }

See also