/** //// DAY AND NIGHT CYCLE STUDY PROP \\\\ Jenna Klima Mr. Martin 10/28/14 **/ float sunX = 150; float sunY = 150; float setDaycycle = 2; void setup ( ) { size ( 600, 600 ); background ( 200 ); } void draw ( ) { sky ( ); ground ( ); sunMoon ( ); } void ground ( ) { if ( setDaycycle %2 == 0 ) { fill ( 150, 250, 150 ); } else{ fill ( 50, 100, 50 ); } noStroke ( ); rect ( 0, height-201, width, 200 ); stroke ( 0 ); } void sky ( ) { if ( setDaycycle %2 == 0 ) { noStroke ( ); fill ( 150, 150, 250 ); } else{ noStroke ( ); fill ( 75 ); } rect ( 0, 0, width, height / 1.5 ); stroke ( 0 ); } void sunMoon ( ) { float arc = -70 * sin ( PI * sunX / width ); if ( setDaycycle %2 == 0 ) { ellipseMode ( CORNER ); noStroke ( ); fill ( 255, 255, 100 ); ellipse ( sunX - 24, sunY - 24 + arc, 50, 50 ); sunX = sunX + 1; //sun rays strokeWeight ( 3 ); stroke ( 255, 255, 100 ); line ( sunX + 40, sunY + 40 + arc, sunX + 18, sunY + 18 + arc ); line ( sunX - 40, sunY - 40 + arc, sunX - 18, sunY - 18 + arc ); line ( sunX + 40, sunY - 40 + arc, sunX + 18, sunY - 18 + arc ); line ( sunX - 40, sunY + 40 + arc, sunX - 18, sunY + 18 + arc ); line ( sunX, sunY + 25 + arc, sunX, sunY + 55 + arc ); line ( sunX, sunY - 25 + arc, sunX, sunY - 55 + arc ); line ( sunX + 25, sunY + arc, sunX + 55, sunY + arc ); line ( sunX - 25, sunY + arc, sunX - 55, sunY + arc ); } else { fill ( 220 ); } ellipseMode ( CORNER ); noStroke ( ); ellipse ( sunX - 24, sunY - 24 + arc, 50, 50 ); sunX = sunX + 2; //reset sun AND moon (works with both) if ( sunX > width + 10 ) { sunX = 0; //-- sunY = random ( 50, 130 ); setDaycycle = setDaycycle +1 ; } }