|
@@ -18,10 +18,24 @@ const buildVectorData = (vector, toHue, toLightness, toChroma, toHex) => {
|
|
return { vector, sqMag, mag, unit, hue, lightness, chroma, hex };
|
|
return { vector, sqMag, mag, unit, hue, lightness, chroma, hex };
|
|
};
|
|
};
|
|
|
|
|
|
-const calcImportance = (chroma, lightness, proportion) =>
|
|
|
|
- chroma // used linearly
|
|
|
|
- - Math.abs((Math.max(0.4, lightness) / 0.75) - 1) // reduce contribution for overly light color - probably a highlight - and increase for low light
|
|
|
|
- + 0.5 * Math.tanh(10 * (proportion - 0.25)) // steep ramp centered around 25%
|
|
|
|
|
|
+const calcImportance = (chroma, lightness, proportion) => (
|
|
|
|
+ // scale the final result by 100 just for clarity
|
|
|
|
+ 100
|
|
|
|
+ // ramp the proportion value such that
|
|
|
|
+ // proportion > 85% => basically guaranteed to be most important, gets bonus
|
|
|
|
+ // proportion < 15% => no way to be most important, goes negative
|
|
|
|
+ // otherwise => depend approximately on sqrt(proportion)
|
|
|
|
+ * ( Math.tanh(100 * (proportion - 0.85))
|
|
|
|
+ + Math.tanh(100 * (proportion - 0.15))
|
|
|
|
+ + Math.sqrt(proportion) )
|
|
|
|
+ // consider the chroma based on the sqrt of its part of chroma + lightness
|
|
|
|
+ * Math.sqrt(chroma / (chroma + lightness))
|
|
|
|
+ // ramp the lightness value such that
|
|
|
|
+ // lightness >> 50% => scale by 3
|
|
|
|
+ // lightness << 50% => scale by 1
|
|
|
|
+ // otherwise => slightly steep ramp
|
|
|
|
+ * (2 + Math.tanh(10 * (lightness - 0.5)))
|
|
|
|
+);
|
|
|
|
|
|
const buildClusterData = (size, inertia, mu1, mu2, mu3, nu1, nu2, nu3, totalSize, toHue, toLightness, toChroma, toHex) => {
|
|
const buildClusterData = (size, inertia, mu1, mu2, mu3, nu1, nu2, nu3, totalSize, toHue, toLightness, toChroma, toHex) => {
|
|
const mu = buildVectorData([mu1, mu2, mu3], toHue, toLightness, toChroma, toHex);
|
|
const mu = buildVectorData([mu1, mu2, mu3], toHue, toLightness, toChroma, toHex);
|