//Carly Sacco
//Section C
//csacco@andrew.cmu.edu
//Project 11: Generative Landscape
//creates the components on the water
var waterSpeed = 0.00008;
var waterDetail = 0.0005;
//creates the components for the icebergs
var iceSpeed = 0.0005;
var iceDetail = .05;
//snow array
var snow = [];
function setup() {
createCanvas(480, 280);
//initial collection of snow
for (var i = 0; i < 100; i += 1) {
var flake = random(width);
snow[i] = drawSnow(flake);
}
frameRate(10);
}
function draw() {
//sky
background(176, 203, 245);
//icebergs
noFill();
beginShape();
stroke(255);
for (var x = 0; x < width; x += 1) {
var t = (x * iceDetail) + (millis() * iceSpeed);
var y = map(noise(t), 0,1, height/7, height);
vertex(0, 900)
vertex(width, 800)
vertex(x, y);
}
endShape();
//calls the function to make water
makeWater();
//penguin body
fill('black');
noStroke();
ellipse(280, 220, 35, 40);
ellipse(280, 195, 25, 25);
//penguin stomach
fill('white');
ellipse(280, 225, 25, 45);
ellipse(280, 195, 15, 15);
//penguin eyes
fill('black');
ellipse(276, 191, 3, 3);
ellipse(284, 191, 3, 3);
//penguin body
fill('orange');
triangle(276, 195, 284, 195, 280, 200);
//boat
push();
noStroke();
translate(60, 30);
fill('red')
quad(40, 200, 250, 200, 230, 260, 60, 260);
fill('white');
rect(100, 150, 80, 50);
fill('black')
ellipse(110, 165, 15, 15);
ellipse(140, 165, 15, 15);
ellipse(170, 165, 15, 15);
pop();
//calling the functions to make the snow
snowFall();
drawSnow();
addSnow();
}
//makes the water
function makeWater() {
noFill();
beginShape();
stroke(66, 114, 189);
for (var x = 0; x < width; x++) {
var t = (x * waterDetail) + (millis() * waterSpeed);
var y = map(noise(t), 0,1, height/2, height);
vertex(0, 800)
vertex(width, 800)
vertex(x, y);
}
endShape();
}
//continues to add snow that appears
function addSnow() {
var moreSnow = 5;
if(1 < moreSnow) {
snow.push(drawSnow(height));
}
}
//calls for the snow to appear and move
function snowFall() {
for (i = 0; i < snow.length; i +=1) {
snow[i].displaySnow();
snow[i].moveSnow();
}
}
//actually drawing what the snow looks like
function drawSnow(width) {
var sno = {
x: random(0, 480),
y: 0,
radius: random(5, 10),
speed: 1,
moveSnow: function() {
this.y += this.speed;
},
displaySnow: function() {
noStroke();
fill(255);
ellipse(this.x, this.y, this.radius, this.radius);
},
}
return sno;
}
For my project I had decided I wanted to do a winter themed one since it has started to get very cold here. Therefore, instead of mountains I chose to do icebergs and did that by making the sharp edges seem to be floating by the boat. After I added the snow for my objects and boat to fit the theme I thought it would be cute to add the penguin.