Ok here is my version, the rect() bit is probably not the best, also it doesn’t look at smooth as I expected.
PVector[] points = new PVector[4];
PVector[] cols = new PVector[4];
void setup() {
size(200, 200);
background(100);
frameRate(1);
noLoop();
points[0] = new PVector(50, 50);
points[1] = new PVector(20, 20);
points[2] = new PVector(80, 60);
points[3] = new PVector(120, 120);
cols[0] = new PVector(255, 100, 100);
cols[1] = new PVector(200, 255, 100);
cols[2] = new PVector(0, 100, 200);
cols[3] = new PVector(50, 0, 200);
}
void draw() {
// ellipse(mouseX, mouseY, 20, 20);
for (int x = 0; x < width; x += 1) {
for (int y = 0; y < height; y += 1) {
PVector rgb = new PVector(0, 0, 0);
float d_total = 0;
for (int i = 0; i < points.length; i++) {
// weight by inverse distance, avoid div by 0
float d = 100 / (dist(x, y, points[i].x, points[i].y) + random(-0.001, .001));
PVector incr = PVector.mult(cols[i], d);
// rgb.add(cols[i]);
rgb.add(incr);
d_total += d;
}
rgb.div(d_total);
// rgb.div(points.length);
noStroke();
fill(rgb.x, rgb.y, rgb.z);
rect(x, y, 1, 1);
}
}
filter(BLUR, 5);
}