// circular motion prototyping float sx,sy; float mx,my; int state; float dark; void setup() { size( 640,480); sx = -50; mx = -50; state = 0; dark = 110; } void draw(){ background( 100,150,200 ); fill( 100,200,100 ); rect( -2,height/4, width+4,height*3/4 ); // dark = constrain(0, 0, 150); noStroke(); fill(0,dark); rect(0,0,width,height); if (state == 0){ drawSun(); } if (state == 1){ drawMoon(); } text(dark,40,height-40); } void drawSun(){ sy = -sqrt(pow(1000,2)-pow(sx-320, 2))+1000; sx= sx+1; fill( 255,255,0 ); ellipse( sx, sy, 40,40 ); if (sx > width+50){ state = 1; sx = -50; } if (sx >-20 && sx<80){ dark = dark -1; } if (sx >560 && sx<660){ dark = dark +1; } } void drawMoon(){ my = -sqrt(pow(1000,2)-pow(mx-320, 2))+1000; mx= mx+1; fill( 255,255,255 ); ellipse( mx, my, 40,40 ); if (mx > width+50){ state = 0; mx = -50; } }