I really wanted to do something with birds, because I have always had the association of birds with time. I thought having the necks grow would be a funny/cute way to represent time, so that’s what I set out to do. Using the time functions was relatively easy, and I thought this was a very enjoyable project. Doing Assignment-06-C definitely helped me when it came to figuring out how to execute my ideas. The only thing I wasn’t sure how to do (without messing up the picture) was how to make the head start off screen. Right now, if it was at midnight, it would show the head starting at the bottom of the canvas instead of slowly coming in.
I originally wanted to do a rooster, but I liked the simpler image of a pigeon-like bird instead.
//Natalie Schmidt
//nkschmid@andrew.cmu.edu
//Section D
//Project-06
var x;
var H;
var M;
var S;
var H2;
var M2;
var S2;
function setup() {
createCanvas(500, 400);
angleMode(DEGREES);
noStroke();
textSize(16);
stroke(1);
}
function draw() {
background(18, 202, 255);
H = hour() % 12;
M = minute();
S = second();
//map out the time so the bird necks
//move with the time
H2 = map(H, 0, 23, 0, height - 25);
M2 = map(M, 0, 59, 0, height - 25);
S2 = map(S, 0, 59, 0, height - 25);
//"second" bird head
fill(255);
//draw the neck
rect(350, height - S2, 100, S2, 60);
push();
stroke(0);
strokeWeight(1);
//draw the white part of eye
fill(240);
ellipse(390, height - (S2 - 25), 35, 35);
fill(0);
//draw the black pupil
ellipse(388, height - (S2 - 20), 20, 20);
pop();
fill(236, 223, 21);
//draw the beak right
triangle(420, height - (S2 - 5), 441, height - (S2 + 15),
431, height - (S2 - 10));
//draw the beak left
triangle(407, height - (S2), 414, height - (S2 + 20),
419, height - (S2 - 4));
//draw the body
fill(252, 158, 255);
rect(320, 300, 105, 100, 60);
//add the bird's "bawk"
fill(0);
var bawk = random(447, 449);
text("Bawk!", bawk, height - (S2 - 25));
// "minute" bird head
fill(255);
//draw the neck
rect(200, height - M2, 100, M2, 60);
push();
stroke(0);
strokeWeight(1);
fill(240);
//white part of eye
ellipse(240, height - (M2 - 25), 35, 35);
fill(0);
//pupil
ellipse(238, height - (M2 - 20), 20, 20);
pop();
fill(236, 223, 21);
//beak right
triangle(270, height - (M2 - 5), 291, height - (M2 + 13),
281, height - (M2 - 10));
//beak left
triangle(257, height - (M2 - 2), 264, height - (M2 + 19),
269, height - (M2 - 5));
//body
fill(242, 208, 255);
rect(165, 300, 115, 100, 60);
fill(0);
bawk = random(298, 300);
text("Bawk!", bawk, height - (M2 - 30));
// "hour" bird head
fill(255);
stroke(1);
//neck
rect(50, height - H2, 100, H2, 60);
push();
stroke(0);
strokeWeight(1);
fill(240);
//white part of eye
ellipse(90, height - (H2 - 25), 35, 35);
fill(0);
//pupil
ellipse(87, height - (H2 - 20), 20, 20);
pop();
fill(236, 223, 21);
//beak right
triangle(117, height - (H2 - 4), 138, height - (H2 + 16),
128, height - (H2 - 9));
//beak left
triangle(104, height - (H2), 111, height - (H2 + 21),
116, height - (H2 - 3));
//body
fill(188, 255, 218);
rect(0, 300, 130, 100, 60);
fill(0);
bawk = random(152, 154);
text("Bawk!", bawk,height - (H2 - 44));
}