Xu Xu – Project 11 – Landscape

sketch

var waterSpeed = 0.00005;
var waterDetail = 0.003;
var mountain1Speed = 0.0009;
var mountain1Detail = 0.05;
var mountain2Speed = 0.0005;
var mountain2Detail = 0.014;
var crows = [];

function setup() {
    createCanvas(480, 400);
    frameRate(10);
    for (var i = 0; i < 9; i++){
        var crowX = random(width);
        var crowY = random(0, 200);
        crows[i] = makeCrow(crowY, crowX);
    }
}

function draw(){
    background(240);
    drawSun();
    drawMountain2();
    drawMountain1();
    drawBoat();
    drawWater();
    updateCrow();
    addCrow();
    removeCrow();


}
function drawSun(){
    noStroke();
    fill(239.7, 186.15, 204, 25);
    ellipse(300, 200, 500, 500);
    fill(239.7, 186.15, 204, 30);
    ellipse(350, 200, 350, 350);
    fill(239.7, 186.15, 204, 35);
    ellipse(390, 200, 200, 200);

}
function drawBoat(){
        //line(265, 330, 240, 360);
    noStroke();
    fill(100);
    arc(255,345, 50, 10, 0, PI);
    ellipse(260,340, 5, 20);
    ellipse(260, 328, 5, 5);
    triangle(250, 326, 270, 326, 260, 323);

}
function drawMountain2(){
    noStroke();
    fill(188.7, 211.65, 229.5);
    beginShape();
    for (var i = 0; i < width; i ++){
        var x = (i * mountain2Detail) + (millis() * mountain2Speed);
        var y = map(noise(x), 0, 1.5, 50, 300);
        vertex(i, y);
    }
    vertex(width, height);
    vertex(0, height);
    endShape();
}

function drawMountain1(){
    noStroke();
    fill(155.55, 196.35, 226.95);
    beginShape();
    for (var i = 0; i < width; i ++){
        var x = (i * mountain1Detail) + (millis() * mountain1Speed);
        var y = map(noise(x), 0, 1.2, 150, 250);
        vertex(i, y);
    }
    vertex(width, height);
    vertex(0, height);
    endShape();
}
function drawWater(){
    noStroke();
    fill(119.85, 140.25, 165.75);
    beginShape();
    for (var i = 0; i < width; i ++){
        var x = (i * waterDetail) + (millis() * waterSpeed);
        var y = map(noise(x), 0, 1.8, 345, 360);
        vertex(i, y);
    }
    vertex(width, height);
    vertex(0, height);
    endShape();
}
function makeCrow(crowX, crowY){
    var crow = {
        x: crowX,
        y: crowY,
        velocity: random(3, 18),
        size: random(5, 10),
        move: moveCrow,
        show: showCrow,
    }
    return crow;
}
function moveCrow(){
    this.x -= this.velocity;
    this.y -= this.velocity / random(5, 10);
}
function showCrow(){
    strokeWeight(1);
    stroke(0);
    noFill();
    arc(this.x, this.y, this.size, this.size/2, PI, TWO_PI);
    arc(this.x + this.size, this.y, this.size, this.size/2, PI, TWO_PI);
}
function updateCrow(){
    for(i = 0; i < crows.length; i++){
        crows[i].move();
        crows[i].show();
    }
}
function addCrow(){
    if (random(0,1) < 0.1){
        var crowX = width;
        var crowY = random(0, height/2);
        crows.push(makeCrow(crowX, crowY));
    }
}
function removeCrow(){
    var keep = [];
    for (i = 0; i < crows.length; i++){
        if (crows[i].x + crows[i].size > 0){
            keep.push(crows[i]);
        }
    }
    crows = keep;
}

For this project, I wanted to create someone on a boat flowing along the landscape, with crows flying in the opposite direction.

Sean Meng-Project-11-Landscape

hmeng-project-11

//Sean Meng
//hmeng@andrew.cmu.edu
//Section C
//Project-11-Generative Landscape

var sushi = [];

function setup() {
    createCanvas(480, 480);
    frameRate(50);
    //set an initial group of sushi
    for (var i = 0; i < 3; i++){
        var rx = random(width);
        sushi[i] = makeSushi(rx);
    }
}

function draw() {
    background(255, 200, 200);
    
    //the lattern
    fill(30);
    rect(60, 20, 40, 160);
    rect(78, 0, 5, 20)
    
    fill(235, 70, 70);
    stroke(235, 70, 70);
    strokeWeight(50);
    rect(60, 60, 40, 80)
    noStroke();
    
    //ribs on lattern
    for(i = 0; i < 8; i++){
        fill(120, 0, 0);
        rect(35, 57 + i * 12, 90, 1.5);
    }

    //the belt
    fill(50);
    rect(0, 320, width, 80);
    fill(180);
    rect(0, 400, width, 10);

    //the table
    fill(255, 237, 199);
    rect(0, 410, width, 190);

    //the plate
    fill(255);
    ellipse(170, 440, 300, 40);
    fill(220);
    ellipse(180, 435, 200, 20);
    fill(250);
    ellipse(186, 438, 180, 20);

    //thie chopsticks
    fill(250);
    rect(385, 435, 35, 10);
    fill(128, 55, 0);
    quad(400, 430, 405, 430, 455, 480, 443, 480);
    fill(128, 55, 0);
    quad(390, 430, 395, 430, 435, 480, 425, 480);

    updateSushi();
    removeSushiOutOfView();
    addSushi();
}


function updateSushi() {
    for (var i = 0; i < sushi.length; i++) {
        sushi[i].move();
        sushi[i].display();
    }
}

function removeSushiOutOfView() {
    //remove sushi from array if it's out of sight
    var sushiToKeep = [];
    for (var i = 0; i < sushi.length; i++) {
        if (sushi[i].x + sushi[i].breadth > 0) {
            sushiToKeep.push(sushi[i]);
        }
    }
    sushi = sushiToKeep; //remember the surviving sushi
}

