Zee Salman- Project 11- Landscape

sketch

// Zee Salman
//fawziyas@andrew.cmu.edu
//Project-11
//section E

var trees = []
var terrain = 0.005;
var midTerrain = 0.016;
var lowTerrain = 0.020;
var terrainSpeed = 0.0004;
var rate = 0.007; 

function setup() {
    createCanvas(400, 400);
    frameRate(300);  
    }
function draw() {
    //background 
    fill(163,221,255);
    rect(0,0,width,height);
    
    //sun 
    noStroke();
    fill(255,228,26);  
    ellipse(width-60, 70, 80, 80);
    
    //mountain 
    mountains(); 
    addT();
    removeT();
    newT();
    ground(); 
}


function removeT(){
    //takes away trees
    var treesKeep = [];
    for (var i = 0; i < trees.length; i++){
        if (trees[i].x + trees[i].breadth > 0) {
            treesKeep.push(trees[i]);
        }
    } 
    trees = treesKeep;
}



function addT(){
    // x coordinate 
    for (var i = 0; i < trees.length; i++){
        trees[i].move();
        trees[i].display();
    }
}


function newT() {
    // new tree on screen
    if (random(0,1) < rate) {
        trees.push(drawT(width));
    }
}


function treesMove() {
    this.x += this.speed;
}
    
//show trees
function treesDisplay() {
    
    //bottom
    strokeWeight(8);
    stroke(120, 79, 25);
    line(this.x, 350, this.x, 420);

    //top
    noStroke();
    fill(48,67,7);
    triangle(this.x - 30, 360, this.x + 30, 360, this.x, 300);
}


function drawT(px) {
    var bx = {x: px,
                breadth: 20,
                speed: -1.0,
                move: treesMove,
                display: treesDisplay}
    return bx;
}

function ground() {
    noStroke(); 
    fill("grey");
    rect(0, height-25, width, height/5);
}

function mountains() {
    //creates mountains 
    beginShape(); 
    stroke(43, 99,41);
    for (var x = 0; x < width; x++) {
        var q = (x * terrain) + (millis() * terrainSpeed);
        var m = map(noise(q), 0, .95, 300, 3);
        line(x, m, x, height); 
    }
    endShape();

   
    
    beginShape(); 
    stroke(76, 160, 73);
    for (var x = 0; x < width; x++) {
        var q = (x * midTerrain) + (millis() * terrainSpeed);
        var m = map(noise(q), 0, .75, 250, 200);
        line(x, m, x, height); 
    }
    endShape();

    
    beginShape(); 
    stroke(120, 205, 117);
    for (var x = 0; x < width; x++) {
        var q = (x * lowTerrain) + (millis() * terrainSpeed);
        var m = map(noise(q), 0, 3, 300, 250);
        line(x, m, x, height); 
    }
    endShape();
}



sketch for landscape

I was very interested in this project because it would never be the same when the landscape would pass by. It reminds me of when I go on a road trip and stick my head out the car window. The scenes change all the time. That is where I got my inspiration from to do this project.

Lauren Park – Project 11 – Landscape

sketch

//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.

Stefanie Suk – Project 11- Landscape

sketch

//Stefanie Suk
//15-104 D
//ssuk@andrew.cmu.edu
//Project-11-Landscape

let car = [];
let num = 10; //number of cars

function setup() {
  createCanvas(400, 400);

  for (let i = 0; i < num; i++) {
    car[i] = new Car(random(height),
      random(width),
      color(random(255), random(255), random(255)), //color of car
      random(1, 7), //car speed
      random(10, 100) //car size
    );
    print(car[i]);
  }

}

function draw() {
  background(0, 41, 58);

  fill(241, 244, 15);
  ellipse(300, 50, 5, 5);
  ellipse(270, 74, 5, 5);
  ellipse(130, 50, 5, 5);
  ellipse(20, 80, 5, 5);
  ellipse(360, 100, 5, 5);
  ellipse(70, 160, 5, 5);
  ellipse(230, 140, 5, 5);
  ellipse(330, 170, 5, 5);
  ellipse(180, 230, 5, 5); //stars 

  fill(200);
  rect(0, 300, 400, 30);
  fill(200);
  rect(0, 290, 400, 3);
  fill(200);
  rect(80, 70, 30, 330);
  fill(200);
  rect(320, 70, 30, 330);
  stroke(200);
  strokeWeight(5);
  line(95, 90, 215, 315)
  stroke(200);
  strokeWeight(5);
  line(95, 90, 0, 275)
  stroke(200);
  strokeWeight(5);
  line(335, 90, 215, 315);
  stroke(200);
  strokeWeight(5);
  line(335, 90, 400, 220); //bridge


  for (let i = 0; i < 10; i++) {
    car[i].move();
    car[i].display(); //making cars show
  }
}



class Car {
  constructor(x, y, z, s, l) {
    this.x = x;
    this.y = y;
    this.z = z; //color of car
    this.l = l; //length of car
    this.speed = s; //speed
  }
  
  move() {
    this.x = this.speed + this.x; //making cars move
    if (this.x > width) {
      this.x = 0; //where the cars come out
    }
  }

