ArrayList clodcols = new ArrayList(); //CloudCol c; void setup() { size(500, 500); sunloc = 125; for(int i = 0; i < 2000; i++){ clodcols.add(new CloudCol(i)); } } float viewpoint; float moveview = 1; float sunloc; float nightness; void mouseMoved(){ adjustFromMouse(mouseX,mouseY); } void mouseDragged(){ adjustFromMouse(mouseX,mouseY); } void adjustFromMouse(float x,float y){ moveview = map(x-250,0,250,0,5); sunloc = map(y,0,500,50,320); nightness = map(constrain(y,0,500),0,500,0,1); } color ORANGE = color(255,128,0);; color DARK_ORANGE = color(200,100,0);; color YELLOW = color(200,200, 60); color PINK = color(255,100, 100); color suncolor = ORANGE; color skycolor = PINK; color cloudcolor = DARK_ORANGE;// color(200,128, 60); color wavecolor = DARK_ORANGE; void draw() { noStroke(); viewpoint += moveview; background(nightness*255,100,(1- nightness) * 200); suncolor = color( map(nightness,0,1,255,255), map(nightness,0,1,255,128), 0 ); wavecolor = cloudcolor = color( map(nightness,0,1,255,200), map(nightness,0,1,255,100), map(nightness,0,1,255,0) ); fill(suncolor); ellipse(250,sunloc,100,100); fill(0, 0, 100); noStroke(); rect(0, 250, 500, 250); // viewpoint = 500-mouseX; int extra = 200; for(int i = -extra; i < 500 + extra; i++){ int lookup = round(viewpoint) + i; while(lookup < 0) lookup += 2000; lookup = lookup % 2000; CloudCol c = clodcols.get(lookup); c.draw(i); } noStroke(); fill(suncolor); int NUMREFLECTIONS = 20; float SPACING = 250 / NUMREFLECTIONS; float reflectwidth = map(sunloc,0,320,100,0); if(reflectwidth > 8){ for(int i = 0; i < NUMREFLECTIONS; i++){ float y = 30*noise(i) + 250 + i * SPACING; ellipse(250+random(-1,1), y ,map(y,250,500,0,1) * reflectwidth,random(3,4)); } } } class CloudCol { ArrayList clouds = new ArrayList(); ArrayList waves = new ArrayList(); float pos; CloudCol(float ppos) { pos = ppos; for (float y = 225; y > 0; y--) { if (random(100) < .05) { clouds.add(new Cloud(y)); } } for (float y = 255; y < 500; y++) { if (random(100) < .05) { waves.add(new Wave(y)); } } } void draw(float x) { for (Cloud c : clouds) { c.draw(x); } for(Wave w : waves){ w.draw(x); } } } class Cloud { float h, sz; color c; Cloud(float ph) { h = ph; sz = map(h, 0, 250, 40, 2); } //i kind of dont understand why the math isn't backwards void draw(float x) { noStroke(); fill(cloudcolor); float modx = getPerspectiveX(x,h); //println("hieght is "+h+"::"+offScaleHeight +" and "+offSide+" = "+(modx-x)); ellipse(modx , h, sz*2, sz); } } class Wave { float h, sz; color c; Wave(float ph) { h = ph; sz = map(h, 500, 250, 10, 2); } // float a = random(PI*2); void draw(float x) { // a += .1; stroke(wavecolor); noFill(); strokeWeight(2); float modx = getPerspectiveX(x,h); //while(a > PI * 2) a -= PI *2; /* float mod = cos(a); mod = map(mod,-1,1,.2,1); println(mod); arc(modx-sz/2, h-sz/2 + mod*sz/4,sz*mod,sz*mod,0,PI/2 ); arc(modx+sz/2, h-sz/2 + mod*sz/4,sz*mod,sz*mod,PI/2 ,PI); */ arc(modx-sz/2, h-sz/2 ,sz,sz,0,PI/2 ); arc(modx+sz/2, h-sz/2 ,sz,sz,PI/2 ,PI); } } float OUTNESS = 3.2; float getPerspectiveX(float ox, float oy){ float distFromMidLine = ox - 250; float distFromHoriz = abs(oy - 250); float mul = map(distFromHoriz,0,250,1,OUTNESS); float r = distFromMidLine * mul; /* println("first diff was "+distFromMidLine +" now is "+r +" because "+mul);*/ return 250 + r; }