function addSushi() {
    //with a very small probability, add a new sushi to the end
    var newSushiProb = 0.005; 
    if (random(0,1) < newSushiProb) {
        sushi.push(makeSushi(width));
    }
}

function sushiDisplay(){

    //rice
    stroke(this.c3);
    strokeWeight(10);
    strokeJoin(ROUND);
    fill(this.c3);
    rect(this.x, 350, this.breadth, this.height);

    //salmon on top of rice
    var top = 350 + this.height;
    var top2 = 350 + this.height - 5;
    stroke(255, this.c1, this.c2);
    fill(255, this.c1, this.c2);
    rect(this.x - 10, top, this.breadth + 20, 20);
    noStroke();
    fill(255, this.c1 + 50, this.c2 + 80);
    triangle(this.x, top2, this.x + 10, top2, this.x + 5, top + 15);
    triangle(this.x + 30, top2, this.x + 40, top2, this.x + 35, top + 15);
    triangle(this.x + 60, top2, this.x + 70, top2, this.x + 65, top + 15);
    
    //the kelp
    fill(0);
    rect(this.x + this.breadth / 2, top2, 30, -this.height + 5);
}

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

function makeSushi(startX){
    var mySushi = {x: startX,
                speed: -1.0,        
                breadth: random(80, 120),
                height: -random(50, 70),
                c1: random(100, 150),
                c2: random(50, 90),
                c3: random(240, 255),
                move: sushiMove,
                display: sushiDisplay}
    return mySushi;
}

Concept sketch

In this project, I intend to create this “rotation sushi” scene. Using generative drawing methods, sushi with different shapes, sizes and toppings come out and move along the belt.

Cathy Dong – Project 11 – Landscape

sketch

/* Cathy Dong
   Section D
   yinhuid@andrew.cmu.edu
   Project 11 - Landscape
*/

// mountain slope and move speed variables
var tDetail1 = 0.002;
var tSpeed1 = 0.0001;
var tDetail2 = 0.005;
var tSpeed2 = 0.0003;
var tDetail3 = 0.01;
var tSpeed3 = 0.0008;

// mountain colors
var terrC1 = "#597081";
var terrC2 = "#7EA0B7";
var terrC3 = "#D6EEFF";

//mountain heights range
var h1Min = 0;
var h1Max = 300;
var h2Min = 150; 
var h2Max = 400;
var h3Min = 250;
var h3Max = 480;

// star variables
var sList = [];
var sNum = 20; // number of stars
var sLeft = -20; // reset start to canvas right
var sSpeed = -0.5;

// car variables
var cList = [];
var cHeight = 20; // car height
var cWidth = 50; // car width
var cNum = 5; //number of cars
var cLeft = -20 - cWidth; // reset car to start
var cSpeed = -1.5; // car speed
var wSize = 10; // car wheel size


function setup() {
    createCanvas(480, 480);
    // star start at random px and py
    for (var j = 0; j < sNum; j++) {
        var px = random(width);
        var py = random(height / 3);
        sList[j] = starMake(px, py);
    }

    // car cx and cy
    var ground = height - height / 15;
    for (var k = 0; k < cNum; k++) {
        var cx = random(width);
        var cy = ground - wSize / 2 - cHeight;
        cList[k] = carMake(cx, cy);
    }

    
}

function draw() {
    // sky color
    background("#2B2D42");
    // render stars
    starRender();
    // render mountains 
    terrainDraw(tDetail1, tSpeed1, terrC1, h1Min, h1Max);
    terrainDraw(tDetail2, tSpeed2, terrC2, h2Min, h2Max);
    terrainDraw(tDetail3, tSpeed3, terrC3, h3Min, h3Max);
    // draw ground
    fill("#8D99AE");
    rect(0, height - height / 15, width, height / 15);
    // render car
    carRender();
    
}

// mountain draw function 
function terrainDraw(terrainDetail, terrainSpeed, terrC, terrMin, terrMax) {
    noStroke();
    // fill with layer color
    fill(terrC);
    // start drawing the shape
    beginShape();
    vertex(0, height);
    // generate terrian
    for (var i =  0; i < width; i++) {
        var t = (i * terrainDetail) + (millis() * terrainSpeed);
        var y = map(noise(t), 0, 1, terrMin, terrMax);

        vertex(i, y);
    }
    vertex(width, height);
    endShape();
}

// star object
function starMake(px, py) {
    var star = {x: px, y:py, speed: sSpeed,
                update: starUpdate,
                draw: starDraw}
    return star;
}

// update star px and py
function starUpdate() {
    this.x += this.speed;
    if (this.x <= sLeft) {
        this.x += width - sLeft;
    }
}

// draw star at this.x and this.y location
function starDraw() {
    noStroke();
    fill("yellow");
    var size = random(1, 5); // make it shine
    push();
    translate(this.x, this.y);
    circle(0, 0, size);
    pop();
}

// render the star based on previous info
function starRender() {
    for (var i = 0; i < sList.length; i++) {
        sList[i].update();
        sList[i].draw();
    }
}

// car info
// a is car x position; b is car y position
function carMake(cx, cy) {
    var car = {a: cx, b: cy, speed: cSpeed, c: color(random(100), random(0), random(255)),
                update: carUpdate,
                draw: carDraw}
    return car;
}

// update car position
function carUpdate() {
    this. a += this.speed;
    if(this.a <= cLeft) {
        this.a += width - cLeft;
    }
}

// draw initial car
function carDraw() {
    // wheel location
    var wX1 = cWidth / 4;
    var wX2 = cWidth - wX1;
    noStroke();
    push();
    translate(this.a, this.b);
    // draw car
    fill(this.c);
    rect(0, 0, cWidth, cHeight);
    // draw car wheels
    fill(0);
    circle(wX1, cHeight, wSize);
    circle(wX2, cHeight, wSize);
    pop();
}

