@pbroom/color-kitConversion

toRgbInto

Convert a Color to sRGB (0-255, rounded and clamped like toRgb), writing into out (allocation-free).

functionimport { toRgbInto } from '@pbroom/color-kit';into.ts:140
function toRgbInto(  out: Rgb, ,  color: Color,): Rgb;

Parameters

outRgb
Object to write the result into
colorColor
Color to convert

Returns

Rgbout

Example

TypeScript
import { parse, toRgbInto } from '@pbroom/color-kit';

const rgb = { r: 0, g: 0, b: 0, alpha: 1 };
toRgbInto(rgb, parse('oklch(0.7 0.15 30)'));
rgb; // → { r: 237, g: 118, b: 101, alpha: 1 }