  display() {
    noStroke();
    fill(this.z);
    rect(this.x, 270, this.l, 30, 20); //position of cars moving, adjusting shape of cars 
  }
}

Recently, I went outside with my friends to see the night view of Pittsburgh near downtown. I wanted to create what I saw that day by creating what I think is the most symbolic landscape of Pittsburgh, the yellow bridge. I created an illustration of the yellow bridge and the night sky, and made the cars in different lengths and colors move across the bridge. The yellow bridge and the night sky with stars are static because I wanted to emphasize the movement of the vehicles. The cars are coded to move from left to right in different speeds, lengths, and colors to represent the diversity of vehicles I saw the day I went out.

Sketch on Paper
Sketch on Illustrator

Hyejo Seo-Project 11 – Landscape

sketch

/*
Hyejo Seo
Section A
hyejos@andrew.cmu.edu
Project-11-landscape 
*/
var c1, c2; // for gradient
var smile = [];

function setup() {
    createCanvas(480, 480);
    frameRate(50);
    //setting up background gradient 
    c1 = color(15, 113, 115);
    c2 = color(240, 93, 94);
    
}

function draw() {
    gradient(c1, c2); // background color
    drawMountains();
    desert();
    drawSun();
    updateSmile();
    deleteSmile();
    addSmile();
}
// setting up gradient for the sky
function gradient(c1, c2) {
    noFill();
    noStroke();
    for (var y = 0; y < height; y++) {
        var inter = map(y, 0, height, 0, 1);
        var c = lerpColor(c1, c2, inter);
        stroke(c);
        line(0, y, width, y);
      }
}

function drawMountains () { // drawing mountains by using terrain
    var terrainSpeed = 0.0005;
    var terrainDetail = 0.006;
    stroke(47, 57, 94);
    noFill();
    beginShape();
    for (var x = 0; x < width; x++) {
        var t = (x * terrainDetail) + (millis() * terrainSpeed);
        var y = map(noise(t), 0, 1, height / 2, height);
        line(x, y, x, height); //draws lines from the points of terrain to the bottom of the canvas
    }

    endShape();
}
function desert () { //drawing the dessert land 
    fill(216, 164, 127);
    noStroke();
    beginShape();
    vertex(0, height - 60);
    vertex(width, height - 60);
    vertex(width, height);
    vertex(0, height);
    endShape(CLOSE);

}
function drawSun() { // drawing sun at a suspended location
    fill(216, 30, 91);
    circle(400, 200, 50);
}

function updateSmile() {
    for(var i = 0; i < smile.length; i++) {
        smile[i].move();
        smile[i].draw();
    }
}

function deleteSmile() {
    var smileToKeep = [];
    for(var i = 0; i < smile.length; i++) {
        if(smile[i].xx + smile[i].w > 0) {
            smileToKeep.push(smile[i]);
        }
    }
    smile = smileToKeep;
}
function addSmile() {
    var newSmile = 0.008;
    if (random(1) < newSmile) {
        smile.push(makeSmile(width, random(450, 480)));
    }
}
function moveSmile() {
    this.xx += this.speed; // moving the smiles to the left
}
function drawSmile() {
// drawing the face 
    stroke(56, 63, 81);
    strokeWeight(2);
    fill(255, 120, 79);
    push();
    translate(this.xx, this.yy);
    circle(0, -this.hh, this.w);
    pop();
//drawing the eyes
    fill(56, 63, 81);
    noStroke();
    push();
    translate(this.xx, this.yy);
    ellipse(-5, -this.hh - 5, 6, 13);
    ellipse(5, -this.hh - 5, 6, 13);
    pop();
//drawing mouth 
    stroke(56, 63, 81);
    strokeWeight(2);
    noFill();
    push();
    translate(this.xx, this.yy);
    arc(0, -this.hh + 5, 20, 15, TWO_PI, PI);
    pop();

}
function makeSmile(birthLocationX, birthLocationY) {
    var sm = {xx: birthLocationX, yy: birthLocationY,
        w: random(30, 50), hh: random(10, 30), speed: -1,
        move: moveSmile, draw: drawSmile}
    return sm;
}

For this project, I wanted to add an element of surprise to my landscape: smiley faces. I roughly sketched out my plan (as seen below) after being inspired by pictures of the desert in Arizona. This is why I chose the light brown for the land – sandy and dry – and darker and colder blue for the mountains. to convey that they are really far away. Overall, this project helped me feel more comfortable with drawing objects. 

My rough sketch for this project
Picture of a desert in Arizona that inspired overall landscape and color schemes.

Yoshi Torralva-Generative Landscape

sketch

//Yoshi Torralva
//yrt@andrew.cmu.edu
//Section-E
//Project-11-Generative-Landscape 
var runningTree = [];