// render car to this.a and this.b
function carRender() {
    for (var m = 0; m < cList.length; m++) {
        cList[m].update();
        cList[m].draw();
    }
}

The idea is to create a night scene on a highway. In the scene, stars and mountains move relative to the cars in a various speed based on depth relationship.

initial sketch

Jina Lee – Project 11

sketch

// Jina Lee
// jinal2@andrew.cmu.edu
// Project 11
// Section E

var sushi = [];
var count = 0;
var riceSize = 70;

function setup() {
    createCanvas(480, 280);
    // for loop to create the sushi
    for (var i = 0; i < 5; i += 20){
        sushi[i] = makeSushi(width);
    }
    frameRate(120);
}


function draw() {
    count += 1;
    // beige
    background(207, 185, 151);
    sushiText();
    sushiConveyorBelt();
    updateAndDisplaySushi();
    removeSushiThatHaveSlippedOutOfView();
    addNewSushiConstantly();
}

function sushiText(){
    // frame for sign
    fill(150, 0, 0);
    rect(340, 22, 120, 48, 5);
    // white sign
    fill(255);
    rect(350, 28, 100, 35, 5);
    // turned on open sign
    fill(150, 0, 0);
    textSize(18);
    text("OPEN", 370, 52);
    // menu
    fill(255);
    rect(50, 22, 250, 150);
    fill(0);
    textSize(30);
    text("menu", 70, 60);
    stroke(0);
    strokeWeight(3);
    line(75, 100, 240, 100);
    line(75, 80, 280, 80);
    line(75, 90, 280, 90);
    line(75, 110, 280, 110);
    line(75, 120, 100, 120);
    line(75, 130, 240, 130);
    line(75, 140, 240, 140);
    line(75, 150, 280, 150);
}

function updateAndDisplaySushi(){
    for (var i = 0; i < sushi.length; i++){
        sushi[i].move();
        sushi[i].display();
    }
}


function removeSushiThatHaveSlippedOutOfView(){
    var sushiToKeep = [];
    for (var i = 0; i < sushi.length; i++){
        if (sushi[i].x + sushi[i].breadth > -200) {
            sushiToKeep.push(sushi[i]);
        }
    }
    sushi = sushiToKeep;
}

// keeps adding sushi to the end
function addNewSushiConstantly() {
    if (count > 270) {
        sushi.push(makeSushi(width));
        count = 0;
    }
}

// update sushi position every frame
function sushiMove() {
    this.x += this.speed;
}

// draw the sushi
function sushiDisplay() {
    var Height = 30;
    fill(255);
    noStroke();
    push();
    translate(this.x, height - 40);
    // plate
    fill(161, 206, 94);
    ellipse(35, -Height/7, 110, 30)
    rect(5, 5, 60, 10);
    // rice
    fill(255);
    rect(0, -Height, riceSize, 30);
    // eel
    fill(139,69,19);
    rect(0, -Height - 20, riceSize, 20);
    // seaweed
    fill(0);
    rect(25, -Height - 20, riceSize/4, 20);
    // plate
    fill(16, 52, 166);
    ellipse(175, -Height/7, 110, 30);
    rect(145, 5, 60, 10);
    // rice
    fill(255);
    rect(140, -Height, riceSize, 30);
    // tuna
    fill(234, 60, 83);
    rect(140, -Height - 20, riceSize, 20);
    pop();
}

function makeSushi(birthLocationX) {
    var sushi = {x: birthLocationX,
                breadth: 60,
                speed: -1.0,
                move: sushiMove,
                display: sushiDisplay}
    return sushi;
}

function sushiConveyorBelt() {
    // grey
    stroke(200);
    strokeWeight(30);
    line (0, height - 10, width, height - 10);
}

Here is the sketch of what I envisioned.

For this project, I am creating a sushi conveyor belt. I was inspired because back home, there is an all you can eat sushi restaurant that has sushi on a conveyor belt. The sushi is what moves. I made the signs static so it seems as if you are sitting at the table watching the sushi pass through. I created eel and tuna sushi.

Gretchen Kupferschmid-Project 11- Landscape

sketch

   //initialize variables
    var terrainSpeed = 0.0005;
    var terrainDetail = 0.005;
    var groundDetail= 0.005;
    var groundSpeed = 0.0005;
    var cactus = [];
    var col1, col2;

function setup() {
    createCanvas(480,480);
    frameRate(10);
    //start landscape out with 3 cacti
    for(i = 0; i < 3; i++){
      var rx = random(0,width);
      cactus[i] = makeCactus(rx);
}
}
 function draw (){
    //create gradient colors
    c1= color(255, 149, 0);
    c2= color(235, 75, 147);
    setGradient(c1, c2);
    
    //call functions 
    drawDesertMtn();
    updateCactus();
    removeCactus();
    addCactus();
}

function setGradient(c1, c2){
    //create the gradient background
  noFill();
  
  for(i = 0; i < height; i++){
    var grad = map(i, 0, height, 0, 1);
    var col = lerpColor(c1, c2, grad);
    stroke(col);
    line(0, i, width, i);
  }
}

