//Mendel by Aaron Steed 2006 //Excessive use of noSmooth & smooth is a patch for the Dell computer this was exhibited on //import processing.video.*; //import processing.opengl.*; //import processing.pdf.*; //video tracking variables //Capture capture; //capture object WhiteMountain graph; //interactive graph object static final int columns = 40; //graph columns to scan static final int imageWidth = 600; //capture width static final int screenWidth = 600; //display width static final int columnWidth = imageWidth / columns; //capture column width static final int screenColumnWidth = screenWidth / columns; //capture column resized to screen static final int speed = 4; //speed of tracking scan static int threshold = 470; //sensitivity to white //Garden variables Garden garden; //Master class to manage garden static final int treeNum = 3; //Quantity of trees and seeds, more that 5 requires editing initColors() ParticleSystem physics; //Physics object for seeds static boolean mouseMode = true; //Drag and drop troubleshooting mode? static final float angleStep = 0.3; //Rate of branch turn in radians static color [] colorTable; //Seed colours static float [] rotationTable; //Seed rotation table Channel [] sound; //Sound effect array static final int podBurstSound = 0; static final int hopperSound = 1; static final int growSound = 2; static final int suckSound = 3; Console console; //Tree to pdf buttons static boolean consoleOn = false; //Draw console? void setup(){ size(600, 600); framerate(24); smooth(); rotationTable = new float[width]; float theta = 0.0; for(int i = 0; i < rotationTable.length; i++){ rotationTable[i] = theta; theta = (theta + 0.1) % TWO_PI; } Ess.start(this); sound = new Channel[4]; sound[podBurstSound] = new Channel("pop.wav"); sound[hopperSound] = new Channel("hopper.wav"); sound[growSound] = new Channel("growth.wav"); sound[suckSound] = new Channel("suck.wav"); initColors(); physics = new ParticleSystem(5.0, 0.05); graph = new WhiteMountain(columns, columnWidth, speed, threshold, false); garden = new Garden(treeNum); console = new Console(treeNum); //capture = new Capture(this, 640, 480, 24); ellipseMode(CENTER); } void draw(){ smooth(); background(0); fill(255); triangle(mouseX, mouseY, mouseX - 150, mouseY, mouseX - 150, mouseY - 150); triangle(mouseX, mouseY, mouseX + 150, mouseY, mouseX + 150, mouseY - 150); loadPixels(); graph.update(g); garden.draw(); graph.draw(); physics.tick(); if(consoleOn){ console.draw(); } } /* void captureEvent(Capture capture){ capture.read(); graph.update(capture); } */ void keyPressed(){ switch(key){ case '+': case '=': graph.threshold += 10; println("Current threshold:"+graph.threshold); break; case '-': case '_': graph.threshold -= 10; println("Current threshold:"+graph.threshold); break; case 'm': case 'M': mouseMode = !mouseMode; println("Drag and drop mode:" + mouseMode); break; case 'p': case 'P': println("Genetic code of current trees:"); garden.printTrees(); break; case 'c': case 'C': consoleOn = !consoleOn; break; } } void mousePressed(){ if(consoleOn){ int choice = -1; for(int i = 0; i < console.button.length; i++){ if(console.button[i].over()){ choice = i; } } if(choice > 0){ beginRecord(PDF, "myTree.pdf"); background(255); if(keyPressed && key == ' '){ for(int i = 0; i < garden.grass.length; i++){ garden.grass[i].draw(); } garden.tree[choice].seed.draw(); } garden.tree[choice].draw(); endRecord(); } } } public void stop() { Ess.stop(); super.stop(); }