UNPKG

@kcuf/mere-color

Version:

Mere color utils for generating, manipulation, a11y purposes.

18 lines (17 loc) 554 B
import { rgbMix, toColorStringOriginalNotation } from '../util'; import { parseToRgb } from '../parse'; /** * Mixes two colors together by calculating the average of each RGB channel, returning the new color in the original notation normalized. */ export default function mix(color1, color2, ratio) { var rgb1 = parseToRgb(color1); var rgb2 = parseToRgb(color2); if (!rgb2) { return color1; } if (!rgb1) { return color2; } return toColorStringOriginalNotation(rgbMix(rgb1, rgb2, ratio), color1); } //# sourceMappingURL=mix.js.map