function drawDesertMtn(){
    //back mtn 
    fill(255, 155, 84);
    noStroke();
    beginShape(); 
    //make the terrain randomize and go off screen
    for (var x = 0; x < width; x++) {
        var t = (x * terrainDetail) + (millis() * terrainSpeed);
        var y = map(noise(t), 0,2, 50, height);
        vertex(x, y); 
    }
    vertex(width,height);
    vertex(0,height);
    endShape();
    
    //middle mtn
    fill(245, 105, 98);
    noStroke();
    beginShape(); 
    //make the terrain randomize and go off screen
    for (var x = 0; x < width; x++) {
        var t = (x * terrainDetail) + (millis() * terrainSpeed);
        var y = map(noise(t), 0,1, 100, height);
        vertex(x, y); 
    }
    vertex(width,height);
    vertex(0,height);
    endShape();
    
    //closest mtn
    fill(224, 54, 139);
    noStroke();
    beginShape(); 
    //make the terrain randomize and go off screen
    for (var x = 0; x < width; x++) {
        var t = (x * terrainDetail) + (millis() * terrainSpeed);
        var y = map(noise(t), 0,1,200,height);
        vertex(x, y); 
    }
    vertex(width,height);
    vertex(0,height);
    endShape();
    
    //groud
    fill(165, 196, 106);
    noStroke();
    beginShape();
    //make the ground randomize and go off screen
     for (var x = 0; x < width; x++) {
        var t = (x * groundDetail) + (millis() * groundSpeed);
        var y = map(noise(t), 0, 1,400,480);
        vertex(x, y); 
    }
    vertex(width, height);
    vertex(0,height);
    endShape();
}


//change x value of cactus as cactus moves
function moveCactus(){
    this.x += this.speed;
}

function makeCactus(cactusX){
    //create the cactus as an object w some random parts
    var cactus={
        x:cactusX,
        speed: -6,
        breadth:311,
        color: random(0,100),
        length: random(50,100),
        move: moveCactus,
        display: displayCactus,
    }
    return cactus;
}

function updateCactus(){
    //loop through an array of cactus to update as adding and moving
  for(i = 0; i < cactus.length; i++){
    cactus[i].move();
    cactus[i].display();
  }
}

function displayCactus(){
    //create the cactus visuals with object parts
    noStroke();
    fill(this.color, 107, 9);
    //translate to x value of new cactus
    push();
    translate(this.x+157, height-40);
    ellipse(0,0,94,137);
    fill(this.color, 107,9);
    ellipse(61, -52, this.length,48);
    fill(this.color, 115, 28);
    ellipse(47,-83,19,27);
    fill(90, 115, 22);
    ellipse(81, -74, 24,24);
    fill(90, 115, 22);
    ellipse(-34, -86, this.length, 74);
    fill(this.color, 115, 22);
    ellipse(-18, -131, 41,41);
    fill(252, 197, 247);
    //create flower on cactus
    beginShape();
    curveVertex(-1, -150);
    curveVertex(-7,-152);
    curveVertex(-7, -147);
    curveVertex(-10, -157);
    curveVertex(-5, -141);
    curveVertex(-4, -135);
    curveVertex(1, -140);
    curveVertex(8, -135);
    curveVertex(8, -142);
    curveVertex(8, -147);
    curveVertex(3, -148);
    curveVertex(3, -153);
    curveVertex(-1, -150);
    endShape();
    pop();
}

function addCactus(){
//add a new cactus to the array
  var newCactus = 0.01;
  if(random(0,1)< newCactus){
    cactus.push(makeCactus(width));
  }
    
}
function removeCactus(){
    //remove cactus from array as it goes off the screen
  var keepCactus = [];
  for(i = 0; i < cactus.length; i++){
    if(cactus[i].x + cactus[i].breadth > 0){
      keepCactus.push(cactus[i]);
    }
  }
  cactus = keepCactus;
}

I was inspired by desert landscapes in which the sun is setting and there are cacti as well as communicate the vastness of a place like joshua tree.ca.

Sarah Kang-Project 11 – Landscape

landscape

//sarah kang
//section c
//sarahk1@andrew.cmu.edu
//project-11-landscape

var m1Speed = .001
var m1Detail = .005
var m2Speed = .002
var m2Detail = .01
var m3Detail = .005

var firework = [];
var firework2 = [];

function setup() {
  createCanvas(480, 480);
    //initial set of pink fireworks
    for (i = 0; i < 12; i++) {
        var fireworkX = random(width);
        var fireworkY = random(0, 240);
        firework[i] = makeFirework(fireworkX, fireworkY);
    }

        //initial set of orange fireworks
    for (i = 0; i < 8; i++) {
        var firework2X = random(width);
        var firework2Y = random(0, 240);
        firework2[i] = makeFirework2(firework2X, firework2Y);
    }

    frameRate(20);
}


function draw() {
 background(0);

 fireworks();
 fireworks2();

 m1();
 m2();

 noStroke();
 fill(94, 94, 115);
 rect(0, 400, 480, 80);

 m3();

}

function m1() {
  //back mountain range 
  stroke(20, 21, 54);
  beginShape();
  for(var x = 0; x < width; x++) {
    var t = (x * m1Detail) + (millis() * m1Speed);
    var y = map(noise(t), 0, 1, 200, 340);
    line(x, y, x, 400);
  }
  endShape();
}

function m2() {
  //front mountain range
  stroke(28, 29, 82);
  beginShape();
  for(var x = 0; x < width; x++) {
    var t = (x * m2Detail) + (millis() * m2Speed);
    var y = map(noise(t), 0, 1, 240, 380);
    line(x, y, x, 400);
  }
  endShape();
}

function m3() {
  //mountain range shadow
  stroke(34, 34, 43);
  beginShape();
  for(var x = 0; x < width; x++) {
    var t = (x * m3Detail) + (millis() * m2Speed);
    var y = map(noise(t), 0, 1, 400, 480);
    line(x, y, x, 400);
  }
  endShape();
}

function drawFirework() {
    noStroke();
    fill(255, 230, 238);
    push();
    translate(this.x2, this.y2);

    for (let i = 0; i < 12; i ++) {
    ellipse(0, 20, 3, 25);
    rotate(PI / 5);
    }

    pop();
}

function makeFirework(xlocation, ylocation) {
  var makeFire = {x2: xlocation, 
                y2: ylocation, 
                fireworkX: random(0, width), 
                fireworkY: random(0, 240),
                speed: -2.0,
                move: moveFirework,
                draw: drawFirework}
  return makeFire;
}

