Skip to content

@jsvision/core / mix

Function: mix() ​

mix(a, b, t): Color

Defined in: color/ramp.ts:175

Blend two colors in OKLab space.

At t = 0 the result is exactly a and at t = 1 exactly b (both returned verbatim); in between, all three OKLab components interpolate linearly, so the blend crosses perceptual color space rather than raw RGB.

Parameters ​

a ​

Color

The start color (returned as-is at t = 0) — resolvable, not 'default'.

b ​

Color

The end color (returned as-is at t = 1) — resolvable, not 'default'.

t ​

number

The blend position, 0..1.

Returns ​

Color

a, b, or the interpolated #rrggbb midpoint.

Throws ​

InvalidColorError when either color is unresolvable (evaluated even at the endpoints).

Example ​

ts
import { mix } from '@jsvision/core';

mix('#000000', '#ffffff', 0.5); // a perceptual mid-gray