class Flower { // class name // define variables float x; // x position for upper point float y; // y position for upper point float c; // for curve x float x1; // x position for lower point int diameter; // for size of the ball int diam; // store value for the initial diameter before mouse interaction float speed; // for stem float grow = 1; // for ball float theta = 0.0; float m; // range of movement depending on width boolean mouse; // check if mouse is same position of ball // constructor Flower(float Tempx, float Tempy, float Tempc, float Tempx1,int Tempdiameter,float Tempspeed, float Tempm){ x = Tempx; y = Tempy; c = Tempc; x1 = Tempx1; diameter = Tempdiameter; speed = Tempspeed; m = Tempm; } // functionality // draw stem void drawstem(){ // draw curve //y defines tall of the stem, x determine the x position of the stem, c determines the curve noFill(); stroke(0); curve(c,50, x, y, x1, 420, 950, 900); } // move stem void stemmove() { // make curve moves // see later _easein , easeout effect x = (sin(theta) + 2) * m; theta += speed/20; } //draw ball void ball(){ // draw ball // x and y defines the position of the ball = stem position ellipseMode(CENTER); fill(255); stroke(0); ellipse(x,y,diameter,diameter); // println(diameter); // if mouse if over the ball then call function ballgrow if ( mouse){ growball(); } if (!mouse){ } } void growball(){ // size of the ball increases according with variable grow diameter += grow; //println("growantes" + grow); // condition to create the loop - ball size changes if (( diameter > diam*2) || ( diameter < diam)) { grow = grow*-1; //println(diameter); //println("diam=" +diam); println("growdepois" + grow); } } // mouseover ball_creating interaction void rollover ( int xp, int yp ) { float d = dist(x,y,xp,yp); if (d < diameter/2) { mouse = true; } else { mouse = false; } } }