Warning: session_start(): open(/var/lib/php/sessions/sess_bbrsm0n4kr9nl4hs57637b8ioi, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
// from https://codepen.io/tculda/pen/pogwpOw
/**
* Given some points with color attached, calculate the color for a new point
* @param p The new point position {x: number, y: number}
* @param points The array of given colored points [{x: nember, y: number, c: hexColor}]
* @return hex color string -- The weighted color mix
*/
static Color multiPointGradientPixel(DoublePt p, LPair gradientPoints) {
ret multiPointGradientPixel(p.x, p.y, gradientPoints);
}
static Color multiPointGradientPixel(double px, double py, LPair gradientPoints) {
int n = l(gradientPoints);
double[] colorRatios = new[n];
fillArray(colorRatios, 1);
for i to n:
for j to n:
if (i != j) {
var p1 = gradientPoints.get(i).a;
var p2 = gradientPoints.get(j).a;
d = getProjectionDistance2(p1.x, p1.y, p2.x, p2.y, px, py);
colorRatios[i] *= clampZeroToOne(d[1]);
printVars ifdef multiPointGradientPixel_debug(+p, +i, +j, +p1, +p2, d := asList(d), colorRatio := colorRatios[i]);
}
ret blendMultipleColors(countIteratorAsList(l(gradientPoints),
i -> pair(gradientPoints.get(i).b, colorRatios[i])));
}