/** * 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) { double[] colorRatios = new [gradientPoints.length]; fillArray(colorRatios, 1); for i over gradientPoints: for j over gradientPoints: if (i != j) { double d = getProjectionDistance(gradientPoints.get(i).a, gradientPoints.get(i).b, p); colorRatios[i] *= clampZeroToOne(d.d2); } ret blendMultipleColors(points, countIteratorAsList(l(gradientPoints), i -> pair(gradientPoints.get(i).b, colorRatios[i]))); }