For this project, I wanted to document time with an apple tree/ deciduous tree. As the minute passes, the leaves change color from green to red, and at the end of each minute wilt off and blow away. As the hour passes, the ground that the tree is on grows more and more red as the leaves/apples fall to the ground. As the day passes, the background color (sky) gets darker and darker, until the last hour of the day, where it goes totally black. There is also a person under the tree trying to collect the falling foliage/apples.
sketch
var y = 0
function setup() {
createCanvas(420, 480);
background(200,200,255);
text("p5.js vers 0.9.0 test.", 10, 15);
angleMode(DEGREES);
}
function draw() {
var h = hour()
var sky = map(h,0,24,255,0)
background(50,100,sky);
stroke(200)
noFill();
strokeWeight(.5);
ellipse(width/2,height/2.75, 300);
noStroke();
fill(100,60,0)
rect((width/2)-10,height-100,20,-210)
triangle(width/2,height-130,(width/2)-20,height-100,(width/2)+20,height-100)
var m = minute()
var g = map(m,0,60,0,255)
fill(g,255-g,0);
rect(0,height-100,width,100);
translate(width/2,height/2.75);
var s1 = second()
var p = map(s1,0,60,-100,100) fill(10)
rect(p,150,20,40);
ellipse(p+10,140,20);
strokeWeight(3);
stroke(10);
line(p+2,190,p,210)
line(p+18,190,p+20,210)
line(p,150,p-12,170)
line(p+20,150,p+33,170);
strokeWeight(1);
fill(255,255,140);
rect(p-15,170,50,20);
stroke(100,60,0);
strokeWeight(6);
line(0,0,150,0);
line(100,0,150,-30);
line(100,0,150,30);
line(0,0,-150,0);
line(-100,0,-150,-30);
line(-100,0,-150,30);
push(); rotate(120);
line(0,0,150,0);
line(100,0,150,-30);
line(100,0,150,30);
pop();
push(); rotate(60);
line(0,0,150,0);
line(100,0,150,-30);
line(100,0,150,30);
pop();
push(); rotate(-60);
line(0,0,150,0);
line(100,0,150,-30);
line(100,0,150,30);
pop();
push(); rotate(240)
line(0,0,150,0);
line(100,0,150,-30);
line(100,0,150,30);
pop();
var s = second()
var rg = map(s,0,60,0,255) var x = 150
var r = .2
for (var i= 0 ; i < 30 ; i++) {
rotate(15);
x -= r*sin(15);
noStroke();
fill(rg,255-rg,0);
ellipse(x,y,30,15);
ellipse(x-50,y,15,10);
if(s>50 & s<60){
rotate(15);
noStroke();
fill(rg,255-rg,0);
ellipse(x,y,30,15);
ellipse(x-50,y,15,10);
x -= r*sin(15);
y+=r
}
}
}