@pbroom/color-kitConversion

fromRgbInto

Convert sRGB (0-255) to a Color, writing into out (allocation-free). Bit-identical to fromRgb.

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

Parameters

outColor
Color to write the result into
rgbRgb
sRGB color

Returns

Colorout

Example

TypeScript
import { fromRgbInto, toCss } from '@pbroom/color-kit';

const color = { l: 0, c: 0, h: 0, alpha: 1 };
fromRgbInto(color, { r: 59, g: 130, b: 246, alpha: 1 });
toCss(color, 'oklch'); // → 'oklch(0.6231 0.188 259.81)'