//import noc.*; Flock flock; ArrayList a; Flower f; float j = 0; int branchCounter = 0; int flowerSize = 15; void setup() { size(600,200); frameRate(30); colorMode(RGB,255,255,255,100); flock = new Flock(); // Add an initial set of boids into the system for (int i = 0; i < 50; i++) { flock.addBoid(new Boid(new Vector3D(width/2,height/2),2.0f,0.05f)); } background(255); smooth(); // Setup the arraylist and add one branch to it a = new ArrayList(); // A branch has a starting location, a starting "velocity", and a starting "timer" Branch b = new Branch(new Vector3D(50,500),new Vector3D(0f,-0.5f),300f); // Add to arraylist a.add(b); f = new Flower(new Vector3D(50,500),new Vector3D(0f,-0.5f),300f); } void draw() { // Try erasing the background to see how it works // background(100); // Let's stop when the arraylist gets too big if (a.size() < 1024) { // For every branch in the arraylist for (int i = a.size()-1; i >= 0; i--) { // Get the branch, update and draw it Branch b = (Branch) a.get(i); b.update(); f.update(); b.render(random(20,30)-j); j= j+0.00055; // If it's ready to split if (b.timeToBranch()) { a.remove(i); // Delete it a.add(b.branch(45f)); // Add one going right a.add(b.branch(-30f)); // Add one going left print(b.timeToBranch()); branchCounter = branchCounter +1; if (branchCounter>20){ drawFlowerLoc(b.loc); //f.render(); } } } } else{ drawBackground(); fill(255,3); rect(0,0,width, height); flock.run(); /*for (int i = a.size()-1; i >= 0; i--) { // Get the branch, update and draw it Branch b = (Branch) a.get(i); b.update(); if (b.timeToBranch()) { a.remove(i); // Delete it a.add(b.branch(45f)); // Add one going right a.add(b.branch(-30f)); moveFlowerLoc(b.loc); } }*/ } } void drawBackground(){ int wholeImage = width*height/2; loadPixels(); for(int i=0; i < wholeImage; i++) { pixels[i+wholeImage] = pixels[i]; } updatePixels(); } void drawFlowerLoc ( Vector3D loc ) { pushMatrix(); fill(255,0,0,30); float locW = loc.x; float locH = loc.y; fill(255,0,0,50); ellipse(locW+random(8), locH+random(8), flowerSize,flowerSize); ellipse(locW+random(8), locH-random(8), flowerSize,flowerSize); ellipse(locW-random(8), locH+random(8), flowerSize,flowerSize); ellipse(locW-random(8), locH-random(8), flowerSize,flowerSize); popMatrix(); //flock.addBoid(new Boid(new Vector3D(mouseX,mouseY),2.0f,0.05f)); }