function moveFirework() {
    this.x2 += this.speed;
    if (this.x2 <= -20) {
        this.x2 += 500;
    }
}

function fireworks() {
    //pink fireworks
    for(i = 0; i < firework.length; i++) {
        firework[i].move();
        firework[i].draw();
    }
}

function drawFirework2() {
    noStroke();
    fill(255, 176, 97);
    push();
    translate(this.x2, this.y2);

    for (let i = 0; i < 12; i ++) {
    ellipse(0, 30, 3, 40);
    rotate(PI / 5);
    }

    pop();
}

function makeFirework2(xlocation, ylocation) {
    var makeFire2 = {x2: xlocation, 
                y2: ylocation, 
                firework2X: random(0, width), 
                firework2Y: random(0, 240),
                speed: -2.0, 
                move: moveFirework2,
                draw: drawFirework2}
    return makeFire2;
}

function moveFirework2() {
    this.x2 += this.speed;
    if (this.x2 <= -20) {
        this.x2 += 500;
    }
}

function fireworks2() {
    //orange fireworks
    for(i = 0; i < firework2.length; i++) {
        firework2[i].move();
        firework2[i].draw();
    }
}

For this project, I wanted to make a nighttime landscape and incorporate a colorful fireworks show.

Margot Gersing – Project 11

sketch

//Margot Gersing - Project 11 - mgersing@andrew.cmu.edu - section E

var stars = [];
var terrainSpeedOne = 0.0002; //dark green moutain speed
var terrainSpeedTwo = 0.0004; // water speed
var terrainSpeedThree = 0.0006; // ligth green ground speed
var terrainDetailOne = 0.008; //green moutian
var terrainDetailTwo = 0.001; //water
var terrainDetailThree = 0.005; //light green moutain


function setup() {
    createCanvas(480, 480);
    frameRate(20);
    //fills stars array
    for (var i = 0; i < 75; i ++){
        var strX = random(width);
        var strY = random(0, height / 2);
        stars[i] = makeStars(strX, strY);
    }
    
}

function draw() {
    background(214, 197, 204);
    //moon
    fill(169, 47, 35);
    ellipse(375, 100, 150, 150);
    displayStars(); //stars
    moutainTwo(); //background moutians
    water(); //water
    moutainThree(); //foreground
}

function moutainTwo() {
    noStroke();
    fill(22, 56, 32); //darkgreen
    beginShape();
    for(var x = 0; x < width; x++){
        var t = (x * terrainDetailOne) + (millis() * terrainSpeedOne);
        var y = map(noise(t), 0, 1, 300, 250);
        vertex(x, y);
    }
    vertex(width, height);
    vertex(0, height);
    endShape(CLOSE);

}

function water() {
    noStroke();
    fill(72, 90, 103); //blue
    beginShape();
    for(var x = 0; x < width; x++){
        var t = (x * terrainDetailTwo) + (millis() * terrainSpeedTwo);
        var y = map(noise(t), 0, 2, 400, 300);
        vertex(x, y);
    }
    vertex(width, height);
    vertex(0, height);
    endShape(CLOSE);
}

function moutainThree() {
    noStroke();
    fill(110, 135, 84); //light green
    beginShape();
    for(var x = 0; x < width; x++){
        var t = (x * terrainDetailThree) + (millis() * terrainSpeedThree);
        var y = map(noise(t), 0, 2, 500, 300);
        vertex(x, y);
    }
    vertex(width, height);
    vertex(0, height);
    endShape(CLOSE);
}

function drawStars(){ //what stars will look like
    noStroke();
    fill(201, 165, 180, 150);
    push();
    translate(this.x, this.y);
    ellipse (1, 10, 5, 5);
    pop();
}

function makeStars(strX, strY){ //stars object
    var star = {x: strX, 
                y: strY, 
                speed: -1, 
                move: moveStars, 
                draw: drawStars}
    return star;
}

function moveStars(){ //how stars move
    this.x += this.speed;
    if(this.x <= -10){
        this.x += width;
    }

}

function displayStars(){ //display stars
    for(i = 0; i < stars.length; i++){
        stars[i].move();
        stars[i].draw();
    }
}



For this project I decided to go with mountain landscapes. I had a good time messing with colors to create something a little different. I also generated stars in the sky. I decided to make the stars transparent so they were more subtle and you could see them pass over the moon. I also made the objects further back move slower so it would imitate what you see when you look out the window.

Sketch of Landscape

Fanjie Mike Jin — Project 11 — Landscape

sketch

// Fanjie Mike Jin
// Section C
//fjin@andrew.cmu.edu
//Project-11

// global variables declared to hold objects
// array for tree objects
var trees = []

function setup() {
    //color preprared for the gradient effect
    c1 = color(250, 100, 0);
    c2 = color(204, 143, 0);
    createCanvas(480, 480);
    frameRate(100);  
    }
function draw() {
    //draw the gradient background 
    for (var i = 0; i < height; i++) {
        var inter = map(i, 70, 110, 0, 1);
        var c = lerpColor(c1, c2, inter);
        stroke(c);
        line(0, i, width, i);
    }
    //draw the sun in the background 
    noStroke();
    fill(234, 120, 120, 200);  
    ellipse(100, 60, 90, 90);
    fill(255, 146, 128, 200);  
    ellipse(100, 60, 76, 76);

    mountainBackground(); //mountain 
    land()
    updatetrees();
    removetrees();
    newtrees(); 
}

function updatetrees(){
    // Update the x positions of the trees and display them 
    for (var i = 0; i < trees.length; i++){
        trees[i].move();
        trees[i].display();
    }
}
function removetrees(){
    //remove the building from the array once it dropped off the left edge
    var treesToKeep = [];
    for (var i = 0; i < trees.length; i++){
        if (trees[i].x + trees[i].breadth > 0) {
            treesToKeep.push(trees[i]);
        }
    }
    // the exsiting trees will be kept 
    trees = treesToKeep;
}