function setup() {
    createCanvas(480, 480); 
        //placing trees on first canvas frame
        for (var i = 0; i < 10; i++){
        var rx = random(width);
        runningTree[i] = runningTreeObject(rx);
    }
    frameRate(8);
}
function draw() {
    background(18, 36, 64); 
    fill(255, 240, 186);
    ellipse(100, 200, 100, 100)
    fill(18, 36, 64); 
    ellipse(120, 190, 80, 80)
    fill(74, 74, 7);
    //back horizon line
    rect(0, 400, width, 200);
    //adding functions to move trees across canvas
    updateRunTree();
    removeTree();
    addingTrees(); 
    //front horizon line
    fill(51, 54, 1);
    rect(0, 420, width, 200);
}
//updating tree movement
function updateRunTree(){
    for (var i = 0; i < runningTree.length; i++){
        runningTree[i].move();
        runningTree[i].display();
    }
}
//deleting trees after leaving canvas
function removeTree(){
    var keepTreeLoop = [];
    for (var i = 0; i < runningTree.length; i++){
        if (runningTree[i].x + runningTree[i].widthTree > 0) {
            keepTreeLoop.push(runningTree[i]);
        }
    }
    runningTree = keepTreeLoop;
}
//adding new trees
function addingTrees() {
    var randomTreeAdding = 0.1; 
    if (random(0,1) < randomTreeAdding) {
        runningTree.push(runningTreeObject(width));
    }
}
//moving the tree everytime it is redrawn
    function movingTree() {
    this.x += this.speed;
}
// draw the building and some windows
function Tree() {
    var minHeightOfTree = 60;
    var treeHeight = this.heightOfTree * minHeightOfTree; 
    noStroke(); 
    push();
    //moving bases to the bottom horizon line 
    translate(this.x, 420);
    //tree stumps
    fill(this.wood); 
    rect(0, -treeHeight, this.widthTree, treeHeight);
    //greenery of the tree
    //variations of green called from the tree object
    fill(this.colors);
    ellipse(random(10,20), -treeHeight + random(10,15), treeHeight, treeHeight);
    //for loop made to show motion of trees in the grass
    //10 opaque variations of the dust from running trees
    for (var i = 0; i < 10; i++) {
        fill(20,0,0,30);
        noStroke();
        //random location not made in object as it redraws
        ellipse(random(10, 50), random(10,50), this.scaleOfGreens, this.scaleOfGreens);
    }
    pop();
}
function runningTreeObject(startX) {
    var object = {x: startX,
        widthTree: 20,
        speed: -5.0,
        //multiply to randomize height of tree
        heightOfTree: round(random(1, 20)),
        //size of tree bush
        scaleOfGreens: round(random(100,300)),
        move: movingTree,
        display: Tree,
        //varied green color
        colors: randomColor(),
        //varied wood color
        wood: randomWoodColor()
        }
    return object;
}
//color of leaves
function randomColor() {
    return [Math.floor(random(0)), Math.floor(random(30,100)), Math.floor(random(10,20))]
}
//varied color of wood
function randomWoodColor() {
    return [Math.floor(random(20,50)), Math.floor(random(0,20)), Math.floor(random(0))]
}

Initial sketch of Generative Landscape

With this project, I wanted to generate a landscape that would give dynamic motion to actual elements in the landscape. I decided to give movement to the trees as if they were running on the ground. I added varied opaque clouds that show trailing dirt clouds. I placed made the background night time with a moon to depict the trees running in the night.

Mari Kubota- Project 11- Landscape

sketch

/*  Mari Kubota
    49-104 Section 1
    mkubota@andrew.cmu.edu 
    Project 11
*/

var lamps = [];
var stars = [];
var buildings = [];


function setup() {
    createCanvas(480, 280); 

    // create an initial collection of objects
    for (var i = 0; i < 10; i++){
        var rx = random(width);
        lamps[i] = makeLamp(rx);
        stars[i] = makeStar(rx);
        buildings[i] = makeBuilding(rx);
    }
    frameRate(10);
}


function draw() {
//creates gradient sky
	c1 = color(0, 28, 84);
    c2 = color(222, 241, 255);
    setGradient(c1, c2);

//creates roads
    noStroke();
    fill(100);
    rect(0, height*.75, width, height/4);
    fill(200);
    stroke(50);
    rect(0,height*.9, width, height/9);
//calls functions with objects     
    updateAndDisplayStars();
    removeStarsThatHaveSlippedOutOfView();
    addNewStarsWithSomeRandomProbability(); 

    updateAndDisplayBuildings();
    removeBuildingsThatHaveSlippedOutOfView();
    addNewBuildingsWithSomeRandomProbability(); 

    updateAndDisplayLamps();
    removeLampsThatHaveSlippedOutOfView();
    addNewLampsWithSomeRandomProbability();

}


function updateAndDisplayLamps(){
    // Update the building's positions, and display them.
    for (var i = 0; i < lamps.length; i++){
        lamps[i].move();
        lamps[i].display();
    }
}

function updateAndDisplayStars(){
    // Update the building's positions, and display them.
    for (var i = 0; i < stars.length; i++){
        stars[i].move();
        stars[i].display();
    }
}

function updateAndDisplayBuildings(){
    // Update the building's positions, and display them.
    for (var i = 0; i < buildings.length; i++){
        buildings[i].move();
        buildings[i].display();
    }
}
//////////////////////////////////////////////////////


