I am looking for a way to merge similar hsl colors together by a specific amount. Let's say I have the following three colors: 150, 50, 100
, 149, 49, 100
, 151, 51, 99
. The result I am looking for should be a single value: 150, 50, 100
.
Let me try to explain it better:
Example Data:
const colors = {
red: [
{h:151 , s:57 , l:100},
{h:150 , s:5 , l:100},
{h:155 , s:50 , l:100},
{h:125 , s:100 , l:100},
{h:132 , s:0 , l:100},
],
green: [...],
blue: [...]
}
Now let's say each array contains a lot of items, and I want to reduce the number of items by merging similar items together. The threshold must be a variable. The merging process is simply taking the average of all similar items.
I hope that my explanation is clear, it is quite hard to explain.