@pbroom/color-kitConversion

linearToSrgb

Convert linear-light RGB (0-1) to 8-bit sRGB (0-255) with the sRGB transfer function. Each channel is rounded to an integer and clipped to [0, 255].

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

Parameters

linearLinearRgb
Linear-light RGB color

Returns

RgbA new Rgb with integer channels

Example

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

linearToSrgb({ r: 1, g: 0.2, b: 0, alpha: 1 }); // → { r: 255, g: 124, b: 0, alpha: 1 }
linearToSrgb({ r: 1.2, g: 0.5, b: -0.1, alpha: 1 }); // → { r: 255, g: 188, b: 0, alpha: 1 }

See also