function removeLampsThatHaveSlippedOutOfView(){
    // takes away lamps once they leave the frame
    var lampsToKeep = [];
    for (var i = 0; i < lamps.length; i++){
        if (lamps[i].x + lamps[i].breadth > 0) {
            lampsToKeep.push(lamps[i]);
        }
    }
    lamps = lampsToKeep; // remember the surviving buildings
}


////////////////////////////////////////////////////////
function removeStarsThatHaveSlippedOutOfView(){
//removes stars from array stars and puts them in new array
//once they've moved off the edge of frame
    var starsToKeep = [];
    for (var i = 0; i < stars.length; i++){
        if (stars[i].x + stars[i].breadth > 0) {
            starsToKeep.push(stars[i]);
        }
    }
    stars = starsToKeep; // remember the surviving stars
}

function removeBuildingsThatHaveSlippedOutOfView(){
    var buildingsToKeep = [];
    for (var i = 0; i < buildings.length; i++){
        if (buildings[i].x + buildings[i].breadth > 0) {
            buildingsToKeep.push(buildings[i]);
        }
    }
    buildings = buildingsToKeep; // remember the surviving buildings
}
////////////////////////////////////////////////////////////////////////


function addNewLampsWithSomeRandomProbability() {
    // With a very tiny probability, add a new building to the end.
    var newLampLikelihood = 0.03; 
    if (random(0,1) < newLampLikelihood) {
        lamps.push(makeLamp(width));
    }
}

function addNewStarsWithSomeRandomProbability() {
    // With a very tiny probability, add a new building to the end.
    var newStarLikelihood = 0.02; 
    if (random(0,1) < newStarLikelihood) {
        stars.push(makeStar(width));
    }
}

function addNewBuildingsWithSomeRandomProbability() {
    // With a very tiny probability, add a new building to the end.
    var newBuildingLikelihood = 0.007; 
    if (random(0,1) < newBuildingLikelihood) {
        buildings.push(makeBuilding(width));
    }
}
///////////////////////////////////////////////////////////////////////////


// method to update position of building every frame
function lampMove() {
    this.x += this.speed;
}

function starMove() {
    this.x += this.speed;
}

function buildingMove() {
    this.x += this.speed;
}
//////////////////////////////////////////////////////////////////////////////


// draws lamps
function lampDisplay() {
    fill(255,255,0,45);
    noStroke();    
    ellipse(this.x, height -25 - this.h,this.r,this.r); //halo of light from lamp
    fill(102,166,218);
    rect(this.x-1.5, height - 25-this.h, this.breadth, this.h); //lamp post
    fill(255);
    ellipse(this.x, height -25 - this.h, this.r2, this.r2); //lightbulb
    stroke(255);
    strokeWeight(0.5);
    noFill();
    quad(this.x - 1.5, height - 20 - this.h,
        this.x - 5, height - 35 - this.h,
        this.x + 5, height - 35 - this.h, 
        this.x + this.breadth - 1.5, height - 20 - this.h); //draws the lamp box
}

function starDisplay(){
  //halo of light around star
  noStroke();
  fill(255, 255, 0, 30);
  ellipse(this.x + this.breadth/2, this.h, this.breadth * 5, this.breadth * 5);
  stroke(255,255,0);
  strokeWeight(0.5);
  noFill();
  //draws diamonds that make up star
  quad(this.x, this.h,
       this.x + this.breadth / 2,this.h - this.tall / 2,
       this.x + this.breadth, this.h,
       this.x + this.breadth / 2,this.h + this.tall / 2);
}

function buildingDisplay() {
    var floorHeight = 20;
    var bHeight = height; 
    noStroke();
    fill(0);  
    push();
    translate(this.x, height - 40);
    rect(0, -bHeight, this.breadth, bHeight);
    for (var i = 0; i < this.nFloors; i+=2) {
    	fill("yellow");
        rect(5, -15 - (i * floorHeight), this.breadth - 10, 15);
    }
    pop();
}
//////////////////////////////////////////////////////////////////////////


function makeLamp(posX) {
    var lamp = {x: posX,
                breadth: 3,
                speed: -2.5,
                h: random(40,60),
                r: random(20,35),
                r2: 4,
                move: lampMove,
                display: lampDisplay}
    return lamp;
}

function makeStar(posX) {
    var star = {x: posX,
                breadth: 3,
                speed: -0.5,
                tall: random(5,10),
                h: random(20, 100),
                move: starMove,
                display: starDisplay}
    return star;
}

function makeBuilding(birthLocationX) {
    var bldg = {x: birthLocationX,
                breadth: 60,
                speed: -1.0,
                nFloors: round(random(10,20)),
                move: buildingMove,
                display: buildingDisplay}
    return bldg;
}
//////////////////////////////////////////////////////////////////////////////

//gradient sky function
function setGradient(c1, c2) {
  noFill();
  for (var y = 0; y < height; y++) {
    var inter = map(y, 0, height, 0, 1);
    var c = lerpColor(c1, c2, inter);
    stroke(c);
    line(0, y, width, y);
  }
}

For this project, I created a landscape of a city during the night time. The three objects in the landscape are the buildings, lamps, and stars. All of the objects appear randomly in random quantities. The only consistency is the height at which the buildings and lamps appear. The lamps’s colors are randomized and made transparent in order to create a halo effect. The objects all move across the canvas at different speeds in order to create a sense of depth. The stars move slowest, followed by the buildings, and the lamp posts move the fastest.

