mixColors
Mixes two colors in sRGB, as CSS color-mix(in srgb, color P%, base) does: percent% of
color and the rest of base. Alpha is interpolated in premultiplied space (CSS Color 4), so a
translucent color weighs less in the result. Opaque colors give a plain weighted average of the
channels.
Available since v3.1.10
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
color | RgbColor | The color to mix in |
base | RgbColor | The color it is mixed into |
percent | number | Share of `color`, from 0 (all `base`) to 100 (all `color`); clamped. Defaults to 50. |
Returns
Section titled “Returns”RgbColor — The straight result: channels rounded to integers, alpha to 3 decimals
Examples
Section titled “Examples”Tint a color toward another
Section titled “Tint a color toward another”The same as color-mix(in srgb, red 25%, blue), usable where there is no CSS engine.
Mix a translucent color
Section titled “Mix a translucent color”Alpha is interpolated in premultiplied space, as CSS Color 4 specifies.
Related Types
Section titled “Related Types”RgbColor
Section titled “RgbColor”An RGB(A) color with channels expressed as plain numbers, convenient for further conversion or manipulation.