function newtrees() {
    // add a new tree to the end
    var probability = 0.017; 
    if (random(0,1) < probability) {
        trees.push(drawtrees(width));
    }
}

//update position of tree every frame
function treesMove() {
    this.x += this.speed;
}
    
//display the trees
function treesDisplay() {
    noStroke();
    //leaves
    fill(50, 235, 173);
    triangle(this.x - 15, 350, this.x + 15, 350, this.x, 320);
    triangle(this.x - 20, 370, this.x + 20, 370, this.x, 330);
    triangle(this.x - 30, 400, this.x + 30, 400, this.x, 350);
    //trunk
    stroke(194, 245, 228);
    line(this.x, 350, this.x, 420);
}


function drawtrees(px) {
    var dt = {x: px,
    //trees obeject properties 
                breadth: 30,
                speed: -1.0,
                move: treesMove,
                display: treesDisplay}
    return dt;
}

function mountainBackground() {
    //makes mountains in the back
    terrain = 0.009;
    terrain2 = 0.014;
    terrainSpeed = 0.0003;
    //use noise function to draw random background contour of the furthest mountains 

    stroke(30, 148, 143,200);
    beginShape(); 
    //make slowly rolling hills
    for (var j = 0; j < width; j++) {
        var t = (j * terrain) + (millis() * terrainSpeed);
        var y2 = map(noise(t), 0, 1, 200, 10);
        line(j, y2, j, height); 
    }
    endShape();

    //use noise function to draw random background contour of the closer mountains 
    stroke(65, 158, 155);
    beginShape(); 
    for (var j = 0; j < width; j++) {
        var t = (j * terrain2) + (millis() * terrainSpeed);
        var y2 = map(noise(t), 0, 1, 400, 10);
        line(j, y2, j, height); 
    }
    endShape();
}


function land() {
//makes the land in the foreground appear 
    fill(46, 84, 78);
    rect(0, 420, 480, 130);
}

When I thought about the “generative landscape”, the first idea that prompted my mind is a landscape with mountains and trees. There are two layers of mountains to show the depth of this generative landscape. There are pine trees in the foreground. I have chosen the colors strategically so that the whole composition can be read clearly and aesthetically pleasing.

quick sketch

Paul Greenway – Project 11 – Landscape

sketch

// Paul Greenway
// pgreenwa
// pgreenwa@andrew.cmu.edu
// Project-11-Landscape

var terrainSpeed = 0.0005;
var terrainDetail = 0.005;

var buildings = [];
var trees = [];

var c1;
var c2;

function setup() {
    createCanvas(480, 300); 
  
    //gradient background color set
    c1 = color(0, 90, 186); 
    c2 = color(255, 166, 0);
    setGradient(c1, c2);
    
    // create an initial collection of buildings
    for (var i = 0; i < 20; i++){
        var rx = random(width);
        buildings[i] = makeBuilding(rx);
    }
    frameRate(60);
}


function draw() { 
    
    setGradient(c1, c2);
    
    mountains1();
    mountain2();
    strokeWeight(1);
  
    
  
    updateAndDisplayBuildings();
    removeBuildingsThatHaveSlippedOutOfView();
    addNewBuildingsWithSomeRandomProbability(); 
  
    updateAndDisplayTrees();
    removeTreesThatHaveSlippedOutOfView();
    addNewTreesWithSomeRandomProbability();
  
  
  
    fill(40);
    rect (0,height-60, width, height-50);
  
    noFill();
    stroke(255);
    strokeWeight(1);
    line(0,height-40, width, height-40);
    strokeWeight(3);
    line(0,height-30, width, height-30);
  
    noStroke();
    fill(255);
    ellipse(500,50,30,30);
  
  
}


//create background mountains

function mountains1() {
  
    noStroke();
    fill(255,100);
    beginShape();
    for (var x = 0; x < width; x++) {
        var t = (x * terrainDetail*3) + (millis() * terrainSpeed);
        var y = map(noise(t), 0, 1, height/4, height/2);
        vertex(x, y);
      }
    vertex(width, height);
    vertex(0, height);
    endShape(CLOSE);
}

function mountain2() {
  
    noStroke();
    fill(185, 96, 0, 100);
    beginShape();
    for (var x = 0; x < width; x++) {
        var t = (x * terrainDetail*3) + (millis() * terrainSpeed);
        var y = map(noise(t), 0, 1, height/1.5, height/2);
        vertex(x, y);
      }
    vertex(width, height);
    vertex(0, height);
    endShape(CLOSE);
}



//set background color gradient

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


//create windy trees

function updateAndDisplayTrees(){
    
    for (var i = 0; i < trees.length; i++){
        trees[i].move();
        trees[i].display();
    }
}
function removeTreesThatHaveSlippedOutOfView(){

    var treesToKeep = [];
    for (var i = 0; i < trees.length; i++){
        if (trees[i].x + trees[i].breadth > 0) {
            treesToKeep.push(trees[i]);
        }
    }
    trees = treesToKeep; // remember the surviving buildings
}
function addNewTreesWithSomeRandomProbability() {
    // With a very tiny probability, add a new building to the end.
    var newTreeLikelihood = 0.01; 
    if (random(0,1) < newTreeLikelihood) {
        trees.push(makeTree(width));
    }
}
function treeMove() {
    this.x += this.speed;
}
function treeDisplay() {
    var treeHeight = random(45,50);
    var tHeight = treeHeight; 
    fill(0,100); 
    noStroke(); 
    push();
    translate(this.x, height - 40);
    ellipse(0, -tHeight, this.breadth-10, tHeight);
    fill('black');
    rect(0-4,-tHeight, this.breadth-45, tHeight);
    pop();
}
function makeTree(birthLocationX) {
    var tre = {x: birthLocationX,
                breadth: 50,
                speed: -1.0,
                nFloors: round(random(2,8)),
                move: treeMove,
                display: treeDisplay}
    return tre;
}
  
    

