toRgb
Convert a Color to 8-bit sRGB (0-255 per channel).
import { toRgb } from '@pbroom/color-kit';index.ts:92function toRgb(color: Color): Rgb;Out-of-gamut colors are clipped per channel to [0, 255] and every channel is rounded to an integer; alpha passes through unchanged. Use toSrgbGamut first for a perceptual gamut map instead of a clip.
Parameters
Returns
RgbA new Rgb with integer channels
Example
import { parse, toRgb } from '@pbroom/color-kit';
toRgb(parse('#3b82f6')); // → { r: 59, g: 130, b: 246, alpha: 1 }
toRgb(parse('oklch(0.7 0.3 150)')); // → { r: 0, g: 203, b: 0, alpha: 1 } (clipped)