Skip to main content
Module

x/colormath/dist/index.d.ts>mixColor

A color conversion and color manipulation library written in typescript for Node.js, Deno and Browser 🎨.
Latest
function mixColor
import { mixColor } from "https://deno.land/x/colormath@1.2.4/dist/index.d.ts";

Mixes two colors.

Examples

mixColor([189, 30, 30], [30, 30, 189]) // [109.5, 30, 109.5] mixColor([189, 30, 30], [30, 30, 189], 0.75) // [149.25, 30, 69.75] mixColor([189, 30, 30], [30, 30, 189], 1) // [189, 30, 30]

mixColor('#e01616', '#6d1e6d').hex; // '#a71a42' mixColor('#e01616', '#6d1e6d', 0.75).hex; // '#c3182c' mixColor('#e01616', '#6d1e6d', 1).hex; // '#e01616'

Parameters

colorA: ColorValue

The rgb values of first color in the form of [r, g, b] array or hex string.

colorB: ColorValue

The rgb values of second color in the form of [r, g, b] array or hex string.

optional
amount: number

The amount of the color to be mixed. Number should be between 0.0 to 1.0. Default value is 0.5.