//create buildings based on starter code

function updateAndDisplayBuildings(){
    
    for (var i = 0; i < buildings.length; i++){
        buildings[i].move();
        buildings[i].display();
    }
}
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 addNewBuildingsWithSomeRandomProbability() {
    // With a very tiny probability, add a new building to the end.
    var newBuildingLikelihood = 0.005; 
    if (random(0,1) < newBuildingLikelihood) {
        buildings.push(makeBuilding(width));
    }
}
function buildingMove() {
    this.x += this.speed;
}
function buildingDisplay() {
    var floorHeight = 20;
    var bHeight = this.nFloors * floorHeight; 
    fill(100,200); 
    noStroke(); 
    push();
    translate(this.x, height - 40);
    rect(0, -bHeight, this.breadth, bHeight);
    noStroke();
    fill(255);
    for (var i = 0; i < this.nFloors; i++) {
        ellipse(3+5,-10+20*-i,5,5);
    }
    for (var y = 0; y < this.nFloors; y++) {
        ellipse(13+5,-10+20*-y,5,5);
    }
    for (var z = 0; z < this.nFloors; z++) {
        ellipse(23+5,-10+20*-z,5,5);
    }
    for (var x = 0; x < this.nFloors; x++) {
        ellipse(33+5,-10+20*-x,5,5);
    }
    pop();
}
function makeBuilding(birthLocationX) {
    var bldg = {x: birthLocationX,
                breadth: 50,
                speed: -1.0,
                nFloors: round(random(2,8)),
                move: buildingMove,
                display: buildingDisplay}
    return bldg;
}

For this project I wanted to create the view of a landscape as seen when driving in a car. I made use of the base passing buildings object as well as adding trees, mountains, and a gradient sky color to create the overall composition.

Inspiration Image

Timothy Liu — Project 11 — Landscape

tcliu-project-11

// Timothy Liu
// 15-104, Section C
// tcliu@andrew.cmu.edu
// OpenProject-11

var cowArray = []; // array for all cows
var birdArray = []; // array for all birds

// variables to control the shape and speed of the rows of trees
var backTreesStructure = 0.04;
var backTreesSpeed = 0.0009;
var frontTreesStructure = 0.04;
var frontTreesSpeed = 0.0009;

// hill in the front
var rollingPlain = 0.005;
var rollingPlainSpeed = 0.0001;

function setup() {

    createCanvas(600, 240); 

    // start with 3 cows on the screen
    for (var i = 0; i < 3; i++){
        var cowPlacement = random(0, width);
        cowArray[i] = cowObj(cowPlacement); // places the 3 cows in random locations

    }

    // draws in birds; start with 5 on the screen
    for (var j = 0; j < 5; j++) {
        birdArray.push(birdObj(j * 30 + random(40, width - 40),
                        random(20, 60), random(10, 25))); // gives the birds random x, y, and size
    }

    frameRate(40);

}

function draw() {

    background(124, 196, 230); // sky color

    drawTrees(); // draw the two rows of trees first (in the background)

    updateAndShowCows(); // draw and have the cows move

    updateCowsOffScreen(); // account for when cows move off screen

    updateAndShowBirds(); // draw and have the birds move

    updateBirdsOffScreen(); // account for when birds move off screen

    newCows(); // draws in new cows (from edge of screen)

    newBirds(); // draws in new birds (from edge of screen)
}

function drawTrees() {

    // the back (darker) row of trees
    beginShape();
    fill(40, 120, 61);
    noStroke();
    vertex(0, height);

    // use noise function to draw random tree line
    for (var x = 0; x < width; x++) {
        var t = (x * backTreesStructure) + (millis() * backTreesSpeed);
        var y = map(noise(t), 0, 1, 40, 150);
        vertex(x, y); 
    }
    vertex(width, height);
    endShape();

    // the front (lighter) row of trees
    beginShape(); 
    fill(50, 168, 82);
    noStroke();
    vertex(0, height);

    //use noise function to draw random, lower tree line to create depth
    for (var x = 0; x < width; x++) {
        var t = (x * frontTreesStructure) + (millis() * frontTreesSpeed);
        var y = map(noise(t * 0.7), 0, 1, 80, 200);
        vertex(x, y); 
    }
    vertex(width, height);
    endShape();

    // the light-green hills in front
    beginShape(); 
    fill(154, 196, 118);
    noStroke();
    vertex(0, height);

    // use a dampened version of the noise function to make slowly rolling hills
    for (var x = 0; x < width; x++) {
        var t = (x * rollingPlain) + (millis() * rollingPlainSpeed);
        var y = map(noise(t * 0.5), 0, 1, 170, 200);
        vertex(x, y); 
    }
    vertex(width, height);
    endShape();

}

// puts the cows on the canvas and makes them move
function updateAndShowCows(){

    for (var i = 0; i < cowArray.length; i++){

        cowArray[i].move(); // move property of the cow obj
        cowArray[i].show(); // show property of the bird obj

    }
}

// puts the birds on the canvas and makes them move
function updateAndShowBirds(){

    for (var i = 0; i < birdArray.length; i++){

        birdArray[i].moveB(); // move property of the bird obj
        birdArray[i].showB(); // show property of the bird obj

    }
}

// eliminates the cows that move off screen
function updateCowsOffScreen(){

    var cowsToKeep = []; // to determine which cows are still on screen

    for (var i = 0; i < cowArray.length; i++) {
        if (cowArray[i].x + cowArray[i].cowWidth > 0) { // if the cow is still on the screen
            cowsToKeep.push(cowArray[i]); // put it into the new array
        }
    }

    // cowsToKeep[] becomes the new array of cows currently on screen
    cowArray = cowsToKeep;
}

