xxxxxxxxxx
55
function setup() {
createCanvas(400, 400);
}
function draw() {
background(220,220,230);
stroke("black");
fill("white");
rect(10+sin(0.1*frameCount),10+noise(.1*frameCount)*8,
width-20,height/2, 10);
push();
clip(()=>
rect(10+sin(0.1*frameCount),10+noise(.1*frameCount)*8,
width-20,height/2, 10)
);
// sky
let sky = color(135,206,235);
let night = color(14,62,82);
noStroke();
fill( lerpColor(sky,night,(1+sin(.001*frameCount))/2));
rect(0,0,width,height/3+40);
// ground
noStroke();
fill(color(110, 38, 14));
rect(0,height/3,width,height/4);
// hills
noStroke();
fill("green");
beginShape();
vertex( 0 , height/3+50);
for (let i=0;i<width;i++){
let j = (.5*frameCount-i)%width;
vertex( i, height/3- abs(sin(noise(j/width)*80/PI)*8));
}
vertex( width , height/3+50);
endShape(CLOSE);
// poles
stroke("black");
fill("darkgray");
rect(10+(1.6*frameCount%(width*1.2)),50,
10,height/2+40);
stroke("black");
fill("darkgray");
rect((-10+1.8*frameCount%(width*1.1)),0,
14,height/2+40);
pop();
}