Skip navigation

// Darren’s Dancing Man

int size_x = 1000;

int size_y = 1000;
int i;

float bodywidth = 75;
float bodyheight = 150;
float L_x = size_x/2 – bodywidth/2;
float L_y = size_y/3;
float R_x = L_x + bodywidth;
float R_y = L_y;
float L_angle1 = 0.0;
float L_angle2 = 0.0;
float R_angle1 = 0.0;
float R_angle2 = 0.0;
float segLength_arm = 50;
float rand_x;
float rand_y;
float rand_col;

void setup() {
size(size_x, size_y);
smooth();
strokeWeight(25.0);
stroke(0, 100);
}

void draw() {
background(25,25,25);
if(keyPressed) {
if (key == ‘z’) {
ellipse(size_x/2,size_y/2-bodyheight/2,500+300,500+300);
if (mousePressed) {
fill(random(255),random(255),random(255));

}
R_angle1 = (mouseX/float(width) – 0.5) * -PI;
R_angle2 = (mouseY/float(height) – 0.5) * PI;

L_angle1 = PI + (mouseX/float(width) – 0.5) * -PI;
L_angle2 = (mouseY/float(height) – 0.5) * PI;

draw_man();
}
if (key == ‘x’) {
ellipse(size_x/2,size_y/2-bodyheight/2,500+125,500+125);
if (mousePressed) {
fill(random(255),random(255),random(255));
}
R_angle1 = (mouseX/float(width) – 0.5) * -PI;
R_angle2 = (mouseY/float(height) – 0.5) * PI;

L_angle1 = PI + (mouseX/float(width) – 0.5) * -PI;
L_angle2 = (mouseY/float(height) – 0.5) * PI;

draw_man();
}
if (key == ‘c’) {
ellipse(size_x/2,size_y/2-bodyheight/2,500 – 50,500 – 50);
if (mousePressed) {
fill(random(255),random(255),random(255));
}
R_angle1 = (mouseX/float(width) – 0.5) * -PI;
R_angle2 = (mouseY/float(height) – 0.5) * PI;

L_angle1 = PI + (mouseX/float(width) – 0.5) * -PI;
L_angle2 = (mouseY/float(height) – 0.5) * PI;

draw_man();
}
i = i +1;
if (i%100 == 0) {
rand_x = random(size_x);
rand_y = random(size_y);
}
ellipse(rand_x,rand_y,100,100);

//if (key == ‘b’) {
// new_rand = random(255);
//}
}
else {
if (mousePressed) {
fill(random(255),random(255),random(255));
}
R_angle1 = (mouseX/float(width) – 0.5) * -PI;
R_angle2 = (mouseY/float(height) – 0.5) * PI;

L_angle1 = PI + (mouseX/float(width) – 0.5) * -PI;
L_angle2 = (mouseY/float(height) – 0.5) * PI;

draw_man();
}

}

void segment(float x, float y, float a, float segLength) {
translate(x, y);
rotate(a);
line(0, 0, segLength, 0);
}

void draw_man() {

rect(L_x,L_y,bodywidth,bodyheight);
ellipse(L_x + bodywidth/2, L_y-bodywidth/2,bodywidth/3,bodywidth/2);
pushMatrix();
segment(R_x, R_y, R_angle1, segLength_arm);
segment(segLength_arm, 0, R_angle2, segLength_arm);
popMatrix();

pushMatrix();
segment(L_x, L_y, L_angle1, segLength_arm);
segment(segLength_arm, 0, L_angle2, segLength_arm);
popMatrix();
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: