top of page

+ PROCESSING   P3   //   JAVA 

ArrayList <lin> lines;
float thold = 2;
float spifac = 2.05;
float drag = 0.003;
int big = 1800;
ball bodies[] = new ball[big];
float mX;
float mY;
void setup() {
lines = new ArrayList <lin>();
size(1280, 720);
strokeWeight(1);
sill(0, 0, 0);
stroke(0, 0, 0, 5);
background(255, 255, 255);   
smooth();
for(int i = 0; i < big; i++) {
bodies[i] = new ball();
void draw() {
if(mousePressed) {
background(255, 255, 255);
mX += 0.5 * (mouseX - mX);
mY += 0.5 * (mouseY - mY);
mX += 0.5 * (mouseX - mX);
mY += 0.5 * (mouseY - mY);
for(int i = 0; i < big; i++) {
bodies[i].render();
lines.add(new lin( new PVector(bodies[i].X, bodies[i].Y), new PVector( bodies[i].pX, bodies[i].pY)));
class ball {
float X;
float Y;
float Xv;
float Yv;
float pX;
float pY;
float w;
ball() {
X = random(width);
Y = random(height);
w = random(1 / thold, thold);
void render() {
if(!mousePressed) {
Xv /= spifac;
Yv /= spifac;
Xv += drag * (mX - X) * w;
Yv += drag * (mY - Y) * w;
X += Xv;
Y += Yv;
line(X, Y, pX, pY);
pX = X;
pY = Y;
void keyPressed() {
if (key == 'q') {
beginRecord 
background(255);
for (int i=0; i<lines.size(); i++){
stroke(0);
lines.get(i).drawLine();
endRecord();
exit();
class lin{
PVector a;
PVector b;
lin(PVector _a, PVector _b){
a = new PVector(_a.x, _a.y);
b = new PVector(_b.x, _b.y);
void drawLine(){
line(a.x,a.y,b.x,b.y);
   

bottom of page