//***************************************************************************************************/ //* Author: Joo Youn Paek */ //* Description: ICM Midterm Assignment verson 1. for Monday's 3:30 PM Class */ //* A surface filled with Asian waterpainting animation */ //* interaction with mouse release and mouse move */ //* Date: 10/31/2005 */ //***************************************************************************************************/ //Declare global variable boolean start; boolean grow; float growingX; float growingY; //creating leafs boolean startLeaf; int numLeaf = 5; //amount of lines for the leaf //declaring the object(Leafs) from class Leaf Leaf[] Leafs = new Leaf[numLeaf]; //creating seed to trunk //Declare and construct a object "seeds" from the class "Seed" Seed seeds = new Seed(); void setup() { framerate(100); size(700,300); smooth(); noStroke(); background(255); start = true; grow = false; startLeaf = false; } //planting the seed //Distinguish the first mouse press(inflanting seed) between next mouse release(growing the trunk) //using boolean start void mousePressed() { if (start == true) { seeds = new Seed(mouseX, mouseY, random(3,7)); } else if (start == false) { growingX = mouseX; growingY = mouseY; } } void mouseMoved() { if (start == true) { seeds = new Seed(mouseX, mouseY, random(3,7)); } else if (start == false) { growingX = mouseX; growingY = mouseY; } } void mouseReleased() { //position the leafs at mouseX and mouseY for(int i = 0; i < numLeaf; i++) { Leafs[i] = new Leaf(mouseX, mouseY, int(random(2, 6))*10, random(-0.25, 0.25), random(-0.25, 0.25), i); seeds= new Seed(mouseX, mouseY, random(3,7)); } ellipseMode(CENTER); startLeaf = true; grow = true; start = false; } //growing the trunk //Using function growAgain, void draw() { seeds.growAgain(growingX, growingY); seeds.display(); //with the boolean (start) continue to create leafs at same location if (startLeaf == true) { stroke(0, 10); //updating the location of the leaf for(int i=0; i < numLeaf; i++) { Leafs[i].update(); } //moving the lines each time to create various leaf images for(int i=0; i