if (d2 > 0.1) { // make sure we don't divide by zero
// accelerate towards each attractor
vx += accel * (attractor[i].x-x) / d2;
vy += accel * (attractor[i].y-y) / d2;
}
}
// move by the velocity
x += vx;
y += vy;
// scale the velocity back for the next frame
vx *= damp;
vy *= damp;
}
}
// this is basically just a random point
class Attractor {
float x,y;
Attractor(float x, float y) {
this.x = x;
this.y = y;
}
Attractor() {
x = random(width/8, width/8 *7); // In between 1 and 3 quarters
y = random(height/8, height/8 *7); // of the height and width
}
}
// Use a keypress so thousands of files aren't created
void keyPressed() {
save("Export.png");
}
I didn't make most of this code -- credits are in the comments at the top. I just changed around the variables and added the last part that exports a PNG when a key is pressed, but the export is really low quality. How do I make a high quality export?