xxxxxxxxxx
var s = .5;
//THE RED BODY.
var bodyrotate = 0;
var bodytworotate = 0;
var bodysize = 50;
var bodytwosize = 200;
var bodyincr = 0.3;
var bodytwoincr = 0.3;
var redoff = 20;
var redincr = 0.5;
var tworedoff = 20;
var tworedincr = 0.5;
//THE BLUE BODY.
var blubodyrotate = 2;
var blubodytworotate = 0;
var blubodysize = 200;
var blubodytwosize = 400;
var blubodyincr = 0.3;
var blubodytwoincr = 0.3;
//THE GREEN BODY.
var grbodyrotate = 0;
var grbodytworotate = 0;
var grbodysize = 100;
var grbodytwosize = 500;
var grbodyincr = 0.3;
var grbodytwoincr = 0.3;
function setup() {
createCanvas(windowWidth, windowHeight);
background("PeachPuff");
rectMode(CENTER);
}
function draw() {
background("PeachPuff");
resetMatrix();
rectMode(CENTER);
translate(mouseX, mouseY);
//RED BODY
fill(random(255), 0, 0, 80); //red
stroke(255, 0, 0, 80);
strokeWeight(random(1,5));
push(); //up one level on the drawing stack
translate(redoff, 400);
rotate(bodyrotate);
rect(0, 0, bodysize, bodysize); //body
pop(); //restore
//Internal moving parts----
//modify rotation
if(bodysize>=50 && bodysize<=200)
{
//bodysize increase (rotate faster)
bodysize+=0.6; //grow
bodyrotate+=0.6;
if(bodysize>200) bodysize=50;
}
redoff+=redincr;
if(redoff>20) redincr*=-1;
if(redoff<-20) redincr*=-1;
//RED BODY2
fill(random(255), 0, 0, 80); //red
stroke(255, 0, 0, 80);
strokeWeight(random(1,5));
push(); //up one level on the drawing stack
translate(tworedoff, 400);
rotate(bodytworotate);
rect(0, 0, bodytwosize, bodytwosize); //body
pop(); //restore
//Internal moving parts----
//modify rotation
if(bodytwosize>=50 && bodytwosize<=200)
{
//bodysize increase (rotate faster)
bodytwosize-=0.6; //grow
bodytworotate-=0.6;
if(bodytwosize<50) bodytwosize=200;
}
tworedoff+=tworedincr;
if(tworedoff>20) tworedincr*=-1;
if(tworedoff<-20) tworedincr*=-1;
//GREEN BODY
fill(0, random(255), 0, 50); //green
stroke(0, 255, 0, 80);
strokeWeight(random(1,5));
push(); //up one level on the drawing stack
translate(100, 350);
rotate(grbodyrotate);
rect(0, 0, grbodysize, grbodysize); //body
pop(); //restore
//Internal moving parts----
//modify rotation
if(grbodysize>=100 && grbodysize<=500)
{
//bodysize increase (rotate faster)
grbodysize+=0.8; //grow
grbodyrotate+=0.3;
if(grbodysize>500) grbodysize=100;
}
//GREEN BODY2
fill(0, random(255), 0, 50); //green
stroke(0, 255, 0, 80);
strokeWeight(random(1,5));
push(); //up one level on the drawing stack
translate(100, 350);
rotate(grbodytworotate);
rect(0, 0, grbodytwosize, grbodytwosize); //body
pop(); //restore
//Internal moving parts----
//modify rotation
if(grbodytwosize>=100 && grbodytwosize<=500)
{
//bodysize increase (rotate faster)
grbodytwosize-=0.8; //grow
grbodytworotate-=0.3;
if(grbodytwosize<100) grbodytwosize=500;
}
//BLUE BODY1
fill(0, 0, 255, 50); //blue
stroke(0, 0, 255, 80);
strokeWeight(random(1,5));
push(); //up one level on the drawing stack
translate(80, 280);
rotate(blubodyrotate);
scale(s);
s+=0.005;
if(s>1) s = 0.5;
rect(0, 0, blubodysize, blubodysize); //body
pop(); //restore
//Internal moving parts----
//modify rotation
if(blubodysize>=200 && blubodysize<=400)
{
//bodysize increase (rotate faster)
blubodysize+=0.3; //grow
blubodyrotate+=0.25;
if(blubodysize>400) blubodysize=200;
}
//BLUE BODY2
fill(0, 0, random(255), 50); //red
stroke(0, 0, 255, 80);
strokeWeight(random(1,5));
push(); //up one level on the drawing stack
translate(80, 280);
rotate(blubodyrotate);
scale(s);
s+=0.005;
if(s>1) s=0.5;
rect(0, 0, blubodytwosize, blubodytwosize); //body
pop(); //restore
//Internal moving parts----
//modify rotation
if(blubodytwosize>=200 && blubodytwosize<=400)
{
//bodysize increase (rotate faster)
blubodytwosize-=0.3; //grow
blubodytworotate-=0.25;
if(blubodytwosize<200) blubodytwosize=400;
}
}