setAlpha
Return a copy of color with its alpha set to alpha, clamped to [0, 1].
import { setAlpha } from '@pbroom/color-kit';index.ts:159function setAlpha( color: Color, , alpha: number,): Color;Parameters
- alpha
number - New opacity (
0transparent to1opaque)
Returns
ColorA new Color
Example
import { parse, setAlpha, toCss } from '@pbroom/color-kit';
toCss(setAlpha(parse('#3b82f6'), 0.5), 'rgb'); // → 'rgb(59 130 246 / 0.5)'