// class Nodeflower begin ---------------------------------------- //// class Nodeflower{ float lb;//length of flower based on age of user float xl;//the location of flower based on evaluatin point user gived float swing;//the movement based on noise generate // basic bezier point float x1,y1,cx1,cy1; float cx2,cy2,x2,y2; //update variable; float xmove; float ymove; float yup; float updateX; float updateY; float temxx; //gender x; float genderx; float base; int indexid; int overr; float gap; float sweight; boolean setUpid; boolean isSameId; boolean doCheck; boolean spreadon; //emotion String emotionCap; // direction of sameid int exDirection; Toppart topnodeR; Nodeflower[] other; UserArc shapeSmall, shapeMiddle; // gen noise; GenNoise nxoff; Nodeflower(float lb_, float xl_, float swing_, float weight_,int indexid_, Nodeflower[] x){ //emotionCap = emotion_; lb = lb_; xl = xl_; swing = swing_; indexid = indexid_; setUpid = false; isSameId = false; sweight = weight_; gap = 30; // initiate bezier point xmove = 0.0; ymove = 0.0; base = sh-290-random(0,5); yup=.5; x1 = xl+xmove; cx1 = x1+(lb*0.3)+xmove; y1 = base; cy1 = base; x2 = xl; y2 = base; cx2 = x1; cy2 = base; other = x; //generx genderx =random(-20,20); // userArc shapeSmall = new UserArc(x1, y1, 10, 10, 0.3, 0, 100,indexid); shapeMiddle = new UserArc(x1, y1, 0, 0, 0.6, 1, 190,indexid); // top circle topnodeR = new Toppart(x1,y1,shapeSmall.roundArc/5,indexid); // noise cc nxoff = new GenNoise(x2); } void run(){ nxoff.genNoise(); setUp(); reset(); updatePoint(); shapeSmall.update(x1,y1); shapeSmall.display(); display(); topnodeR.update(); } // need to be outside this class void collidecheck(Nodeflower[] oba){ if(topnodeR.isstop == true){ //println("oba.length : "+oba.length); for(int i = 0 ; i< oba.length ; i++){ float targetx = oba[over].x2; float dis = abs(oba[over].x2-oba[i].x2); if((dis > 0 && dis < 120) && i != over){ sameid = oba[i].getId(); oba[sameid].isSameId = true; oba[sameid].exDirection = oba[sameid].x2 > targetx ? 0 : 1; //indacom decide the direction of expand sidArray = append(sidArray,sameid); } } } } void setUp(){ if(y1>base-lb && setUpid == false){ y1 -=yup; cy1 = y1+ 2*yup; x1 = xl+nxoff.xoff; cx1 = xl; // println(x1); yup+=0.05; } else if(y1<= base-lb){ setUpid = true; } //ymove = nxoff.yoff; } void updatePoint(){ // store x1 value temporally targeup=x1; float temX = xl+swing; temxx = temX; // if(othersOver==false){ //case 01: mouse over on the topnode if(topnodeR.isstop == true){ over = indexid; x1 = temX; updateX = x1; updateY = y1; exDirection = 0; cx1 = x1; cy1 = y1; shapeSmall.b = 1; noStroke(); fill(255); ellipse(x2,y2,8,8); } // case 02: normal: mouseover is false and isSameId is true if(topnodeR.isstop == false && isSameId == false ){ shapeSmall.b = 0; if(setUpid == true){ swing = nxoff.xoff; x1 = xl+swing; cx1 = xl+swing/2; cy1 = y1-swing/3; } } // case 03: mouseover is false and isSameId is true if(topnodeR.isstop == false && isSameId == true && exDirection == 0){ float gapp = xl- nodef[over].xl; gap = 80 + gapp; swing = abs(nxoff.xoff); float increas = 0.4; if(x1< nodef[over].updateX+gap ){ x1 += (nodef[over].updateX+gap-x1)*increas; } if(x1>= nodef[over].updateX+gap){ x1 = nodef[over].updateX+swing+gap; } } if(topnodeR.isstop == false && isSameId == true && exDirection == 1){ float gapp =nodef[over].xl- xl; gap = 80 + gapp; swing = abs(nxoff.xoff); float increas = 0.4; if(x1 >= nodef[over].updateX-gap ){ x1 += (nodef[over].updateX-gap-x1)*increas; } if(x1< nodef[over].updateX-gap){ x1 = nodef[over].updateX-swing-gap; } } } } void reset(){ // check the boolean of collision test doCheck = nodef[over].topnodeR.isstop ? true : false; if(!doCheck){ for(int i=0 ; i Nodeflower//////////////////////////////////////////////////// class Toppart{ float topx; float topy; float topsize; float targetSize; boolean isOver; boolean isLocked; boolean isstop; boolean isOut; int topid; color rCr = color(10,10,10); color reCr = color(10,10,10); color overCr = color(200,100,100); Toppart(float tx, float ty,float targetSize_,int dd){ topx = tx; topy = ty; topsize = 5; isOver = false; isstop = false; isOut = true; topid = dd; targetSize = targetSize_; } void update(){ over(); if(isOver == true && othersOver == false){ isActive = true; rCr = color(rv[topid], gv[topid], bv[topid]); rCr = overCr; //topsize = 10; } else{ rCr = reCr = color(rv[topid], gv[topid], bv[topid]); isstop =false; //topsize = 10; isActive = false; } } void display(float x_,float y_){ topx = x_; topy = y_; fill(rCr); ellipse(x_,y_,topsize,topsize); if(isOver){ stroke(reCr); fill(rCr); ellipse(x_,y_,topsize,topsize); } } void over(){ if(overTop(topx,topy, targetSize)){ isstop =true; isOver = true; isOut = false; } else{ isOver = false; isOut = true; } } boolean overTop(float x_, float y_, float xxx){ float disX = x_ - mouseX; float disY = y_ - mouseY; if (sqrt(sq(disX) + sq(disY)) < xxx ) { return true; } else { return false; } } } ///class Toppart end --> Nodeflower////////////////////////////////////////////////////