YouieCho-Project-11-Landscape

sketch

/* Youie Cho
   Section E
   minyounc@andrew.cmu.edu
   Project-11-Landscape*/

var terrainSpeed = 0.0001;
var terrainDetail = 0.005;
var houses = [];
var tY = 130;

function setup() {
    createCanvas(400, 300);
    frameRate(10);
    // initial collection of houses
    for (var i = 0; i < 10; i++){
        var rx = random(width);
        houses[i] = makehouse(rx);
    }
}

function draw() {
    background(219, 110, 163);
    snowyTerrain();
    snow();
    house();

    // Happy November text moving upwards
    fill(196, 71, 132);
    textSize(12);
    textFont('Helvetica');
    text('Happy November', 150, tY);
    tY -= 0.05;

    // moon
    fill(255, 238, 194);
    ellipse(330, 40, 40, 40);
}

function snow() {
    for (var i = 0; i < 50; i++) {
        ellipse(random(0, width), random(0, height), 1, 1);
    }
}

function snowyTerrain() {
    noStroke();
    fill(252, 230, 240);
    beginShape();
    for (var x = 0; x < width + 1; x++) {
        var t = (x * terrainDetail) + (millis() * terrainSpeed);
        var y = map(noise(t), 0,1, height * 0.5, height * 0.8);
        vertex(x, y);
    }
    vertex(width, height);
    vertex(0, height);
    endShape();
}

function house() {
    push();
    translate(0.1 * width, 0.1 * height);
    scale(0.8);

    stroke(0);
    noFill();

    updateAndDisplayhouses();
    removehousesThatHaveSlippedOutOfView();
    addNewhousesWithSomeRandomProbability();
    pop();
}

// houses' positions are updated and displayed
function updateAndDisplayhouses(){
    for (var i = 0; i < houses.length; i++) {
        houses[i].move();
        houses[i].display();
    }
}

// houses outside of the canvas are removed
function removehousesThatHaveSlippedOutOfView() {
    var housesToKeep = [];
    for (var i = 0; i < houses.length; i++){
        if (houses[i].x + houses[i].breadth + 70 > 0) {
            housesToKeep.push(houses[i]);
        }
    }
    houses = housesToKeep;
}

// new house is added at the end with small probability
function addNewhousesWithSomeRandomProbability() {
    var newhouseLikelihood = 0.01;
    if (random(0, .5) < newhouseLikelihood) {
        houses.push(makehouse(width + 70));
    }
}


// method to update position of house every frame
function houseMove() {
    this.x += this.speed;
}


// draw the houses
function houseDisplay() {
    var floorHeight = 15;
    var bHeight = this.nFloors * floorHeight;

    // house block
    fill(145, 55, 26);
    noStroke();
    push();
    translate(this.x, height - 40);
    rect(0, -bHeight + 20, this.breadth, bHeight);

    // roof
    fill(61, 27, 18);
    triangle(-10, -bHeight + 20, this.breadth/2, -bHeight * 2, this.breadth + 10, -bHeight + 20)

    // snow on the roof
    stroke(255);
    strokeWeight(6);
    strokeJoin(ROUND);
    fill(255);
    triangle(0, -bHeight, this.breadth/2, -bHeight * 2, this.breadth, -bHeight)

    //window that flickers
    strokeWeight(0.5);
    stroke(0);
    fill("yellow")
    noStroke();
    var wL = this.nFloors * 6 // variable to determine location
    var wW = random(25, 27); //variable to determine width and height
    rect(wL, -bHeight + wL * 2, wW, wW - 10);

    // windowsill
    stroke(0);
    line(wL + wW / 2, -bHeight + wL * 2, wL + wW / 2, -bHeight + wL * 2 + wW - 10);
    line(wL, -bHeight + wL * 2 + wW / 2 - 5, wL + wW, -bHeight + wL * 2 + wW / 2 - 5);
    pop();
}


function makehouse(birthLocationX) {
    var hs = {x: birthLocationX,
                breadth: 70,
                speed: -4,
                nFloors: round(random(2,5)),
                move: houseMove,
                display: houseDisplay}
    return hs;
}

I wanted to create a scene that represented the Christmas season, which I like a lot. I made the terrains become snowy hills, and added colors that made the scenery seem pleasant. It was fun to play around with different factors of my drawings, especially to control different things in a way they depend on other elements. For instance, I made my window and windowsills randomly move together to create an effect of the yellow light flickering from each house. It was also fun to add snow on the roofs using rounded joining corners. If I were to continue to work on this, I would want to do something more interesting with the text movement.

William Su – Project 11 – Landscape

sketch

// William Su
// Section E
// wsu1@andrew.cmu.edu
// Project 11

var terrainSpeed1 = 0.0002; 
var terrainDetail1 = 0.0007; 

var terrainSpeed2 = 0.0002; 
var terrainDetail2 = 0.001; 

var terrainSpeed3 = 0.0003; 
var terrainDetail3 = 0.005; 

var c1, c2;

