xxxxxxxxxx
77
let lengths;
let curTime;
const offsetMinutes = 0;
const acceleration = 1;
function setup() {
createCanvas(600, windowHeight);
lengths = [170,60];
noSmooth()
strokeWeight(1.2)
}
function draw() {
curTime = millis() * acceleration + offsetMinutes * 60000;
// curTime = millis() * mouseX + 6000 * (mouseY-height/2);
let minutes = 71 - (curTime/60000)
if(minutes<61){
background(80,100,80)
} else{ background(100,0,0); }
angleMode(DEGREES)
// stroke(0);
// line( sin(curTime/1000) * width * 2, cos(curTime/1000) * width * 2, width/2,height/2);
for(let i=0;i<minutes;i++){
drawBranch(width/2, height/2, i, minutes, 1, 1, 0);
}
}
function drawBranch(x0, y0, index, maxIndex, superIndex, maxSindex, depth){
if(depth==0){
if(index>60){
stroke(35,50 + 100 * (index-60)/(maxIndex-60),100);
}
else{
stroke(50 + 85 * index/maxIndex,0,50 - 25 * index/maxIndex)
}
}
let angle = (0.4 + 0.2*index/maxIndex) * (600+curTime/100) + superIndex/maxSindex * 360;
let length = (1 + index%4) * index/maxIndex * superIndex/maxSindex * lengths[depth] * 0.5;
let x1 = x0 + sin(angle) * length;
let y1 = y0 + cos(angle) * length;
line(x0,y0,x1,y1);
if(depth<1){
let seconds;
if(index == floor(maxIndex)){
seconds = min( 60 - (curTime/1000) % 60, 60 )
} else{ seconds = 60 }
for(let i=0;i<seconds;i++){
drawBranch(x1, y1, i, seconds, index, maxIndex, depth+1)
}
}
}
// function createBranch(depth){
// let branch = {
// depth: depth,
// rot: random(-15, 15),
// children: [],
// hue: random(90,120)%100,
// index: index
// }
// }