gka / chroma.js

JavaScript library for all kinds of color manipulations
https://gka.github.io/chroma.js/
Other
10.19k stars 546 forks source link

How to mix more than 2 colors using weight? #231

Closed mazznoer closed 5 years ago

mazznoer commented 5 years ago
let colors = [
  {
    color: 'black',
    weight: 89,
  },
  {
    color: 'white',
    weight: 121,
  },
  {
    color: 'cyan',
    weight: 9,
  },
  {
    color: 'pink',
    weight: 75,
  },
  {
    color: 'red',
    weight: 13,
  },
];

How to get the average of all the colors using weight?