function draw() {
  ellipse(mouseX, mouseY, 30, 30);
}

function setup() {
    createCanvas(480, 480);
    c1 = color(255, 204, 0); //Gradient Sky
    c2 = color(255);
    setGradient(c1, c2);
    frameRate(30);
}

function draw() {
    fill(255, 251, 130);
    ellipse(width/2, height/2 - 40, 40, 40); //Sun
    water3(); //Distant water
    DrawBoat(); //Fixed Boat
    water2(); //Middle Water
    water1(); //Near Water
}

function setGradient(c1, c2) {
  // noprotect
  noFill();
  for (var y = 0; y < height; y++) {
    var inter = map(y, 0, height, 0, 1);
    var c = lerpColor(c1, c2, inter);
    stroke(c);
    line(0, y, width, y);
  }
}

function water1() {
    noStroke();
    fill(90, 200, 250); 
    beginShape();
    for(var x = 0; x < width; x++){
        var t = (x * terrainDetail1) + (millis() * terrainSpeed1);
        var y = map(noise(t), 0, 2, 400, 300);
        vertex(x, y);
    }
    vertex(width, height);
    vertex(0, height);
    endShape(CLOSE);
}

function water2() {
    noStroke();
    fill(72, 150, 200); 
    beginShape();
    for(var x = 0; x < width; x++){
        var t = (x * terrainDetail2) + (millis() * terrainSpeed2);
        var y = map(noise(t), 0, 1, 330, 300);
        vertex(x, y);
    }
    vertex(width, height);
    vertex(0, height);
    endShape(CLOSE);
}

function water3() {
    noStroke();
    fill(60, 200, 250); 
    beginShape();
    for(var x = 0; x < width; x++){
        var t = (x * terrainDetail3) + (millis() * terrainSpeed3);
        var y = map(noise(t), 0, 2, 250, 200);
        vertex(x, y);
    }
    vertex(width, height);
    vertex(0, height);
    endShape(CLOSE);
}

function DrawBoat() { //Boat
    push();
    fill(150,75,0); 
    rect(width/2,height/2,5,60);
    pop();

    noStroke();
    push();
    fill(250);
    triangle(width/2 - 30, height/2 + 50, width/2 + 2, 220, width/2 + 30, height/2 + 50);
    pop();

    push();
    fill(140);
    arc(width/2, height/2 + 60, 100, 80, 0, PI, CHORD);
    pop();
}



I decided to make a generative landscape of the ocean. I made 3 wave “layers” and had a fixed object in the horizon.

Aaron Lee – Project 11 – Landscape

sketch

/*
Aaron Lee
Section C
sangwon2@andrew.cmu.edu
Project-11-Generative Landscape
*/

var stars = [];

function setup() {
    createCanvas(400,600);
    
    for (var i = 0; i < 15; i ++) {                      //initial placement of stars
        var starsX = random(width);
        var starsY = random(height);
        stars[i] = makestars(starsX, starsY);
    }
    frameRate(10);
}

function draw() {
    background("black");

    showstars();
    deletestars();
    makeNewstars();
    spaceship();
}

//----------------------------------------stars--------------------------------------------------
function showstars() {                                      //this makes the stars move down
    for(var i = 0; i < stars.length; i++) {
        stars[i].move();
        stars[i].display();
    }
}

function deletestars() {                                    //deletes stars that disappear from sight
    var starsToKeep = [];
    for (var i = 0; i < stars.length; i++) {
        if(stars[i].y > 600) {
            starsToKeep.push(stars[i]);
        }
    }
}

function makeNewstars() {                                   //creates more stars coming down
    var newstarsLiklihood =0.05
    if (random(0,1) < newstarsLiklihood) {
        stars.push(makestars(random(width), 0));
    }
}

function starsMove() {                                      //sets the move property of stars
    this.y += this.speed;
}

function starsDisplay() {                                   //what stars look like
    var starsSize = this.starsSize;
    fill("#FFFF00");
    noStroke();
    push();
    translate(this.x, this.y);
    rotate(frameCount / 200.0);
    star(0, 0, 5, 10, 5);
    pop();
}

function star(x, y, radius1, radius2, npoints) {
   let angle = TWO_PI / npoints;
   let halfAngle = angle / 2.0;
   beginShape();
   for (let a = 0; a < TWO_PI; a += angle) {
     let sx = x + cos(a) * radius2;
     let sy = y + sin(a) * radius2;
     vertex(sx, sy);
     sx = x + cos(a + halfAngle) * radius1;
     sy = y + sin(a + halfAngle) * radius1;
     vertex(sx, sy);
  }
  endShape(CLOSE);
}

function makestars(birthLocationX, birthLocationY) {       //function that makes the stars
    var stars = {x : birthLocationX,                                  //stars are born in random places
                y : birthLocationY, 
                speed : random(1, 5),                                //sets random speed of stars
                starsSize : random(10, 25),                          //sets random size of stars
                move : starsMove,  
                display : starsDisplay}
                return stars;
}


