/** @peep sketch */
/*lden1560 - Lisa Deng - Assessment 1 - Designing With Code
Ocean and Sky
**/
void setup(){
size (400,400);
smooth();
//changing the height of waves
float waveheight =(40*random(0.1,1.8));
//change between sunrise, daytime, sunset, night
int time = int (random(0,4));
if (time == 0) {
night(waveheight);
} else if (time==1){
sunset(waveheight);
} else if (time==2) {
daytime(waveheight);
} else if (time==3) {
sunrise(waveheight);
}
//drawing of seagulls
seagulls();
}
//functions---------------------------------
//WAVE
void wave(int y, color fill, float waveheight){
float wlength=random(90,100); //variation of length of wave
noFill();
stroke(fill);
for (float x=width; x>-100; x=x-wlength){
//variables x,y
float xanchor=x;
float yanchor=y-waveheight;
//wave shape;
strokeWeight(60);
bezier(x,y,xanchor,yanchor,xanchor,yanchor,x-wlength,y);
}
}
//SUN
void sun (int xSun,int ySun,color suncolor) {
noStroke();
fill(suncolor);
ellipse(xSun,ySun,100,100);
}
//MOON
void moon (int xMoon, int yMoon, color mooncolor, color skycolor) {
noStroke();
fill(mooncolor);
ellipse(xMoon,yMoon, 100,100);
fill (skycolor);
ellipse (xMoon-40, yMoon-10, 100, 100);
}
//SEAGULLS
void seagulls(){
//variables
int n = 150;
//determining x,y coordinates of seagull
int[] xseagull=new int [n];
int[] yseagull=new int [n];
for (int i=0; i<150; i++){
xseagull[i] = int(random (0,350));
}
for (int i=0; i<150; i++){
yseagull[i] = int(random (20,170));
}
//controls number of seagulls on pic
int numseagulls = int(random(0,6));
//seagull drawing
stroke(150);
strokeWeight(2);
noFill();
for (int f=0; f<numseagulls; f++){
int x=xseagull[int(random(0,150))];
int y=yseagull[int(random(0,150))];
scale (random(0.7,1));
bezier(x,y,x+5,y-10,x+10,y-5,x+20,y);
x = x+20;
bezier(x,y,x+5,y-5,x+10,y-10,x+20,y);
}
}
//NIGHT
void night (float waveheight) {
//palettes
color[] nightwaves = {#8498D3,#1B2A59,#374C8C,#5679BF};
color[] nightsun = {#B4B4C2,#787887,#FDF0FD,#D40100,#D5D5E5};
color[] nightsky = {#0D0620, #0C082B, #0A0924,#020006};
color skycolor = nightsky[int(random(0,3))];
//drawings
background(int(random(0,3)));
moon (300,100, nightsun[int(random(0,3))], skycolor);
for (int y=250;y<500;y+=40){
wave(y,nightwaves[int(random(0,4))], waveheight);
}
}
//SUNSET
void sunset(float waveheight) {
//palettes
color[] sunsetwaves = {#025E73,#010D00,#D9CDBF,#BF6849};
color[] sunsetsun = {#E82C0C,#E36723,#FF392E,#D40100,#AB0007};
color[] sunsetsky = {#7580BF, #725269, #F29544,#BD4275};
//drawings
background(sunsetsky[int(random(0,3))]);
sun (300,150, sunsetsun[int(random(0,3))]);
for (int y=250;y<500;y+=40){
wave(y,sunsetwaves[int(random(0,4))], waveheight);
}
}
//day
void daytime(float waveheight) {
//palettes
color[] daywaves = {#FFEFE0,#A4DAD5,#5EC7C8,#3FB8A4};
color[] daysun = {#E8AD00,#FFD800,#FFA90D,#E87A00,#FF6100};
color[] daysky = {#70ABE9 , #9CCCF2, #BDE6FA, #FFFFFF};
//drawing
background(daysky[int(random(0,3))]);
sun (200,100, daysun[int(random(0,3))]);
for (int y=250;y<500;y+=40){
wave(y,daywaves[int(random(0,4))], waveheight);
}
}
//sunrise
void sunrise(float waveheight){
//palettes
color[] sunrisewaves = {#509799,#A8CBCC,#A8CBCC,#F9FFFE};
color[] sunrisesun = {#F2EDA7,#F2D5A0,#F2BEA0,#F2DC6B,#F2B950};
color[] sunrisesky = {#ECFFF5, #FFACBB, #CCA8C1,#BD4275};
//drawing
background(sunrisesky[int(random(0,3))]);
sun (100,150, sunrisesun[int(random(0,3))]);
for (int y=250;y<500;y+=40){
wave(y,sunrisewaves[int(random(0,4))], waveheight);
}
}
/* The End **/
Comments
Nobody has said anything yet.