// eliminates the birds that move off screen
function updateBirdsOffScreen(){

    var birdsToKeep = []; // to determine which birds are still on screen

    for (var i = 0; i < birdArray.length; i++) {
        if (birdArray[i].bx + birdArray[i].sizeOfBird > 0) { // if the bird is still on the screen
            birdsToKeep.push(birdArray[i]); // put it into the new array
        }
    }

    // birdsToKeep[] becomes the new array of birds currently on screen
    birdArray = birdsToKeep;
}

// occasionally, add a new cow to the end of the screen
function newCows() {
    var newCowOdds = 0.008; 
    if (random(0, 1) < newCowOdds) {
        cowArray.push(cowObj(width)); // add a new cow to the array
    }
}

// occasionally, add a new bird to the end of the screen
function newBirds() {
    var newBirdOdds = 0.008;
    if (random(0, 1) < newBirdOdds) {
        birdArray.push(birdObj(width, random(20, 50), random(10, 25))); // add a new bird to the array
    }
}

// makes the cows move
function movingCows() {
    this.x += this.speed;
}

// makes the birds move
function movingBirds() {
    this.bx += this.speedBird;
}

// this is what actually draws in, and displays, the cows using various cow object properties
function showCows() {

    var cowPlacement = this.randomLoc;
    var earOffset = 7;
    var headOffset = 15;
    var eyeOffset = 10;
    var spot2Offset = 5;
    var spot3Offset = 4;
    var snoutOffset = 6;

    push();

    translate(this.x, height); // places the cows onto the canvas

    // shadow
    noStroke();
    fill(7, 66, 25);
    ellipse(0, -cowPlacement + 10, this.cowWidth, this.cowHeight / 4);

    // cow body
    fill(this.randomColor);
    arc(0, -cowPlacement, this.cowWidth, this.cowHeight * 0.75, 2 * PI / 3, PI / 3, CHORD);
    
    // cow ears
    arc(-headOffset - earOffset, -cowPlacement - headOffset, this.earW, this.earW * 0.75, 4 * PI / 3, PI / 3, CHORD);
    arc(-headOffset + earOffset, -cowPlacement - headOffset, this.earW, this.earW * 0.75, 2 * PI / 3, 5 * PI / 3, CHORD);
    
    // cow head
    ellipse(-headOffset, -(cowPlacement + eyeOffset), this.cowHead * 1.25, this.cowHead);

    // three spots
    fill(0);
    ellipse(this.spot1, -cowPlacement, this.spotW, this.spotH);
    ellipse(this.spot2, -cowPlacement + spot2Offset, this.spotW * 1.2, this.spotH);
    ellipse(this.spot3, -cowPlacement - spot3Offset, this.spotW, this.spotH * 1.2);

    // eyes
    ellipse(-18, -cowPlacement - eyeOffset, this.eye, this.eye * 1.2);
    ellipse(-12, -cowPlacement - eyeOffset, this.eye, this.eye * 1.2);

    // snout
    fill("#eba4dd");
    ellipse(-15, -(cowPlacement + snoutOffset), this.snout * 1.6, this.snout);
    
    pop();

}

// this is what actually draws in, and displays, the birds using various bird object properties
function showBirds() {

    var birdBod = 5; // body size of bird

    noFill();
    stroke(0);
    strokeWeight(2);

    push();

    // places and sizes the birds
    translate(this.bx, this.by);
    scale(this.sizeOfBird / 60);
    ellipseMode(CENTER);

    // uses arcs and ellipses to draw the wings and body
    arc(35, 35, 100, 100, 5 * PI / 4, 3 * PI / 2);
    arc(-35, 35, 100, 100, 3 * PI / 2, 7 * PI / 4);
    fill(0);
    ellipse(0, 0, birdBod, birdBod); 

    pop();

}

// here are all the properties of the cow object
function cowObj(x) {

    let colors = ["#8f6846", "#ffffff", "#918880"] // different colors of cows

    // cow obj properties
    var cow = {x: x,
                cowWidth: random(30, 40), // each cow has a diff size and shape
                cowHeight: random(25, 40),
                cowHead: random(10, 16),
                snout: 7,
                spot1: random(-12, -8),
                spot2: random(1, 5),
                spot3: random(5, 10),
                eye: 3,
                earW: 8,
                spotW: 8,
                spotH: 6,
                speed: random(-3, -1), // each cow moves at a diff speed
                move: movingCows,
                show: showCows,
                randomLoc: random(35, 60),
                randomColor: random(colors), // each cow has a different color
            }

    return cow;

}

// here are all the properties of the bird object
function birdObj(x, y, size) {

    // bird obj properties
    var bird = {bx: x, 
                by: y, 
                sizeOfBird: size, // each bird has a random size
                speedBird: random(-4, -1), // each bird has a random speed
                showB: showBirds,
                moveB: movingBirds
            };

    return bird;

}

When I thought about the “generative landscape” prompt for this week’s assignment, one of the first things that came to mind was the scenery during the long road trips my family takes every year from the Bay Area to Southern California. I distinctly remember staring out the window as a kid, watching cows idly graze in fields and the rolling trees and hills zoom by as we drove down I-5. Thus, I wanted to model my project after this landscape because it’s a very fond childhood memory of mine.

An example of a landscape similar to what I was trying to capture in my project.

In my generative landscape, I have cows of all sorts of shapes, colors, and sizes on grassy plains as the screen pans leftward. In the background, rows of trees and grassy hills roll by, and birds fly overhead at varying speeds. My piece is meant to represent an idyllic view of what a kid sees when they stare out the window on a road trip through California’s central valley. The blue sky, the flocking birds, and the vast greenery all convey warmth and happiness. Ultimately, I think it’s the motion and dynamism of my piece that really help capture the feeling of blissfulness.