week 8: make the sunset last longer
- annaquarrie
- May 2, 2018
- 1 min read

I wanted to create an interactive animation in which the viewer will press the mouse in order to make the sun rise out of the sunset, to make the sunset last longer. The sky also gradually fades to dark as the sun sets, and when the mouse is pressed the sky goes back to blue and the sun rises by a certain amount. I tried to add an ocean sound but the SoundFile command wasn't recognised, and I couldn't understand why.
zip file download;
updated pde file shows sound
//week 8 anna quarrie PImage img; PImage start; float xPos; float yPos; float xRed = 102, xGreen = 156, xBlue = 232; float yRed = 55, yGreen = 30, yBlue = 153; float speed =0.001; float ySpeed=0.5; float opacity; boolean rectShow=true; int click= 0; //import processing.sound.*; //SoundFile ocean;
void setup(){ size(700,500); img = loadImage("beach.jpg"); start = loadImage("start.jpg"); println(img.width); println(img.height); opacity=255; //ocean = new SoundFile(this, "oceanwaves.wav"); //ocean.play();
}
void draw(){ // sunset sky if (click == 0){ image(start,0,0); if (mousePressed == true){ click = 1; } }else{ background(yRed,yGreen,yBlue);
if(rectShow){ fill(xRed, xGreen, xBlue, opacity); stroke(xRed, xGreen, xBlue); rect(0,0,width, height); opacity--; } if (mousePressed){ opacity=255; } //lerpColor
//sun
if (mousePressed == true){ strokeWeight(10); } else{ strokeWeight(3); } fill(255, 204, 0); stroke(252, 237, 179); ellipse(width/2, yPos, 150,150); yPos = yPos + ySpeed; if(mousePressed == true){ yPos= yPos -5; }
//beach jpeg image(img, 0,209, 700,291);
} }
Comments