//Lauren Park
//Section D
//ljpark@andrew.cmu.edu
//Project 11
var palms = [];
function setup() {
createCanvas(480, 480);
frameRate(10);
//for loop to randomize
for(i=0;i <10;i++) {
var palmX = random(width);
var palmY = random(20, 40);
palms[i] = makePalm(palmX, palmY);
}
}
function draw() {
background("#00266E");
//moon
fill("#F7E979");
ellipse(360, 80, 65, 65);
noStroke();
fill("#00266E");
ellipse(340, 70, 45, 45);
//beach
fill("#AD9C5E");
ellipse(240, 275, 580, 100);
//ocean
fill("#2D84BA");
rect(0, 280, 480, 200);
//ocean ripples
noStroke();
fill(103,202,221, 150);
for(var i = 0; i < 3; i ++){
var wavex = random(-240, 250);
var wavey = random(8, 250);
var w = random(30, 60);
var h = random(3, 5);
ellipse(width*0.7 + wavex, height * 0.7 + wavey, w, h);
}
fill(117, 223, 215, 150);
for(var k = 0; k < 2; k ++){
var w2x = random(-270, 170);
var w2y = random(-8, 170);
var w2 = random(30, 60);
var h2 = random(3, 5);
ellipse(width*0.7+ w2x, height *0.7 +w2y, w2, h2);
}
updatePalm();
}
function updatePalm() {
for(j=0;j<palms.length;j++){
palms[j].move();
palms[j].draw();
}
}
function movePalm() {
this.x += this.speed;
if(this.x < -130) {
this.x += width
}
}
function drawPalm() {
push();
translate(this.x, this.y);
stroke("#694000");
fill("#884400");
rect(150, 160, 13, 68);
stroke("#3C5E00");
fill("green");
ellipse(150, 155, 40, 13);
ellipse(140, 150, 43, 13);
ellipse(170, 150, 43, 13);
ellipse(140, 160, 43, 13);
ellipse(170, 160, 43, 13);
pop();
}
function makePalm(plocationX, plocationY) {
var palmtree = {x:plocationX,
y:plocationY,
breadth:10,
palmW:random(50, 80),
palmH: random(10, 15),
speed:-15,
move: movePalm,
draw: drawPalm}
return palmtree;
}
I wows inspired by where I grew up, which is in California and thought of creating a landscape that displays palm trees, the beach, and ocean within a night scene. It was very challenging for me to properly randomize some of the objects at first, that made the whole scene flow when it was running. However, I did enjoy putting thought and colors into creating a new environment that allowed me to express something personal.