gka / chroma.js

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

average applies weight to first hue twice #252

Open RichardRobertson opened 3 years ago

RichardRobertson commented 3 years ago

In chroma.average(...) the first color's hue gets weight applied twice. On line 23, xyz[i] is always mutated with the weight before it's checked to see if the current component === 'h'. This means that the cos and sin functions are getting the wrong angle. https://github.com/gka/chroma.js/blob/cb0f8c94c659bc4918b644eb306bf0bfa89c31b1/src/generator/average.js#L21-L30