Skip to content

Function: mix()

ts
function mix(
   color1, 
   color2, 
   weight?): Color;

Defined in: mix.ts:21

Mix two colors together by a specified weight

Implementation to the Sass mix function. Returns a color that’s a mixture of color1 and color2. Both the weight and the relative opacity of each color determines how much of each color is in the result.

Parameters

ParameterTypeDefault valueDescription
color1ColorundefinedThe first color to be mixed
color2ColorundefinedThe second color to be mixed
weightnumber50The weight to mix the colors by (0-100). Default is 50

Returns

Color

The mixed color

Throws

Invalid Color (color1) if the first color parameter is not a valid color

Throws

Invalid Color (color2) if the second color parameter is not a valid color