import processing.pdf.*; import traer.physics.*; ParticleSystem physics; Particle[][] particles; int gridSize = 80; int posx, posy; float counter=0; boolean record = false; void setup() { if (record) size(800, 800, PDF, "filename.pdf"); else size(600,600); smooth(); // strokeWeight(1); //noStroke(); noFill(); colorMode(HSB, 255); frameRate(60); physics = new ParticleSystem(0.5, 0.05); particles = new Particle[gridSize][gridSize]; float gridStepX = (float) (width / gridSize); float gridStepY = (float) (height / gridSize); for (int i = 0; i < gridSize; i++) { for (int j = 0; j < gridSize; j++) { particles[i][j] = physics.makeParticle(0.4, sin(j/180*3.14) * 10 * gridStepX + (width / 4), cos(i/180*3.14) * 10 * gridStepY + 20, 0.0); if (j > 0) { physics.makeSpring(particles[i][j - 1], particles[i][j], 18.0, 0.01, gridStepX); } } } for (int j = 0; j < gridSize; j++) { for (int i = 1; i < gridSize; i++) { physics.makeSpring(particles[i - 1][j], particles[i][j], 18.0, 0.01, gridStepY); } } particles[0][0].makeFixed(); particles[0][gridSize - 1].makeFixed(); background(255); } void draw() { translate(width/2,height/2); rotate(counter/10); physics.advanceTime(0.1); posx = mouseX; posy = mouseY; posx = round(sin(counter)+sin(counter*10)*cos(counter/2)*500+200); posy = round(cos(counter)*cos(counter/10)*500+200); counter=counter+0.02; for (int i = 0; i < gridSize; i++) { particles[i][gridSize - 1].moveTo(posx,posy, 0); particles[i][0].moveTo(posy, posx, 0); } background(255); for (int i = 0; i < gridSize; i++) { //strokeWeight(abs(posx/100)); translate(i,i); rotate(counter); scale(0.92); //stroke(i,(i*posx*counter)%255,(i*posy*abs(cos(counter)))%255,abs((counter*i*posx))); //noStroke(); fill((i+counter)/100,(i*posx*counter)%255,(i*posy*abs(cos(counter)))%255,abs((i*posx))); //noFill(); beginShape( POLYGON ); curveVertex(particles[i][0].position().x(), particles[i][0].position().y()); for (int j = 0; j < gridSize; j++) { curveVertex(particles[i][j].position().x(), particles[i][j].position().y()); // curveVertex(-particles[j][i].position().x()*0.5, particles[j][i].position().y()*0.5); } curveVertex(particles[i][gridSize - 1].position().x(), particles[i][gridSize - 1].position().y()); endShape(); } if (record) { PGraphicsPDF pdf = (PGraphicsPDF) g; pdf.nextPage(); println(frameCount); if (frameCount == 200) { exit(); } } /* loadPixels(); color c; for (int i=0;i