This code takes an input from a source and makes the balloon in the display grow larger until it explodes.
float bs = 0; // balloon sizeint cellsize = 2; // Dimensions of each cell in the grid
int columns, rows;
Confetti[] confettis = new Confetti[1000];
int state = 0;
boolean x = false;
private color col;
class Confetti {
private float rotY;
private float rotZ;
private float radius;
private float tempRadius;
private color col;
private float finalZ;
private float tempZ = 0;
Confetti() {
rotY = random(TWO_PI);
rotZ = random(-PI, PI);
radius = pow(random(8000000), .3333);
tempRadius = 0;
col = color(random(100),100,100);
finalZ = random(-1000, 1000);
}
void run() {
update();
display();
}
void update() {
if(state == 0) {
tempRadius = 0;
tempZ = 0;
}
if(state > 0) {
if(tempRadius< radius-0.1) {
tempRadius += ((radius-tempRadius)/10);
}
}
}
void display() {
pushMatrix();
if(state == 2) {
translate(0,tempZ,0);
}
rotateY(rotY);
rotateZ(rotZ);
translate(tempRadius,0,0);
rotateY(HALF_PI);
rotateX(tempRadius/10f);
rotateY(tempRadius/10f);
rotateZ(tempRadius/10f);
scale(0.1+tempRadius/radius);
fill(col);
rect(-5,-5,10,10);
popMatrix();
}
}
void setup() {
colorMode(HSB, 100);
size(600,690, P3D);
background(0);
noStroke();
for(int i = 0; i < confettis.length; i++) {
confettis[i] = new Confetti();
}
}
void draw() {
ambientLight(100,0,100);
colorMode(HSB, 100);
background(0);
ambientLight(100,0,100);
if(x){
state = 1;
}
else{
fill(100,100,100);
triangleShape();
ellipse(width/2, (300)-15, bs, bs*1.2);
arc(width/2, 280, bs, (150)+(1.5*bs), 0,PI); // 180 degrees
}
translate(width/2, height/2, 100);
rotateZ(1.4);
rotateX(.7f);
for(int i = 0; i < confettis.length; i++) {
confettis[i].run();
}
if (mousePressed) {
bs += 1; // change value for different grow rates
}else if(bs >0){
bs -= 2;
}
}
void triangleShape(){
if(bs<300){
if(bs<20 && bs >=0){
fill(0,0,0);
}
}else{
x = true;
}
triangle(width/2,300+bs/(4*PI),290,310+bs,310,310+bs);