float spin = 0.0; float diameter = 84.0; float angle; float angle_rot; int rad_points = 90; float rColor = 0; float gColor = 0; float bColor = 0; float aColor= 0; float headX; float headY; float speedX = .7; float speedY = .9; // for puff body int cells = 1000; float[]px= new float[cells]; float[]py= new float[cells]; float[]radiiX = new float[cells]; float[]radiiY = new float[cells]; float[]angleP = new float[cells]; float[]frequency = new float[cells]; float[]cellRadius = new float[cells]; void setup() { size(500, 650); smooth(); // begin in the center headX = width/2; headY = height/2; //fill body arrays for (int i=0; i< cells; i++){ radiiX[i] = random(-29, 29); radiiY[i] = random(-11, 11); frequency[i]= random(-10, 10); cellRadius[i] = random(42, 70); } frameRate(30); } void draw() { background(1, 1, mouseY -80); translate(240, 180); noStroke(); fill(255); angle_rot = 0; if(mouseY > 150) { fill(255, 246, 61, 200); ellipse(0, 0, diameter*80, diameter*80); for(int i=0; i<14; i++) { pushMatrix(); rotate(angle_rot + -18); translate(0, 25); scale(diameter); strokeWeight(2); stroke(255, 246, 61, mouseY/3); noFill(); beginShape(); vertex(15, 40); bezierVertex(5, 0, 80, 0, 50, 55); vertex(30, 45); vertex(25, 75); bezierVertex(50, 70, 75, 90, 80, 70); endShape(); stroke(255, 0, 0, 200); popMatrix(); angle_rot += PI*2/14; } for(int i=0; i<13; i++) { pushMatrix(); rotate(angle_rot + -9); translate(0, 25); scale(diameter); strokeWeight(2); stroke(242, 0, 0, mouseY/ 3); beginShape(); vertex(15, 40); bezierVertex(5, 0, 80, 0, 50, 55); vertex(30, 45); vertex(25, 75); bezierVertex(50, 70, 75, 90, 80, 70); endShape(); stroke(255, 0, 0, 200); popMatrix(); angle_rot += PI*2/13; } diameter = 1 * sin(angle) +.5 ; angle += 0.07; if (angle > TWO_PI) { angle = 0; } } if (mouseY < 150) { fill(255, 246, 61, 200); ellipse(0, 0, diameter * 80, diameter * 80); } { noStroke(); fill(255, 255, 255, 3); translate(-200, -50); //follow the leader for (int i =0; i< cells; i++){ if (i==0){ px[i] = headX+sin(radians(angleP[i]))*radiiX[i]; py[i] = headY+cos(radians(angleP[i]))*radiiY[i]; } else{ px[i] = px[i-1]+cos(radians(angleP[i]))*radiiX[i]; py[i] = py[i-1]+sin(radians(angleP[i]))*radiiY[i]; //check collision of body if (px[i] >= width-cellRadius[i]/2 || px[i] <= cellRadius[i]/2){ radiiX[i]*=-1; cellRadius[i] = random(2, 80); frequency[i]= random(-1, 3); } if (py[i] >= height-cellRadius[i]/2 || py[i] <= cellRadius[i]/2){ radiiY[i]*=-1; cellRadius[i] = random(1, 40); frequency[i]= random(-2, 2); } } // draw puff ellipse(px[i], py[i], cellRadius[i], cellRadius[i]); // set speed of body angleP[i]+=frequency[i]/8; } //check boundary collision of head if (headX >= width-cellRadius[0]/2 || headX <=cellRadius[0]/2){ speedX*=-1; } if (headY >= height-cellRadius[0]/2 || headY <= cellRadius[0]/2){ speedY*=-1; } } }