/* COLOUR HORIZON BY ADAM BRAITHWAITE SEPTEMBER 16, 2018 PROGRAM CREATES A LANDSCAPE THAT CHANGES DEPENDING ON THE MOUSE POSITION INSIDE THE WINDOW OBJECTS CHANGE COLOUR AND SHAPE DEPENDING ON MOUSE X AND Y WHEN NIGHT COMES, THE COLOURS COME ALIVE */ void setup() { //set window size size(400, 400); //set framerate frameRate(60); //no need to draw anything with a stroke noStroke(); } void draw() { //this determines the sky's colour background(mouseX*(400/255), 150, 255-mouseX*(400/255)); //draw sun outer fill(200+mouseX*55/400, 255-mouseX*55/400, 50-mouseX*50/400); ellipse(mouseX-50, (float)1/600*mouseX*mouseX+60, 40+mouseX/2, 40+mouseX/2); //draw inner sun fill(200+mouseX*55/400+50, 255-mouseX*255/400+50, 50-mouseX*50/400+50); ellipse(mouseX-50, (float)1/600*mouseX*mouseX+60, 30+mouseX/2.3, 30+mouseX/2.3); //draw cloud //cloud positioned in relation to mouseY fill(240-mouseX*240/400, 240-mouseX*240/400, 240-mouseX*240/400); ellipse(280+mouseY*1.5-400, 80, 40+5*cos(frameCount*0.05), 40+5*sin(frameCount*0.05)); ellipse(330+mouseY*1.5-400, 70, 60+5*cos(frameCount*0.025), 60+5*sin(frameCount*0.05)); fill(255-mouseX*240/400, 255-mouseX*240/400, 255-mouseX*240/400); ellipse(300+mouseY*1.5-400, 80, 40+5*sin(frameCount*0.05), 40+5*sin(frameCount*0.05)); ellipse(320+mouseY*1.5-400, 100, 40+5*cos(frameCount*0.025), 40+5*sin(frameCount*0.05)); ellipse(360+mouseY*1.5-400, 60, 40+5*sin(frameCount*0.05), 40+5*sin(frameCount*0.05)); //draw hills fill(20-mouseX*20/400, 115-mouseX*115/400, 0); ellipse(-15, 200, 150, 50); ellipse(120, 200, 50, 50); fill(50+mouseX*205/400, 155+mouseX*100/400, 10+mouseX*245/400); ellipse(70, 210, 100, 80); //draw horizon fill(150-mouseX*100/400, 100-mouseX*50/400, mouseX*80/400); rect(0, 200, 400, 200); //draw river fill(50, 100, 150-(mouseX*105/400)); quad(300, 200, 360, 200, 320, 400, 120, 400); //draw shimmers in river stroke(50*sin(frameCount*0.05)+200, 50*sin(frameCount*0.05)+200, 50*sin(frameCount*0.05)+200); line(300, 300, 275, 380); line(260, 300, 220, 360); line(320, 200, 280, 260); stroke(50*sin(frameCount*0.05+PI)+200, 50*sin(frameCount*0.05+PI)+200, 50*sin(frameCount*0.05+PI)+200); line(270, 250, 230, 300); line(330, 280, 320, 310); noStroke(); //BAMBOO GREEN (relative (-30, -50) to original) //draw bamboo static shadow fill(30, 30+mouseX*100/400, 30, 150); ellipse(58-30, 300-50, 30, 10); //draw trailing bamboo shadow fill(30, 30, 30, 150-mouseX*150/400); quad(55-30, 300-50, 61-30, 300-50, 150-mouseX+6-30, 400-50, 150-mouseX-30, 400-50); //draw bamboo main shape fill(150-mouseX*150/400, 200-mouseX*200/400, 0); //main stalk is drawn as a quad so that it may sway quad(55+mouseY/100*cos(frameCount*mouseY/4000)-30, 300-mouseY/2-10-50, 55-30, 300-50, 61-30, 300-50, 61+mouseY/100*cos(frameCount*mouseY/4000)-30, 300-mouseY/2-10-50); ellipse(58, 300, 6, 4);//ellipse to round base of stalk fill(170+mouseX*85/400, 220+mouseX*35/400, mouseX*255/400); ellipse(58+mouseY/100*cos(frameCount*mouseY/4000)-30, 300-mouseY/2-10-50, 6, 4);//ellipse to round top of stalk //BAMBOO BLUE (relative (30, -20) to original) //draw bamboo static shadow fill(30, 30, 30+mouseX*100/400, 150); ellipse(58+30, 300-20, 30, 10); //draw trailing bamboo shadow fill(30, 30, 30, 150-mouseX*150/400); quad(55+30, 300-20, 61+30, 300-20, 150-mouseX+6+30, 400-20, 150-mouseX+30, 400-20); //draw bamboo main shape fill(150-mouseX*150/400, 200-mouseX*200/400, 0); //main stalk is drawn as a quad so that it may sway quad(55+mouseY/100*sin(frameCount*mouseY/4000)+30, 300-mouseY/2-10-20, 55+30, 300-20, 61+30, 300-20, 61+mouseY/100*sin(frameCount*mouseY/4000)+30, 300-mouseY/2-10-20); ellipse(58, 300, 6, 4);//ellipse to round base of stalk fill(170+mouseX*85/400, 220+mouseX*35/400, mouseX*255/400); ellipse(58+mouseY/100*sin(frameCount*mouseY/4000)+30, 300-mouseY/2-10-20, 6, 4);//ellipse to round top of stalk //BAMBOO RED //draw bamboo static shadow fill(30+mouseX*100/400, 30, 30); ellipse(58, 300, 30, 10); //draw trailing bamboo shadow fill(30, 30, 30, 150-mouseX*150/400); quad(55, 300, 61, 300, 150-mouseX+6, 400, 150-mouseX, 400); //draw bamboo main shape fill(150-mouseX*150/400, 200-mouseX*200/400, 0); //main stalk is drawn as a quad so that it may sway quad(55+mouseY/100*sin(frameCount*mouseY/4000), 300-mouseY/2-10, 55, 300, 61, 300, 61+mouseY/100*sin(frameCount*mouseY/4000), 300-mouseY/2-10); ellipse(58, 300, 6, 4);//ellipse to round base of stalk fill(170+mouseX*85/400, 220+mouseX*35/400, mouseX*255/400); ellipse(58+mouseY/100*sin(frameCount*mouseY/4000), 300-mouseY/2-10, 6, 4);//ellipse to round top of stalk //output current mouseX for debug //println(mouseX*255/400); }