import traer.physics.*; ParticleSystem physics; Particle[][] particles; int gridSize = 40; void setup() { size(400, 400); smooth(); // noStroke(); noFill(); 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.2, 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() { physics.advanceTime(0.1); // if (mousePressed) // { for (int i = 0; i < gridSize; i++) { particles[i][gridSize - 1].moveTo(mouseX, mouseY, 0); particles[i][0].moveTo(mouseY, mouseX, 0); } // particles[0][gridSize - 1].velocity().clear(); // } background(255); // vizszintes for (int i = 0; i < gridSize; i++) { stroke(i,i,i,200-i*5); 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[i][gridSize - 1].position().x(), particles[i][gridSize - 1].position().y()); endShape(); } /* for (int j = 0; j < gridSize; j++) { beginShape( POLYGON ); curveVertex(particles[0][j].position().x(), particles[0][j].position().y()); for (int i = 0; i < gridSize; i++) { curveVertex(particles[i][j].position().x(), particles[i][j].position().y()); } curveVertex(particles[gridSize - 1][j].position().x(), particles[gridSize - 1][j].position().y()); endShape(); }*/ loadPixels(); color c; for (int i=0;i