//----------------------------------------spaceship--------------------------------------------------
function spaceship() {                                 //function makes the spaceship window frame
    fill("#C0C0C0");
    strokeWeight(5);
    stroke("black");

    beginShape();
    vertex(0, 600);
    vertex(0, 520);
    vertex(400, 520);
    vertex(400, 600);
    endShape(CLOSE);

    beginShape();
    vertex(0, 80);
    vertex(0, 0);
    vertex(400, 0);
    vertex(400,80);
    endShape(CLOSE);
               
    beginShape();
    vertex(0, 0);
    vertex(80, 0);
    vertex(80, 600);
    vertex(0, 600);
    endShape(CLOSE);

    beginShape();
    vertex(320, 0);
    vertex(400, 0);
    vertex(400, 600);
    vertex(320, 600);
    endShape(CLOSE);

    fill("#808080");
    ellipse(120, 40, 30, 30);
    ellipse(200, 40, 30, 30);
    ellipse(280, 40, 30, 30);
    ellipse(120, 560, 30, 30);
    ellipse(200, 560, 30, 30);
    ellipse(280, 560, 30, 30);
}

When I first thought of the generative landscape, I associated with the infinite and the random arrangement of the stars in galaxy. Then I came up with a narrative that a spaceman is observing stars inside the spaceship. Overall I used monotone for the spaceship in order to give focus to the stars

Ghalya Alsanea- Project 11 – Landscape

I was inspired by space games and how it shows movement of landscape using the background stars and moving objects.
Soource: Galaga

For this project, I wanted to maximize randomization of the space objects, but still have some sort of coherency. Mostly, I was trying to become more comfortable with creating different classes of objects.

sketch

//Ghalya Alsanea
//galsanea@andrew.cmu.edu
//Section B
//Project 11

var lines;
var totalLines = 0;

var j;              //jiggle
var f;              //flower

var p1, p2, p3;     //planets
var sp;             //spinning planet

//stars
var star;
var star2;

function preload() {
    //
}

function setup() {
    createCanvas(600, 600);
    background(0);
    lines = new Array(500);

    //initiate the dif class ojects
    j = new Jiggle();
    f = new Flower();
    p1 = new Planet();
    p2 = new Planet2();
    p3 = new Planet3();
    sp = new SpinPlanet();
    star = new Star();
    star2 = new Star();
}

function draw() {
    background(0);
    //create the shooting starts lines
    lines[totalLines] = new Line();
    totalLines++;
    for (var i = 0; i < totalLines; i++) {
        lines[i].move();
        lines[i].display();
    }
    //show and move the objects
    //jiggle circle
    j.move();
    j.show();
    //flower
    f.move();
    f.show();
    // planets
    p1.move();
    p1.show();
    p2.move();
    p2.show();
    p3.move();
    p3.show();
    //spinplanet
    sp.move();
    sp.show();
    //star 1
    star.move();
    star.show();
    //star 2
    star2.move();
    star2.show();
}


//////////////////////////////////////////////////////////////////////
//                      define the classes                          //
//////////////////////////////////////////////////////////////////////

class Jiggle {
    constructor() {
        this.x = random(0, width);      //start at a random xpos
        this.y = height + 100;          //make sure to start  off the canvas
        this.size = random(20, 50);     //create a new size
        this.col = color("orange");     //define the color
    }
    move() {
        this.y-=2;                          //move up
        this.x = this.x + random(-5, 5);    //make the "jiggle" movement
        //if it moves too far up, reset the object
        if (this.y < -this.size) {
            this.y = height;
            this.x = random(0, width);
            this.size = random(20, 50);
        }
    }
    show() {
        //draw the object
        noStroke();
        strokeWeight(1);
        fill(this.col);
        circle(this.x, this.y, this.size);
    }
}

//////////////////////////////////////////////////////////////////////

class Flower {
    constructor() {
        this.x = random(0, width);      //start at a random xpos
        this.y = height + 100;          //start y loc off the canvas
        this.size = random(40, 80);     //randomize size
    }
    move() {
        this.y--;                       //move up
        this.x = this.x + random(-1, 1);//cause the jiggle
        //reset if it goes too far up
        if (this.y < -this.size) {
            this.y = height;
            this.x = random(0, width);
            this.size = random(40, 80);
        }
    }
    show() {
        // draw the object
        noStroke();
        fill(204, 101, 192, 180);
        //rotate 
        push();
        translate(this.x, this.y);
        for (var i = 0; i < 10; i++) {
            ellipse(0, 30, this.size / 6, this.size);
            rotate(PI / 5);
        }
        pop();
    }
}

//////////////////////////////////////////////////////////////////////

