Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int centerW = width/2, centerH = height/2;
- //DUNE
- int duneVertX, duneVertY, duneBez1X, duneBez1Y, duneBez2X, duneBez2Y, duneBez3X, duneBez3Y, duneBez4X, duneBez4Y, duneBez5X, duneBez5Y, duneBez6X, duneBez6Y, duneVertX2, duneVertY2;
- color duneDayA, duneDayB, duneDuskA, duneDuskB, duneNightA, duneNightB;
- //FOREGROUND
- int foregroundX, foregroundY, foregroundW, foregroundH;
- color fgDay, fgDusk, fgNight;
- //BACKGROUND
- color skyDay, skyDusk, skyNight;
- //FLAG
- int flagX, flagY;
- color flagDay, flagDusk, flagNight, poleDay, poleDusk, poleNight, buryDay, buryDusk, buryNight;
- //SUN
- float sun;
- //BUTTONS
- int buttonX, dayButtonY, duskButtonY, nightButtonY, randomButtonY, buttonSize;
- int dayButtonDist, duskButtonDist, nightButtonDist, randomButtonDist;
- color dayButtonColor, duskButtonColor, nightButtonColor, randomButtonColor;
- PFont buttonFont;
- void setup(){
- size(1000, 530);
- //DUNE
- duneVertX = int(width*.76);
- duneVertY = int(width*.27);
- duneBez1X = int(width*.88);
- duneBez1Y = int(width*.32);
- duneBez2X = int(width*.188);
- duneBez2Y = int(width*.489);
- duneBez3X = int(width*.509);
- duneBez3Y = int(width*.347);
- duneBez4X = int(width*.759);
- duneBez4Y = int(width*.269);
- duneBez5X = int(width*1.499);
- duneBez5Y = int(width*.352);
- duneBez6X = int(width*1.034);
- duneBez6Y = int(width*.882);
- duneVertX2 = int(width*.268);
- duneVertY2 = int(width*.397);
- duneDayA = color(241, 199, 145);
- duneDayB = color(249, 206, 151);
- duneDuskA = color(235, 179, 108);
- duneDuskB = color(244, 185, 111);
- duneNightA = color(126, 94, 53);
- duneNightB = color(134, 100, 57);
- //FOREGROUND
- foregroundX = int(width*-1.5);
- foregroundY = int(width*.325);
- foregroundW = int(width*3);
- foregroundH = int(width*2.5);
- fgDay = color(232, 192, 139);
- fgDusk = color(224, 170, 102);
- fgNight = color(118, 88, 50);
- //FLAG
- flagX = 110;
- flagY = 110;
- flagDay = color(202, 0, 25);
- flagDusk = color(172, 0, 21);
- flagNight = color(114, 0, 14);
- poleDay = color(65, 41, 21);
- poleDusk = color(50, 31, 16);
- poleNight = color(31, 19, 10);
- buryDay = color(214, 166, 79);
- buryDusk = color(186, 140, 83);
- buryNight = color(104, 78, 45);
- //BACKGROUND
- skyDay = color(111, 169, 236);
- skyDusk = color(215, 128, 62);
- skyNight = color(0, 0, 20);
- //SUN
- sun = random(-4.36, -1.97);
- println (sun);
- //BUTTONS
- buttonX = 30;
- buttonSize = 30;
- buttonFont = createFont("Avenir", 16);
- //DAY BUTTON
- dayButtonY = 30;
- dayButtonColor = color(255, 216, 35);
- //DUSK BUTTON
- duskButtonY = 70;;
- duskButtonColor = color(245, 109, 35);
- //NIGHT BUTTON
- nightButtonY = 110;
- nightButtonColor = color(36, 71, 112);
- //RANDOM BUTTON
- randomButtonY = 150;
- randomButtonColor = color(94, 15, 164);
- }
- void draw(){
- //SKY
- //SET SKY COLOR BASED ON SUN POSITION
- if(sun <= -3.26 && sun >= -4.36){
- background (skyNight);
- }
- if(sun <= -1.97 && sun > -3.05){
- background (skyDay);
- }
- if(sun <= -3.05 && sun > -3.26){
- background (skyDusk);
- }
- //SUN
- noStroke();
- //SUN TRANSLATION
- pushMatrix();
- translate(width/2+width/4.5, height*1.6);
- rotate(sun);
- fill(252, 226, 28);
- ellipse(width/2, height, 100, 100);
- popMatrix();
- //END SUN TRANSLATION
- //DUNE LAYER
- pushMatrix();
- //DUNE LAYER MOVEMENT ON MOUSE MOVEMENT
- if(mouseX < centerW || mouseX > centerW){
- translate(-.01*mouseX, 0);
- }
- //DUNE-B TRANSLATION
- pushMatrix();
- translate(-3, -1.25);
- scale(1.006);
- //SET DUNE-B COLOR BASED ON SUN POSITION
- if(sun <= -3.26 && sun >= -4.36);{
- fill(duneNightB);
- }
- if(sun <= -1.97 && sun > -3.05){
- fill(duneDayB);
- }
- if(sun <= -3.05 && sun > -3.26){
- fill(duneDuskB);
- }
- //DUNE-B SHAPE
- beginShape();
- vertex(duneVertX, duneVertY);
- bezierVertex(duneBez1X, duneBez1Y, duneBez2X, duneBez2Y, duneVertX2, duneVertY2);
- bezierVertex(duneBez3X, duneBez3Y, duneBez4X, duneBez4Y, duneVertX, duneVertY);
- endShape();
- popMatrix();
- //END DUNE-B TRANSLATION
- //SET DUNE-A COLOR BASED ON SUN POSITION
- if(sun <= -3.26 && sun >= -4.36);{
- fill(duneNightA);
- }
- if(sun <= -1.97 && sun > -3.05){
- fill(duneDayA);
- }
- if(sun <= -3.05 && sun > -3.26){
- fill(duneDuskA);
- }
- //DUNE-A SHAPE
- beginShape();
- vertex(duneVertX, duneVertY);
- bezierVertex(duneBez5X, duneBez5Y, duneBez6X, duneBez6Y, duneVertX2, duneVertY2);
- bezierVertex(duneBez2X, duneBez2Y, duneBez1X, duneBez1Y, duneVertX, duneVertY);
- endShape();
- popMatrix();
- //END DUNE LAYER
- //FOREGROUND LAYER
- pushMatrix();
- //FOREGROUND LAYER MOVEMENT ON MOUSE MOVEMENT
- if(mouseX < centerW || mouseX > centerW){
- translate(-.04*mouseX, 0);
- }
- //SET FOREGROUND DUNE COLOR BASED ON SUN POSITION
- if(sun <= -3.26 && sun >= -4.36);{
- fill(fgNight);
- }
- if(sun <= -1.97 && sun > -3.05){
- fill(fgDay);
- }
- if(sun <= -3.05 && sun > -3.26){
- fill(fgDusk);
- }
- //FOREGROUND DUNE SHAPE
- ellipseMode(CORNER);
- ellipse(foregroundX, foregroundY, foregroundW, foregroundH);
- //FLAG AND POLE
- //FLAG AND POLE TRANSLATION
- pushMatrix();
- rotate(radians(5));
- translate(60, 30);
- //FLAG
- noStroke();
- //SET FLAG COLOR BASED ON SUN POSITION
- if(sun <= -3.26 && sun >= -4.36);{
- fill(flagNight);
- }
- if(sun <= -1.97 && sun > -3.05){
- fill(flagDay);
- }
- if(sun <= -3.05 && sun > -3.26){
- fill(flagDusk);
- }
- //FLAG SHAPE
- beginShape();
- vertex(flagX, flagY);
- vertex(flagX+(flagX*1.54), flagY+(flagY*.075));
- vertex(flagX+(flagX*1.23), flagY+(flagY*.25));
- vertex(flagX+(flagX*1.54), flagY+(flagY*.425));
- vertex(flagX, flagY+(flagY*.5));
- endShape(CLOSE);
- //POLE
- strokeWeight(5);
- //SET POLE COLOR BASED ON SUN POSITION
- if(sun <= -3.26 && sun >= -4.36);{
- stroke(poleNight);
- }
- if(sun <= -1.97 && sun > -3.05){
- stroke(poleDay);
- }
- if(sun <= -3.05 && sun > -3.26){
- stroke(poleDusk);
- }
- //POLE SHAPE
- line(flagX, flagY, flagX, flagY+200);
- //BURIED FLAGPOLE
- strokeWeight(2);
- //SET BURIED FLAGPOLE COLOR BASED ON SUN POSITION
- if(sun <= -3.26 && sun >= -4.36);{
- stroke(buryNight);
- }
- if(sun <= -1.97 && sun > -3.05){
- stroke(buryDay);
- }
- if(sun <= -3.05 && sun > -3.26){
- stroke(buryDusk);
- }
- //BURIED FLAGPOLE SHAPE
- line(flagX+-15, flagY+202, flagX+15, flagY+202);
- popMatrix();
- //END FLAG AND POLE TRANSLATION
- popMatrix();
- //END FOREGROUND LAYER
- //ICONS
- textFont(buttonFont);
- textAlign(LEFT, CENTER);
- ellipseMode(CENTER);
- imageMode(CENTER);
- //DAY BUTTON
- dayButtonDist = int(dist(buttonX, dayButtonY, mouseX, mouseY));
- //HIGHLIGHT DAY BUTTON ON MOUSEOVER
- if(dayButtonDist<buttonSize/2){
- strokeWeight(2);
- stroke(255);
- }else{
- noStroke();
- }
- //DAY BUTTON SHAPE & ICON
- fill(dayButtonColor);
- ellipse(buttonX, dayButtonY, buttonSize, buttonSize);
- //SHOW "DAY" TEXT ON MOUSEOVER
- if(dayButtonDist<buttonSize/2){
- fill(255);
- }else if(dayButtonDist>buttonSize/2){
- if(sun <= -3.26 && sun >= -4.36){
- fill(skyNight);
- }else if(sun <= -1.97 && sun > -3.05){
- fill(skyDay);
- }else if(sun <= -3.05 && sun > -3.26){
- fill(skyDusk);
- }
- }
- text("Day", (buttonX +15)+7, dayButtonY-2);
- //DUSK BUTTON
- duskButtonDist = int(dist(buttonX, duskButtonY, mouseX, mouseY));
- //HIGHLIGHT DUSK BUTTON ON MOUSEOVER
- if(duskButtonDist<buttonSize/2){
- strokeWeight(2);
- stroke(255);
- }else{
- noStroke();
- }
- //DUSK BUTTON SHAPE & ICON
- fill(duskButtonColor);
- ellipse(buttonX, duskButtonY, buttonSize, buttonSize);
- //SHOW "DUSK" TEXT ON MOUSEOVER
- if(duskButtonDist<buttonSize/2){
- fill(255);
- }else if(duskButtonDist>buttonSize/2){
- if(sun <= -3.26 && sun >= -4.36){
- fill(skyNight);
- }else if(sun <= -1.97 && sun > -3.05){
- fill(skyDay);
- }else if(sun <= -3.05 && sun > -3.26){
- fill(skyDusk);
- }
- }
- text("Dusk", (buttonX+15)+7, duskButtonY-2);
- //NIGHT BUTTON
- nightButtonDist = int(dist(buttonX, nightButtonY, mouseX, mouseY));
- //HIGHLIGHT NIGHT BUTTON ON MOUSEOVER
- if(nightButtonDist<buttonSize/2){
- strokeWeight(2);
- stroke(255);
- }else{
- noStroke();
- }
- //NIGHT BUTTON SHAPE & ICON
- fill(nightButtonColor);
- ellipse(buttonX, nightButtonY, buttonSize, buttonSize);
- //SHOW "NIGHT" TEXT ON MOUSEOVER
- if(nightButtonDist<buttonSize/2){
- fill(255);
- }else if(nightButtonDist>buttonSize/2){
- if(sun <= -3.26 && sun >= -4.36){
- fill(skyNight);
- }else if(sun <= -1.97 && sun > -3.05){
- fill(skyDay);
- }else if(sun <= -3.05 && sun > -3.26){
- fill(skyDusk);
- }
- }
- text("Night", (buttonX+15)+7, nightButtonY-2);
- //RANDOM BUTTON
- randomButtonDist = int(dist(buttonX, randomButtonY, mouseX, mouseY));
- //HIGHLIGHT RANDOM BUTTON ON MOUSEOVER
- if(randomButtonDist<buttonSize/2){
- strokeWeight(2);
- stroke(255);
- }else{
- noStroke();
- }
- //RANDOM BUTTON SHAPE & ICON
- fill(randomButtonColor);
- ellipse(buttonX, randomButtonY, buttonSize, buttonSize);
- //SHOW "RANDOM" TEXT ON MOUSEOVER
- if(randomButtonDist<buttonSize/2){
- fill(255);
- }else if(randomButtonDist>buttonSize/2){
- if(sun <= -3.26 && sun >= -4.36){
- fill(skyNight);
- }else if(sun <= -1.97 && sun > -3.05){
- fill(skyDay);
- }else if(sun <= -3.05 && sun > -3.26){
- fill(skyDusk);
- }
- }
- text("Random", (buttonX+15)+7, randomButtonY-2);
- }
- void mousePressed(){
- //CLICK DAY BUTTON TO SET TIME
- if(dayButtonDist<buttonSize/2){
- if (mousePressed){
- sun = -2.4;
- }
- }
- //CLICK DUSK BUTTON TO SET TIME
- if(duskButtonDist<buttonSize/2){
- if (mousePressed){
- sun = -3.17;
- }
- }
- //CLICK NIGHT BUTTON TO SET TIME
- if(nightButtonDist<buttonSize/2){
- if (mousePressed){
- sun = -4;
- }
- }
- //CLICK RANDOM BUTTON TO RANDOMIZE TIME
- if(randomButtonDist<buttonSize/2){
- if (mousePressed){
- sun = random(-4.36, -1.97);
- }
- }
- }
Add Comment
Please, Sign In to add comment