colorAdd
Adds two colors together.
Basic example
Section titled “Basic example”Mixes two colors by meeting halfway in HSL: the hue lands between the two along the shorter way around the wheel, and saturation and lightness are averaged. Red and blue give purple, red and yellow give orange.
import {colorAdd} from "@d3plus/color";
colorAdd("#ff0000", "#0000ff");
colorAdd("red", "yellow");
colorAdd("#1c7ed6", "#2f9e44");
With opacity
Section titled “With opacity”The optional third and fourth arguments weight each color from 0 to 1. The weights scale the hue, saturation, and lightness terms before they are averaged, so a partial weight is not a simple fade: at o2: 0.25 red and blue mix to a dark brown, at 0.5 to an olive, and only at 1 to the full purple.
import {colorAdd} from "@d3plus/color";
colorAdd("#ff0000", "#0000ff", 1, 0.25);
colorAdd("#ff0000", "#0000ff", 1, 0.5);
colorAdd("#ff0000", "#0000ff", 1, 1);
Parameters
import {colorAdd} from "@d3plus/color";