class Star {
    constructor() {
        this.x = random(0, width);          //start at random xpos
        this.y = height - 50;               //start y loc off canvas
        this.col = color("yellow"); 
        this.npoints = random(5, 12);       //points in star
        this.angle = TWO_PI / this.npoints;
        this.halfAngle = this.angle / 2.0;      
        this.r1 = random(5, 20);            //inner radius
        this.r2 = random(20, 40);           //outer radius

    }
    move() {
        this.x;
        this.y = this.y - random(0.8, 1.2);         //move in a random speed
        // reset if it goes off cnavas
        if (this.y < -100) {
            this.y = height;
            this.y -= random(0.8, 1.2);
            this.x = random(0, width);
            this.npoints = random(5, 12);
            this.angle = TWO_PI / this.npoints;
            this.halfAngle = this.angle / 2.0;
            this.r1 = random(10, 30);
            this.r2 = random(60, 100);
        }
    }
    show() {
        //draw the object
        noStroke();
        fill(this.col);
        //rotate it
        push();
        translate(this.x, this.y);
        rotate(radians(frameCount)/2);
        beginShape();
        //draw a star based on angles and npoints
        for (var a = 0; a < TWO_PI; a += this.angle) {
            var sx = cos(a) * this.r2;
            var sy = sin(a) * this.r2;
            vertex(sx, sy);
            sx = cos(a + this.halfAngle) * this.r1;
            sy = sin(a + this.halfAngle) * this.r1;
            vertex(sx, sy);
        }
        endShape();
        pop();

    }
}

//////////////////////////////////////////////////////////////////////

class Planet {
    constructor() {
        this.x = random(0, width);
        this.size = random(10, 50);
        this.y = height - this.size;
        this.col = color("red");
    }
    move() {
        this.x;
        //Moving up at a constant speed
        this.y -= 0.75;
        // Reset to the bottom
        if (this.y < -100) {
            this.y = height + 250;
            this.size = random(10, 50);
        }
        if (this.x < 0 || this.x > width) {
            this.x = (random(10, 500)) - 25;
        }
    }
    show() {
        //draw planet with ring
        fill(this.col);
        noStroke();
        circle(this.x, this.y, this.size);
        noFill();
        stroke(this.col);
        strokeWeight(1);
        ellipse(this.x, this.y, this.size * 2, this.size / 2);
    }
}

//////////////////////////////////////////////////////////////////////

class Planet2 {
    constructor() {
        this.x = random(0, width);
        this.y = height + 100;
        this.size = random(50, 80);
        this.col = color("pink");
    }
    move() {
        this.x;
        //Moving up at a constant speed
        this.y-=1.1;
        // Reset to the bottom
        if (this.y < -50) {
            this.y = height;
            this.size = random(50, 80);
        }
        if (this.x < 0 || this.x > width) {
            this.x = (random(10, 500)) - 25;
        }
    }
    show() {
        //draw planet with rotated ring
        fill(this.col);
        noStroke();
        circle(this.x, this.y, this.size);

        stroke(this.col);
        strokeWeight(2);
        noFill();
        push();
        translate(this.x, this.y);
        rotate(PI/4);
        ellipse(0, 0, this.size * 1.5, this.size / 3);
        pop();
    }
}

//////////////////////////////////////////////////////////////////////

class Planet3 {
    constructor() {
        this.x = random(0, width);
        this.y = height + 100;      //start below window
        this.size = random(50, 80);
        this.col = color("coral");
    }
    move() {
        this.x = this.x + random(-1, 1);
        //Moving up at a constant speed
        this.y -= 0.85;
        // Reset to the bottom
        if (this.y < -100) {
            this.y = height;
            this.size = random(50, 80);
        }
        if (this.x < 0 || this.x > width) {
            this.x = (random(10, 500)) - 25;
        }
    }
    show() {
        //draw planet with rotating ring
        fill(this.col);
        noStroke();
        circle(this.x, this.y, this.size);
        noFill();
        stroke(this.col);
        push();
        translate(this.x, this.y);
        rotate(radians(frameCount)/2);
        strokeWeight(1);
        ellipse(0, 0, this.size / 2, this.size * 2);
        pop();
    }
}

//////////////////////////////////////////////////////////////////////

class SpinPlanet {
    constructor() {
        this.x = random(0, width);
        this.y = height + 100;      //start below window
        this.size = random(50, 90);
        this.col = color("green");
    }
    move() {
        this.x = this.x + random(-1, 1);
        //Moving up at a constant speed
        this.y -= 0.65;
        // Reset to the bottom
        if (this.y < -100) {
            this.y = height;
            this.size = random(50, 90);
        }
        if (this.x < 0 || this.x > width) {
            this.x = (random(10, 500))-40;
        }
    }
    show() {
        //draw a spinning planet
        fill(this.col);
        noStroke();
        circle(this.x, this.y, this.size);
        noFill();
        stroke(this.col);
        strokeWeight(2);
        push();
        translate(this.x, this.y);
        rotate(frameCount);
        ellipse(random(-1,1), 0, this.size / 2, this.size * 2);
        pop();
        
    }
}

//////////////////////////////////////////////////////////////////////

class Line {
    constructor() {
        this.r = height + 200;      // starting pt + 200 so to make sure it starts off canvas
        this.x = random(width);     // Start with a random x location
        this.y = this.r;            // Start pt below the window
        this.speed = random(2, 5);  // Pick a random speed
        this.l = random(100, 200);  //randomize length of line 
    }

    move() {
        // move y upwards by speed
        this.y -= this.speed;
    }

    display() {
        //only draw if it's in the canvas
        //draw the shooting stars lines
        if (this.y > 0) {
            strokeWeight(1);
            stroke(random(100, 255), random(100, 255), random(100, 255), 200);
            line(this.x, this.y, this.x, this.y - this.l);
        }
    }
}