|
@@ -19,22 +19,17 @@ const buildVectorData = (vector, toHue, toLightness, toChroma, toHex) => {
|
|
|
};
|
|
|
|
|
|
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)))
|
|
|
+ // proportion component - linear, with penalties
|
|
|
+ proportion
|
|
|
+ + Math.tanh(100 * (proportion - 0.05)) // penalty for being <5%
|
|
|
+ + Math.tanh(100 * (proportion - 0.15)) // penalty for being <15%
|
|
|
+ + Math.tanh(100 * (proportion - 0.75)) // penalty for being <75%
|
|
|
+ // chroma component - scaled, with penalty
|
|
|
+ + (chroma / (chroma + lightness)) // consider chroma as portion of chroma + lightness
|
|
|
+ + (Math.tanh(10 * (chroma - 0.25))) // penalty for being <25%
|
|
|
+ // lightness component - linear, with penality
|
|
|
+ + lightness
|
|
|
+ + (Math.tanh(10 * (lightness - 0.5))) // penalty for being <50%
|
|
|
);
|
|
|
|
|
|
const buildClusterData = (size, inertia, mu1, mu2, mu3, nu1, nu2, nu3, totalSize, toHue, toLightness, toChroma, toHex) => {
|