Nina Yoo – Project 10 – Landscape

sketch

 /* Nina Lee Yoo
Section E
nyoo@andrew.cmu.edu
Project- 10:Landscape*/
var terrainSpeed = 0.0005;
var terrainDetail = 0.005;
var terrainDetailB = 0.0015;
var person = [];




function setup() {
    createCanvas(480, 480);
    frameRate(10);

  }
 
function draw() {
    background("pink");
   	
   	noStroke();
    push();
    beginShape();
    fill(176, 196, 222);
    vertex(0,height);



    for (var x = 0; x < width; x++) { // creating background of the first landscape
        var t = (x * terrainDetail) + (millis() * terrainSpeed);
        var y = map(noise(t), 0,1, 0, height);
        vertex(x, y+10); 
    }
    vertex(width,height);
    endShape();
    pop();

    push();
    beginShape();
    fill(250,250,205);
    vertex(0,height);
    for(var x = 0; x<width; x ++){ // creating backfround for the yellow landscape
    	var t = (.5*x*terrainDetailB)+ (millis()*terrainSpeed);
    	var y = map(noise(t),0,1,0,height);
    	vertex(x,y+200);

    }
    vertex(width,height);
    endShape();
    pop();

    //people
  
    push()
    updateP();
    removeP();
    addNewP(); 
    pop()
}


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


function removeP(){

    var personToKeep = [];
    for (var i = 0; i < person.length; i++){
        if (person[i].x + person[i].breadth > 0) {
            personToKeep.push(person[i]);
        }
    }
    persons = personToKeep; 
}

function addNewP(){
   
    var newPerson = 0.01; 
    if (random(0,1) < newPerson) {
        person.push(makePerson(width));
    }
}


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

function personDisplay() {
	push()
    var personHeight = 20;
    var pHeight = this.nPersons * personHeight; 
    fill(255); 
    noStroke(); 
    push();
    translate(this.x, height - 40);
    ellipse(0, -pHeight, this.breadth, pHeight); // drawing the body
    fill(0);
    ellipse(-15, -pHeight - 20, 5, 5); // drawing eyes 
    ellipse(15, -pHeight - 20, 5, 5);

    stroke(200); 
    
    pop()
    }

 



function makePerson(birthLocationX) {
    var personn = {x: birthLocationX,
                breadth: 50,
                speed: -1.0,
                nPersons: round(random(2,8)),
                move: personMove,
                display: personDisplay}
    return personn;
}














I got inspired by this show I watched a long time ago with my brother. It was this weird cartoon blobs with little beady eyes that would just move from place to place in swarms, creating trouble along the way. It was fun to create the moving setting for the little guys and see the different little white marshmellow blobs come out.

Project 10-Jaclyn Saik

week10

var sheep = [];
var terrainSpeed = 0.0005;
var terrainSpeedB = 0.0002;
var terrainSpeedS = 0.0001;

var terrainDetail = 0.02;
var terrainDetailB = 0.01;
var terrainDetailS = 0.03;

function setup() {
    createCanvas(480, 480); 
    
    for (var i = 0; i < 10; i++){ //fills the array with sheep
        var rx = random(width);
        sheep[i] = makeSHEEPS(rx);
    }
    frameRate(10);
}

function draw() {
    background("PaleTurquoise"); //the sky
    noStroke();
    fill("coral"); //sun
    ellipse(130, 100, 30, 30) 

    //darkest green hills
    beginShape(); 
    stroke("darkgreen");
    for (var x = 0; x < width; x++) {
        var t = (x * terrainDetail) + (millis() * terrainSpeedS); //creates detail in terrain
        //based on milliseconds that pass
        var y = map(noise(t), 0,1, 170, height/2);
        line(x, y, x, height); //I used this in order to fill my hills with color
    }
    endShape();
    
    //darker green hills
    beginShape(); 
    stroke("forestgreen");
    for (var x = 0; x < width; x++) {
        var t = (x * terrainDetail) + (millis() * terrainSpeedB); //terrain speeds differ as object appear closer
        //or further away
        var y = map(noise(t), 0,1, 210, height/2);
        line(x, y, x, height); 
    }
    endShape();

    //green hills
    beginShape(); 
    stroke("darkseagreen");
    for (var x = 0; x < width; x++) {
        var t = (x * terrainDetailB) + (millis() * terrainSpeedB);
        var y = map(noise(t), 0,1, 280, height/2);
        line(x, y, x, height); 
    }
    endShape();
    
    showSHEEP();
    byeOLDsheep(); //removes old sheep when they leave the frame
    addNewSHEEPS(); //adds more sheep

    //road bushes
    beginShape(); 
    stroke("olivedrab");
    for (var x = 0; x < width; x++) {
        var t = (x * terrainDetailB) + (millis() * terrainSpeed);
        var y = map(noise(t), 0,1, 430, 400);
        line(x, y, x, height); 
    }
    endShape();
    noStroke(); 

    displayROAD();

}

function showSHEEP() {
    // prints and moves the sheep
    for (var i = 0; i < sheep.length; i++){
        sheep[i].move();
        sheep[i].display();
    }
}

function byeOLDsheep(){
    var sheepToKeep = [];
    for (var i = 0; i < sheep.length; i++){
        if (sheep[i].x + sheep[i].breadth > 0) {
            sheepToKeep.push(sheep[i]);
        }
    }
    sheep = sheepToKeep; //fills with remaining sheeps so they continue to print
}

function addNewSHEEPS() {
    var newSHEEPLikelihood = 0.009; 
    if (random(0,1) < newSHEEPLikelihood) {
        sheep.push(makeSHEEPS(width));
    }
}

//makes the sheep move forward with each frame, depending on var speed
function sheepMove() {
    this.x += this.speed;
}
    
// the physical build of each sheep
function SheepDisplay() {
    var floorHeight = 20;
    var bHeight = this.nFloors * floorHeight; 
    push();
    noStroke();
    translate(this.x, height - 40);
    //legs of sheep
    fill("wheat");
    rect(-7, -bHeight+3, 3, 16);
    rect(-1, -bHeight+5, 3, 16);
    rect(7, -bHeight+5, 3, 16);
    rect(12, -bHeight+3, 3, 16);

    //body of sheep
    fill(255); 
    ellipse(0, -bHeight, 10, 10);
    ellipse(10, -bHeight+10, 10, 10);
    ellipse(5, -bHeight+10, 10, 10);
    ellipse(10, -bHeight+5, 10, 10);
    ellipse(10, -bHeight+5, 15, 15);
    ellipse(-5, -bHeight+5, 15, 15);
    ellipse(-5, -bHeight+10, 10, 10);
    ellipse(0, -bHeight+12, 10, 10);
    ellipse(10, -bHeight, 10, 10);
    fill("wheat");
    ellipse(-10, -bHeight+7, 12, 8);
    ellipse(-7, -bHeight+3, 2, 5);
    ellipse(-10, -bHeight+3, 2, 5);
    fill("black");
    ellipse(-10, -bHeight+7, 2, 2);

    pop();
}

function makeSHEEPS(birthLocationX) { //creates sheeep at their randomized locations within reason
    var lilsheep = {x: birthLocationX,
                breadth: 10,
                speed: -2.5,
                nFloors: round(random(2,8)),
                move: sheepMove,
                display: SheepDisplay}
    return lilsheep;
}

function displayROAD(){ //function for printing the road in the foreground
    noStroke();
    fill("silver");
    rect(0,height-50, width, height-50); 
    fill("dimgray");
    rect(0,height-45, width, height-50); 
}

For this landscape, I wanted to make something that was idellic and nice to look at. When I was little, I would always try to draw the landscape outside when I was sitting in the car on road trips (especially when there are livestock to admire!) but I never could capture it accurately since it’s moving by so quickly. This is hardly an accurate description of what I would remember, but I like that this medium allows me to create moving animations that at least capture that aspect of my memory. I also had fun choosing colors.

My original drawing

Catherine Coyle – Project 10

sketch

// Catherine Coyle
// Section C
// ccoyle@andrew.cmu.edu
// Project 10 - generative landscape


var startingTrees = 10;
var trees = [];
var fog = [];
var fireflies = [];
var birds = [];
var frameC = 1;

function setup() {
    createCanvas(480, 300);
    for (var i = 0; i < startingTrees; i++) {
    	var newTree = makeTree(random(width));
    	// this little chunk of code minimizes the chances of trees overlapping each other
    	for (var j = 0; j < trees.length; j++) {
    		while (((newTree.x > trees[j].x) & (newTree.x < trees[j].x + (trees[j].proximity * 30))) ||
    				((newTree.x + (newTree.proximity * 30) > trees[j].x) && 
    				(newTree.x + (newTree.proximity * 30) < trees[j].x + (trees[j].proximity * 30)))) {
    					newTree = makeTree(random(width));
    		}
    	}
    	trees.push(newTree);
    }
    // generating all the fog clouds and fireflies to start
    for (var i = 0; i < 5; i++) {
    	var newCloud = makeCloud(random(width));
    	fog.push(newCloud);
    }
    for (var i = 0; i < 20; i++) {
    	var newFly = makeFirefly(random(width));
    	fireflies.push(newFly);
    }
}

function draw() {
	// moon and horizon line
	background(76, 93, 99);
	noStroke();
	fill(43, 61, 56);
	rect(0, 100, width, 200)
	fill(255, 253, 237);
	ellipse(width / 2, 0, 70, 70);
	// drawing all my objects each frame
	for (var i = 0; i < birds.length; i++) {
		birds[i].draw();
		birds[i].move();
	}
	for (var i = 0; i < trees.length; i++) {
		trees[i].draw();
		trees[i].move();
	}
	for (var i = 0; i < fireflies.length; i++) {
		fireflies[i].draw();
		fireflies[i].move();
	}
	for (var i = 0; i < fog.length; i++) {
		fog[i].draw();
		fog[i].move();
	}
	// occasionally adding new objects
	// making them dependent on frameC affects the distance apart they will be from each other
	if ((frameC % 30 == 0) & (random(1) < .5)) {
		newTree = makeTree(width);
		trees.push(newTree);
	}
	if ((frameC % 100 == 0) & (random(1) < .5)) {
		newCloud = makeCloud(width);
		fog.push(newCloud);
	}
	if ((frameC % 5 == 0) & (random(1) < .5)) {
		newFly = makeFirefly(width);
		fireflies.push(newFly);
	}
	// want the birds flying by to be kind of rare
	if (random(1) < .008) {
		newBird = makeBird();
		birds.push(newBird);
	}
	frameC++;
	// removing elements that have passed (so list doesnt get too long)
	removeOldTrees();
	removeOldClouds();
	removeOldFlies();
}

// most code below here is straightforward

// each element has its own object and unique properties

function makeTree(startingPt) {
	var tree = {
		x: startingPt,
		proximity: random(1/3, 1),
		draw: drawTree,
		move: moveTree
	}
	return tree;
}

function makeCloud(startingPt) {
	var cloud = {
		x: startingPt,
		visibility: random(1),
		cloudW: random(80, 300),
		elevation: random(50),
		draw: drawCloud,
		move: moveCloud,
	}
	return cloud;
}

function makeFirefly(startingPt) {
	var firefly = {
		x: startingPt,
		y: random(height),
		velX: random(-2, 1.5),
		velY: random(-2, 2),
		sizeF: random(10),
		draw: drawFirefly,
		move: moveFirefly
	}
	return firefly;
}

function makeBird() {
	var bird = {
		x: width,
		y: random(80),
		draw: drawBird,
		move: moveBird,
	}
	return bird;
}

function drawBird() {
	fill(0);
	triangle(this.x, this.y, this.x + 20, this.y - 10, this.x + 20, this.y + 10);
}

function moveBird() {
	this.x -= 5;
}

function drawFirefly() {
	fill(226, 220, 145, 60);
	ellipse(this.x, this.y, this.sizeF * 1.5, this.sizeF * 1.5);
	fill(226, 220, 145);
	ellipse(this.x, this.y, this.sizeF, this.sizeF);
}

function moveFirefly() {
	this.x -= 1.5;
	this.x += this.velX;
	this.y += this.velY;
}

function drawCloud() {
	fill(255, this.visibility * 100);
	rect(this.x, height - this.cloudW / 2 - this.elevation, this.cloudW, this.cloudW / 2);
}

function moveCloud() {
	this.x -= .5;
}

function drawTree() {
	fill(10 + 70 * this.proximity, 30, 55);
	rect(this.x, 0, 30 * this.proximity, height * this.proximity);
}

function moveTree() {
	this.x -= 1;
}


// these 'remove' functions work by looping through the objects
// and getting rid of whats offscreen
function removeOldTrees() {
	for (var i = 0; i < trees.length; i++) {
		if (trees[i].x + 30 * trees[i].proximity < 0) {
			trees.splice(i, 1);
		}
	}
}

function removeOldClouds() {
	for (var i = 0; i < fog.length; i++) {
		if (fog[i].x + fog[i].cloudW < 0) {
			fog.splice(i, 1);
		}
	}
}

function removeOldFlies() {
	for (var i = 0; i < fireflies.length; i++) {
		if ((fireflies[i].x + fireflies[i].sizeF / 2 < 0) ||
			(fireflies[i].y + fireflies[i].sizeF / 2 < 0) ||
			(fireflies[i].y + fireflies[i].sizeF / 2 > height)) {
			fireflies.splice(i, 1);
		}
	}
}

 

This project was really fun! I’m in the Halloween/fall mood so I wanted to do something kind of dark and decided to go with a forest landscape.

My first sketches on paper (not everything here was put into the final project)

The trees look simple but were probably the most complex part of the project. I wanted to give a feeling of depth so the further trees are smaller and darker in color. However, this made it look really bad when the trees were first initially generated because some would overlap and look really weird so I tried my best to avoid that in setup. The  fireflies were pretty easy to do but I think they might be my favorite part of the project because they’re just nice to look at.

Lingfan Jiang-Project-10-Landscape

sketch

// Lingfan Jiang
// Section B
// lingfanj@andrew.cmu.edu
// Project-10

var people = [];


function setup() {
    createCanvas(480, 300); 
    
    // create an initial collection of people
    for (var i = 0; i < 10; i++){
        var rx = random(width);
        people[i] = makePeople(rx);
    }
}


function draw() {
    background(240); 

    updateAndDisplaypeople();
    removepeopleThatHaveSlippedOutOfView();
    addNewpeopleWithSomeRandomProbability(); 

    //belt
    fill(180);
    rect(-5, 190, 500, 110);
    push();
    translate(-100, 0);
    for (var i = 0; i < 20; i++) {
        stroke(100);
        line((i + 3) * 50, 190, i * 50, 300);
    };
    pop();
    stroke("pink");
    line(0, 190, 480, 190);
    line(0, 297, 480, 297);

    //draw sushi bottom
    noStroke();
    fill(255);
    beginShape();
    curveVertex(180, 250);
    curveVertex(250, 240);
    curveVertex(300, 260);
    curveVertex(250, 270);
    endShape(CLOSE);

    //draw sushi top
    fill(255, 160, 160);
    beginShape();
    curveVertex(150, 240);
    curveVertex(170, 235);
    curveVertex(240, 220);
    curveVertex(300, 230);
    curveVertex(330, 260);
    curveVertex(240, 250);
    curveVertex(150, 260);
    endShape(CLOSE);

    //draw lines above sushi
    stroke(255, 201, 201);
    strokeWeight(7);
    line(200, 230, 220, 246);
    line(160, 240, 175, 252);
    line(240, 222, 265, 245);
    line(280, 225, 315, 256);

}


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


function removepeopleThatHaveSlippedOutOfView(){
    // If a people has dropped off the left edge,
    // remove it from the array.  This is quite tricky, but
    // we've seen something like this before with particles.
    // The easy part is scanning the array to find people
    // to remove. The tricky part is if we remove them
    // immediately, we'll alter the array, and our plan to
    // step through each item in the array might not work.
    //     Our solution is to just copy all the people
    // we want to keep into a new array.
    var peopleToKeep = [];
    for (var i = 0; i < people.length; i++){
        if (people[i].x + people[i].breadth > 0) {
            peopleToKeep.push(people[i]);
        }
    }
    people = peopleToKeep; // remember the surviving people
}


function addNewpeopleWithSomeRandomProbability() {
    // With a very tiny probability, add a new people to the end.
    var newPeopleLikelihood = 0.007; 
    if (random(0,1) < newPeopleLikelihood) {
        people.push(makePeople(width));
    }
}


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

// draw the people and some windows
function peopleDisplay() {
    fill(255); 
    stroke(0); 
    strokeWeight(5);
    push();
    translate(this.x, height - 100);
    //people outline
    fill(255, 235, 222);
    ellipse(0, 0, this.breadth, this.breadth);
    //eyes
    fill(255);
    strokeWeight(3);
    ellipse(-30, -50, 30, 30);
    ellipse(30, -50, 30, 30);
    fill(0);
    ellipse(-30, -40, 5, 5);
    ellipse(30, -40, 5, 5);
    pop();
}


function makePeople(birthLocationX) {
    var ppl = {x: birthLocationX,
                breadth: random(150, 300),
                speed: -1.0,
                move: peopleMove,
                display: peopleDisplay}
    return ppl;
}

When I first saw this assignment, it reminded me of the conveyor belt sushi right away. However, instead of letting the sushi move in front of a static human, I decided to let the sushi stay. For the generative background, I wanted to learn it since the abstract clock project. It took me some time to figure out how the generative code works, but it is definitely easier than I expected. As a result, it turns out pretty well. If I have more time to work on it, maybe I would do another layer of a background behind the “people”. Overall, it’s a super fun project to do.

sketch

 

Jenni Lee—Project 10—Landscape

sketch

/* Jenni Lee
Section E
jennife5@andrew.cmu.edu
jennife5-project-10
*/

var houses = [];

function setup() {
  createCanvas(640, 240);

  // create an initial collection of buildings
  for (var i = 0; i < 10; i++) {
    var rx = random(width);
    houses[i] = makeHouse(rx);
  }
  frameRate(10);
}


function draw() {
  background(237, 190, 150);
  
  noStroke ();
  fill (255, 217, 161);
  rect (0, 0, width - 1, height - 51);

  drawTerrain();

  displayStatusString();
  displayHorizon();

  updateAndDisplayHouses();
  removeHousesThatHaveSlippedOutOfView();
  addNewHousesWithSomeRandomProbability();
}


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


function removeHousesThatHaveSlippedOutOfView() {
  // If a house has dropped off the left edge,
  // remove it from the array.  This is quite tricky, but
  // we've seen something like this before with particles.
  // The easy part is scanning the array to find houses
  // to remove. The tricky part is if we remove them
  // immediately, we'll alter the array, and our plan to
  // step through each item in the array might not work.
  // Our solution is to just copy all the buildings
  // we want to keep into a new array.
  var housesToKeep = [];
  for (var i = 0; i < houses.length; i++) {
    if (houses[i].x + houses[i].breadth > 0) {
      housesToKeep.push(houses[i]);
    }
  }
  houses = housesToKeep; // remember the surviving houses
}


function addNewHousesWithSomeRandomProbability() {
  // With a very tiny probability, add a new house to the end.
  var newHouseLikelihood = 0.003;
  if (random(0, 1) < newHouseLikelihood) {
    houses.push(makeHouse(width));
  }
}


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


// draw the building and some windows
function houseDisplay() {
  var floorHeight = 30;
  var bHeight;
  if (this.nFloors == 1) {
    bHeight = 30;
  } else {
    bHeight = 50;
  }
  fill(255);
  noStroke();
  push();
  translate(this.x, height - 40);
  if (this.nHouseColor == 1) {
  	fill(128, 0, 0);
  }
  else {
  	noStroke();
    fill (252, 235, 180);
  }
  rect(0, -bHeight, this.breadth, bHeight);
  
  // door
  noStroke();
  
  if (this.nDoorColor == 1) {
  	fill(0, 128, 0);
  }
  else {
  	fill(204, 204, 0);
  }
  rect(5, -20, this.breadth - 35, 20);
  // door knob
  stroke(0);
  strokeWeight(3);
  point(10, -10);

  // window

  stroke(0);
  strokeWeight(1);
  fill(200);
  rect(this.breadth - 20, -25, 15, 10);
  line(this.breadth - 20, -20, this.breadth - 5, -20);
  line(this.breadth - 12.5, -15, this.breadth - 12.5, -25);
  if (this.nFloors == 2) {
    line(0, -30, this.breadth, -30);
    rect(this.breadth - 30, -45, 15, 10);

    line(this.breadth - 30, -40, this.breadth - 15, -40);
    line(this.breadth - 22.5, -45, this.breadth - 22.5, -35);
  }
  fill(35);
  triangle(-10, -bHeight, this.breadth + 10, -bHeight, this.breadth / 2, -bHeight - 20);
  pop();
}


function makeHouse(birthLocationX) {
  var hse = {
    x: birthLocationX,
    breadth: 50,
    speed: -1.0,
    nFloors: round(random(1, 2)),
    nHouseColor: round(random(1, 2)), 
    nDoorColor: round(random(1, 2)),
    move: houseMove,
    display: houseDisplay
  }
  return hse;
}


function displayHorizon() {
  stroke(0);
  line(0, height - 50, width, height - 50);
}


function displayStatusString() {
  noStroke();
  fill(0);
  var statusString = "# Houses = " + houses.length;
  text(statusString, 5, 20);
}

// Simple demonstration of the noise() function. 
// Change these for different effects:
var terrainSpeed = 0.00005;
var terrainDetail = 0.005;

function drawTerrain() {
  noFill(); 
  beginShape();
  for (var x = 0; x < width; x++) {
    var t = (x * terrainDetail) + (millis() * terrainSpeed);
    var y = map(noise(t), 0, 1, 0, height - 40);
    stroke (196, 176, 146);
    line (x, y, x, height - 50);
//    vertex(x, y);
  }
  endShape();

  noStroke ();
  rect(0, 0, width - 1, height - 1);
}

For this project, I was inspired by the movie Inception. There was a scene in the movie in which the characters are in a dream and they walk around a eerie environment with various houses. I used a warm color scheme to give it a dilapidated, desert-like feeling.

Here is one of my preliminary digital concept sketches drawn on my ipad in which I tested out forms and colors.

Kai Zhang-Project-10-Landscape

sketch

//Kai Zhang
//Section B
//kaiz1@andrew.cmu.edu
//Project-10

var bcs = []; //bloodcells
var bcpositionX = [];
var bcpositionY = [];
var bcspeed = [];
var bcsizing = [];
var bccolor = [];

var vesselDetail = 0.002;
var vesselSpeed = -0.001;

function setup() {
    createCanvas(480, 400);
    colorMode(HSB, 100);
}

function draw() {
    background(240, 70, 40);

	//vessel fluid
	for (var i = 0; i < 480; i += 20) {
	    push();
	    stroke(255, 70, 55);
	    fill(255, 60, 55);
	    strokeWeight(3);
		beginShape();
	    for (var q = 0; q < width; q++) {
	        var t = (q * vesselDetail) + (millis() * vesselSpeed);
	        var y = map(noise(t), 0,1, i, i + 30);
	        vertex(q, y);
	    }
	    endShape();
	    pop();
	}


    noStroke();
    //assigh all the variables
    for (var i = 0; i < 80; i ++) {
        bcpositionX.push(random(-200, 600));
        bcpositionY.push(random(140, 260));
        bccolor.push(random(80, 100));
        bcsizing.push(random(15,35));
        bcspeed.push(random(2, 5));
    }

    //draw the bloodcells
    for (var i = 0; i < 80; i ++) {
        bcs[i] = makeBloodCell(bcpositionX[i], bcpositionY[i], bccolor[i], bcsizing[i]);
        bcpositionX[i] += bcspeed[i];
        bcs[i].draw();
        if (bcpositionX[i] > 800) {
            bcpositionX[i] = -200;
        }
    }

    //masking
    stroke(255, 70, 60);
    strokeWeight(7)
    fill(255, 30, 20);
    rect(-20, -20, 520, 160);
    rect(-20, 260, 520, 160);

	

}


//function to draw each bloodcell
function bcDraw() {
    fill(255, 80, this.bccolor,);
    ellipse(this.bcx, this.bcy, this.bcsize);

    fill(255, 80, this.bccolor - 10,);
    ellipse(this.bcx, this.bcy, this.bcsize * 0.6);
}

//function to create a bloodcell object
function makeBloodCell(x, y, col, size) {
    var bc = {"bcx": x, "bcy": y, "bccolor": col, "bcsize": size};
    bc.draw = bcDraw;
    return bc;
}

For this week’s project “landscape”, instead of creating a normal type of landscape that passes by, I decided to do a microscopic approach – blood cells, as it’s a perfect demonstration of the effect showing different blood cells of difference sizes and move at different speeds across the vessel.

In the code, I’ve used the object “bc” which represents blood cells, assign it with different sizes, colors, and speed. I’ve also put a background fluid flow to increase the fidelity of the imagery.

I’ve used a reference image I found online, and I also did a sketch to represent the logic of the codes.

Image result for blood cells

image URL: https://immuno-oncologynews.com/2017/03/13/erytech-presents-new-data-employing-red-blood-cells-cancer-vaccines/

Jisoo Geum – Project 10 – Landscape

sketch

// Jisoo Geum
// Section B
// jgeum@andrew.cmu.edu 
// Project-10
//global variables
var thethings = [];
var boomSpeed = 0.005;
var boomDetail = 0.05;

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

    // create an initial collection of thethings
    for (var i = 0; i < 10; i++){
        var rx = random(width);
        thethings[i] = makeThethings(rx);
    }
    frameRate(10);
   
}
 
function draw() {
    //background(70,223,191);
    background(0);
    makeBooms(); 

    //display the things (ellipses)
    updateAndDisplayThethings();
    removeThethingsThatHaveSlippedOutOfView();
    addNewThethingsWithSomeRandomProbability(); 
    //display speaker
    makeSpeaker();

}

function makeBooms(){
    noStroke();
   /* 
    //1st boom
    //fill(51,194,248);
    //fill(0);
    noFill();
    strokeWeight(1);
    //stroke(160,240,19);
    stroke(247,223,90);
    beginShape(); 
    vertex(-10,height);
    for (var x = 0; x < width; x++) {
        var t = (x * boomDetail*3) + (millis() * boomSpeed*20);
        var y = map(noise(t), 0, 1 , 200, height); 
        //4th num ++=more straight, --= more abrubt
        //last num ++=lower, --= higher 
        vertex(x ,y/6); // y++ = lower, y -- = higher  
    }
    vertex(width+10,height);
    endShape();

   //2nd boom
    fill(0);
    //noFill();
    strokeWeight(1.2);
    //stroke(160,240,19);
    stroke(70,223,191);
    beginShape(); 
    vertex(-10,height);
    for (var x = 0; x < width; x++) {
        var t = (x * boomDetail) + (millis() * boomSpeed*20);
        var y = map(noise(t), 0, 1 , 200, height); 
        //4th num ++=more straight, --= more abrubt
        //last num ++=lower, --= higher 
        vertex(x ,y/4); // y++ = lower, y -- = higher  
    }
    vertex(width+10,height+10);
    endShape();
*/
    // 3rd boom
    fill(160,240,19);
    
    //noFill();
    strokeWeight(5);
    //stroke(160,240,19); // green 
    stroke(70,223,191);
    beginShape(); 
    vertex(-10,height);
    for (var x = 0; x < width; x++) {
        var t = (x * boomDetail) + (millis() * boomSpeed*20);
        var y = map(noise(t), 0, 1 , 100 , height); 
        //4th num ++=more straight, --= more abrubt
        //last num ++=lower, --= higher 
        vertex(x ,y/2); // y++ = lower, y -- = higher  
    }
    vertex(width+10,height);
    endShape();

    // 4th boom 
    //fill(70,223,191); turqoise
    fill(0);
    //noFill();
    strokeWeight(3);
    stroke(160,240,19); green
    //stroke(254,112,99); // orange 
    //stroke(255);
    beginShape(); 
    vertex(-10,height);
    for (var x = 0; x < width; x++) {
        var t = (x * boomDetail+10) + (millis() * boomSpeed*20);
        var y = map(noise(t), 0, 1 , 0 , height-90); 
        //4th num ++=more straight, --= more abrubt
        //last num ++=lower, --= higher 
        vertex(x ,y); // y++ = lower, y -- = higher  
    }
    vertex(width+10,height*2);
    endShape();
}


function updateAndDisplayThethings(){
    // Update thething's positions, and display them.
    for (var i = 0; i < thethings.length; i++){
        thethings[i].move();
        thethings[i].display();
    }
}


function removeThethingsThatHaveSlippedOutOfView(){
    var thethingsToKeep = [];
    for (var i = 0; i < thethings.length; i++){
        if (thethings[i].x + thethings[i].breadth > 0) {
            thethingsToKeep.push(thethings[i]);
        }
    }
    thethings = thethingsToKeep; // remember the surviving things
}


function addNewThethingsWithSomeRandomProbability() {
    // With a very tiny probability, add a new thing to the end.
    var newThethingsLikelihood = 0.007; 
    if (random(0,1) < newThethingsLikelihood) {
        thethings.push(makeThethings(width));
    }
}


// update position of thethings every frame
function thethingsMove() {
    this.x += this.speed;
}
    
// draw the thethings
function thethingsDisplay() {
    var floorHeight = 10;
    var thethingsX = random(0,300);
    var size1 = random(5,25);
    var size2 = random(2,20);
    var size3 = random(15,30);
    var bHeight = this.nFloors * floorHeight;  
    var transheight = random(20,height)

// making the things 
    push();
    translate(this.x, height - 50);
    noFill();
    stroke(160,240,19);
    strokeWeight(1.5);
    ellipse(thethingsX, -bHeight/4, size1 , size1);
    stroke(70,223,191);
    ellipse(thethingsX, -bHeight/4, size2 , size2);
    //stroke(80,93,255);
    //ellipse(thethingsX, -bHeight+95, size3 , size3);
    //line(thethingsX, -bHeight+90,thethingsX+20, -bHeight+90,)
    pop();
}


function makeThethings(birthLocationX) {
    var tt = {x: birthLocationX,
                breadth: .8,
                speed: -1,
                nFloors: round(random(10,12)),
                move: thethingsMove,
                display: thethingsDisplay}
    return tt;
}



function makeSpeaker (){

// the ellipses 
       /* strokeWeight(0.5);
        stroke(160,240,19);
        noFill();
        ellipse(width/2, height-50,250,40);
        ellipse(width/2, height-50,270,47);
        ellipse(width/2, height-50,290,55);
        ellipse(width/2, height-50,310,62);
        ellipse(width/2, height-50,330,68);
        ellipse(width/2, height-50,350,73);
        ellipse(width/2, height-50,370,77);
*/


    
    noStroke();
    fill(244,93,255);   // pink pill shape 
    rectMode(CENTER); 
    rect(width/2,height-80,235,60,30);
    fill(80,93,255);    // blue 
    rect(width/2,height-80, 40, 60 ); // blue middle part 
    noFill();
    strokeWeight(6);
    stroke(244,93,255);   // pink 'b'
    ellipse(width/2,height-75,15,15);
    line(232,height-95,232,height-75);
    stroke(80,93,255);  // the O s 
    ellipse(150,height-80,25,25);
    ellipse(190,height-80,25,25);
    ellipse(285,height-80,25,25);
    ellipse(325,height-80,25,25);
    strokeWeight(5);
    line(160,220,180,220);  // -
    line(290,220,310,220); //+
    line(300,210,300,230);  //+
    
}

This project was very fun but also challenging for me since the concept was open-ended.  The terrain reminded me of the waves of sound so I decided to create a ‘landscape of sound’. The result did not come out like my initial idea, but I enjoyed the process of choosing vibrant colors. I didn’t delete some of the codes I previously wrote so that I (or anyone) can try different variations of the landscape in the future.

These are some of the different styles I tried.

 

My initial sketch in Adobe Illustrator.

Eliza Pratt – Project 10

sketch

/*
Eliza Pratt
Section E
elpratt@andrew.cmu.edu
Project 10
*/


//array to store craters
var crater = [];
//starting x position of rocket
var rocketX = 540;
//starting y position of rocket
var rocketY = 100;
//starting rocket speed
var rs = 8;
//rocket is not on screen
showRocket = false;
//faulty rocket
var faulty = false;

//creates initial craters with no overlap
function setCrater() {
    //craters that do not overlap are infrequent, so loop
    //runs many times to ensure more craters are drawn
    for (var j = 0; j < 100; j++) {  

        //create a random position
        var pos = {x: random(width), y: random(height * 0.55, height)};
        //assume there is no overlap
        var overlap = false;

        //check new position against all old positions
        //if distance between old and new position is greater than the 
        //maximum size of the crater, assume overlap
        for (var i = 0; i < crater.length; i++) {
            var old = crater[i];
            var d = dist(pos.x, pos.y, old.x, old.y)
            if (d < 180) overlap = true;
        }

        //push position into array if there is no overlap
        if (!overlap) {
            crater.push(pos);
        }
        //make a crater for each position in the array
        for (var w = 0; w < crater.length; w++) {
            crater[w] = makeCrater(crater[w].x, crater[w].y);
        }
    }   
}

function setup() {
    createCanvas(480, 400);
    frameRate(20);

    //create stars with random positions and size
    for (var i = 0; i < STARPOINTS; i++) {
        pX.push(random(0, width));
        pY.push(random(0, height / 2));
        pS.push(random(0.2, 2))
    }

    setCrater();
}


function draw() {
    background(0);
    drawStars();
    //if rocket is prompted, 
    //draw it and move it across screen
    if (showRocket == true) {
        makeRocket(rocketX);
        rocketX -= rs;
    }

    //resets rocket position once it has travelled across screen
    if (rocketX <= -60) {
        showRocket = false;
        faulty = false;
        rocketX = 540;
        rocketY = random(0, height * 0.45);
        rs = random(5, 20);

    }

    //draw terrain
    drawMoon();
    //move craters
    updateCrater();
    removeCrater();
    //add craters and rockets
    addStuff();
}

/////////////ROCKET////////////////
function drawRocket() {
    //flame position
    var fireX = this.x + 25;
    //size of flame
    var fire = 15;

    noStroke();

    //flame
    fill("orange");
    ellipse (fireX, this.y, fire, fire);
    triangle(fireX + 2, this.y + fire / 2, fireX + 2, this.y - fire / 2, 
              fireX + 20, this.y);

    //fins
    fill("red");
    arc(this.x + 10, this.y, 60, 60, HALF_PI, 3 * HALF_PI, CHORD);
    rect(this.x - 10, this.y - 10, 30, 20);

    //body
    fill("blue");
    arc(this.x, this.y, 120, 30, PI / 4, PI * 1.58, CHORD);

    //window
    fill("lightblue");
    strokeWeight(4);
    stroke("darkblue");
    ellipse(this.x - 30, this.y, 15, 15);
}

function makeRocket(rx) {
    //give some rockets a concerningly faulty motion
    if (faulty == true) rocketY += random(-5, 5);

    //create object
     var rocket = {x: rx, y: rocketY, display: drawRocket, speed: rs};
     rocket.display();
}

///////////////STARS////////////////

//number of stars
var STARPOINTS = 300;

//arrays for position and stroke
var pX = [];
var pY = [];
var pS = [];

function drawStars() {
    //draw 300 stars
    for (var i = 0; i < STARPOINTS; i++) {
        // make 'em TWINKLE
        stroke(random(100, 255));
        strokeWeight(pS[i]);
        point(pX[i], pY[i], 10, 10);
    }
}

////////////MOON//////////////////////
function drawMoon() {

    //blue stroke for faint glow
    var w = 5;
    strokeWeight(w);
    stroke("darkblue");

    //draw moon terrain and have it move across screen
    fill(233, 238, 240);
    beginShape();
    for (var x = 0; x < width + w; x++) {
        var t = x * 0.005 + millis() * 0.0001;
        var y = map(noise(t), 0,1, height/3, height * 0.55);
        while (y >= height * 0.6) y = map(noise(t), 0,1, height/3, height * 0.55);
        vertex(x, y)
    }
    vertex(width + w, height + w);
    vertex(-w, height + w);
    endShape();
}

//////////CRATERS///////////////////////////

//draw craters and move them across screen
function updateCrater() {
    for (var i = 0; i < crater.length; i++) {
        crater[i].move();
        crater[i].display();
    }
}

//keep craters that are still on screen and 
//remove the rest from the array
function removeCrater() {
    var keepCrater = [];
    for (var i = 0; i < crater.length; i++) {
        if (crater[i].x + crater[i].w > 0) {
            keepCrater.push(crater[i]);
        }
    }
    crater = keepCrater;
}

//periodically adds elements to screen
function addStuff() {

    //creates new craters and adds them to array
    //every 100 frame counts to prevent overlap
    if (frameCount % 100 == 0) {
        crater.push(makeCrater(width + 90, random(height / 2, height)));
    }

    //infrequently creates a rocket if there is not already one on screen
    var spotRocket = 0.1;
    var faultyRocket = 0.3;
    if (spotRocket > random(0, 1) & showRocket == false) {
        showRocket = true;
        //occasionally creates a faulty rocket
        if (faultyRocket > random(0, 1)) faulty = true;
    }

}

//move craters across screen
function moveCrater() {
    this.x += this.speed;
}

//draws craters
function drawCrater() {
    noStroke();
    //shadow
    fill(this.color - 30);
    ellipse(this.x, this.y - 10, this.w, this.h);
    //crater
    fill(this.color);
    ellipse(this.x, this.y, this.w, this.h);
    stroke(240);
    noFill();

    //outline
    strokeWeight(this.stroke);
    ellipse(this.x, this.y - 5, this.w - 3, this.h + 8);

}

function makeCrater(cx, cy) {
    //maps width, color and stroke so craters appear
    //smaller when they are "farther" away
    var breadth = map(cy, height / 2, height, 55, 180);
    var col = map(cy, height / 2, height, 220, 80);
    var s = map(cy, height / 2, height, 7, 10);

    var crater = {x: cx, y: cy, w: breadth, h: breadth / 4,
                  color: col,  
                  speed: -2.2, 
                  stroke: s,
                  move: moveCrater, 
                  display: drawCrater};
    return crater;

}




This was the most I’ve ever been confused on a project! So many functions! I feel like this is the first time I actually started to understand how functions and objects relate to each other. I was also pleasantly surprised by how some of the elements turned out, like the perspective of the craters and the twinkliness of the stars. I originally wanted the whole thing to be rotating on the axis, but oh man it did not work.

Rachel Lee Project 10 Section E

sketch

/* Rachel Lee
Section E
rwlee@andrew.cmu.edu
Project 19: Generative Landscape
*/

var sailboats = [];

function setup() {
    createCanvas(480, 480);
    noStroke();
    background('blue');

    for(var i = 0; i < 3; i ++) {
    	var rndmX = random(width);
    	sailboats[i] = drawSailboats(rndmX);
    }
    
    frameRate(50);
}

function draw() {
    // Background color changes according to hour time bracket
    // Draw sun and moon according to hour time bracket
	if (hour() >= 0 & hour() <= 8) {
		fill(210, 195, 135);
		rect(0, 0, width, height);
		strokeWeight(15);
		fill(240, 100, 70);
		fill(225, 145, 90);
		ellipse(390, 90, 135);
	} else if (hour() > 8 & hour() <= 16) {
		fill(190, 230, 250);
		rect(0, 0, width, height);
		stroke(255, 231, 101, 80);
        strokeWeight(15);
		fill(230, 210, 120);
		ellipse(390, 90, 135);
	} else if (hour() > 16 & hour() <= 24) {
		fill(10, 50, 70);
		rect(0, 0, width, height);
		strokeWeight(15);
		fill(205, 205, 200);
		fill(225, 225, 210);
		ellipse(390, 90, 135);	
	}	

	// Calls function to draw waves
	waves1();
	waves2();

	updateandDisplaySailboats();
	addSailboats();
}

// Draws wave layer 1 via Perlin Noise
function waves1() {
	noStroke();
    var wavesSpeed = 0.0002;
    var wavesDetail = 0.0004;
    push();
    beginShape();
    fill(0, 100, 140);
    vertex(0, height);
    for (var x = 0; x < width; x++) {
        var w = (x * wavesDetail) + (millis() * wavesSpeed);
        var y = map(noise(w), 0, 1.2, height /2 + 70, height);
        vertex(x, y);
    }
    vertex(x, height);
    vertex(0, height);
    vertex(0, y); 
    endShape();
    pop();
}

// Draws wave layer 2 via Perlin Noise
function waves2() {
	noStroke();
	wavesSpeed = 0.0004;
    wavesDetail = 0.0008;
    push();
    beginShape();
    fill(80, 135, 155);
    vertex(0, height);
    for (var x = 0; x < width; x++) {
        var w = (x * wavesDetail) + (millis() * wavesSpeed);
        var y = map(noise(w), 0, 1, height / 1.5 + 50, height);
        vertex(x, y);
    }
    vertex(x, height);
    vertex(0, height);
    vertex(0, y); 
    endShape();
    pop();
} 

// Updates and displays the position of sailboats
function updateandDisplaySailboats() {
	for(var i = 0; i < sailboats.length; i++) {
		sailboats[i].move();
		sailboats[i].display();
	}
}

// Adds a new sailboat to the canvas according to a marginal probability
function addSailboats() {
    var sailboatProbability = 0.008;
    if (random(0, 1) < sailboatProbability) {
    	sailboats.push(drawSailboats(width));
    }
}

// Updates the position of the sailboat with every frame
function moveSailboats() {
	this.x += this.speed;
}

// Draws the sailboats
function displaySailboats() {
    noStroke();
	push();
	translate(0, 220);
	
	fill(190, 115, 75);
    rect(width / 2 + this.x - 5, height / 2 - 100, 5, 100);

	fill(230, 225, 225);
    quad(width / 2 + this.x - 60, height / 2 - 30, 
    	width / 2 + this.x + 50, height / 2 - 30, 
    	width / 2 + this.x + 30, height / 2,
    	width / 2 + this.x - 40, height / 2);

	fill(230, 85, 60);
	triangle(width / 2 + this.x, height / 2 - 60, 
		width / 2 + this.x, height / 2 - 150, 
		width / 2 + this.x - 60, height / 2 - 40);
	
	fill(225, 120, 110);
    triangle(width / 2 + this.x, height / 2 - 60, 
		width / 2 + this.x, height / 2 - 150, 
		width / 2 + this.x + 40, height / 2 - 60);
	pop(); 
} 

function drawSailboats(birthLocationX, birthLocationY) {
	var boat = {x: birthLocationX,
	    speed: -1,
	    r: random(0.1, 0.3),
	    move: moveSailboats,
	    display: displaySailboats,
	    }
	return boat;
}

For this week’s assignment, I decided to depict some boats sailing across the water. When I was a kid, I would sit by the pier and watch junk boats and ferries glide across the harbour, so this scene really resonated with me. This project was a little challenging for me, but I challenged myself to experiment with Perlin noise, and create a landscape that changes over time (beyond the immediate shifting waves and number of boats). If I had more time, I would try to space the boats out a bit more, so that they don’t overlap, and also add clouds.

Original sketch

 

Alexandra Kaplan – Project 10 – Generative Landscape

sketch

/*
Alexandra Kaplan
Section C
aekaplan@andrew.cmu.edu
Project - 10
*/

var planets = [];
var stars = [];
var ex = 500;
var ey = 500;

function setup() {
    createCanvas(480, 480); 
    
    // create an initial collection of planets
    for (var i = 0; i < 10; i++){
        var rx = random(width);
        if (planets.length < 5){
            planets[i] = makePlanet(rx);
        }
    }
    for(var j = 0; j < 200; j++){
        var sx = random(width);
        stars[j] = makeStar(sx);
    }
    frameRate(20);
}

function draw() {
    background(10,30,120);

    updateAndDisplayStars();
    removestars();
    addNewstars();

    updateAndDisplayplanets();
    removeplanets();
    addNewplanets();
    
    drawShootingStar();
    var newShootingStarLikelihood = 0.01; 
    if (random(0, 1) < newShootingStarLikelihood){
    	if(ex > width || ey > height){
    	   createshootingStar();
    	}
    }	
}
function drawShootingStar(){
	fill('khaki');
	strokeWeight(0);
	var dx = 5;
	var dy = 10;
	ellipse(ex + dx, ey + dy, 10);
	ex += dx;
	ey += dy;
}

function createshootingStar(){
	ex = random(0, width);
	ey = 0;
 }

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

function removeplanets(){
    // If a Planet has dropped off the left edge,
    // remove it from the array
    var planetsToKeep = [];
    for (var i = 0; i < planets.length; i++){
        if (planets[i].x + 50 + planets[i].breadth > 0){
            planetsToKeep.push(planets[i]);
        }
    }
    planets = planetsToKeep; // remember the surviving planets
}

function addNewplanets() {
    // With a very tiny probability, add a new Planet to the end.
    var newPlanetLikelihood = 0.6; 
    if (random(0, 1) < newPlanetLikelihood){
        if (planets.length < 5){
            planets.push(makePlanet(width + 40));
        }
    }
}

// method to update position of Planet every frame
function PlanetMove() {
    this.x += this.speed;
}
   
// draw the Planet
function PlanetDisplay() {
    var pwidth = this.wid;
    fill(this.col); 
    strokeWeight(0); 
    ellipse(this.x, this.y, pwidth);
    stroke(this.strkCol);
    strokeWeight(this.strk);
    line(this.x - (this.wid / this.srtklength) , this.y, this.x + (this.wid / this.srtklength), this.y); 
}


function makePlanet(birthLocationX) {
    var plnt = {x: birthLocationX,
    	        y: random(0, height),
                breadth: 10,
                speed: random(-5,-1),
                wid: random(20, 75),
                move: PlanetMove,
                display: PlanetDisplay,
                col:color(random(50, 100), random(50, 150), random(100, 255)),
                strk: random(0, 5),
                strkCol: color(random(50, 100), random(50, 150), random(100, 255)),
                srtklength: random(1,2),
                }
    return plnt;
}

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

function removestars(){
    // If a star has dropped off the left edge,
    // remove it from the array
    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 addNewstars() {
    // With a very tiny probability, add a new star to the end.
    var newStarsLikelihood = 0.5; 
    if (random(0,1) < newStarsLikelihood) {
        stars.push(makeStar(width + 40));
    }
}

// method to update position of stars every frame
function StarMove() {
    this.x += this.speed;
}
   
// draw the star
function StarsDisplay() {
    var swidth = this.wid;
    fill(this.col); 
    strokeWeight(0); 
    ellipse(this.x, this.y, swidth);  
}


function makeStar(birthLocationX) {
    var st = {x: birthLocationX,
    	        y: random(0, height),
                breadth: 10,
                speed: -.5,
                wid: random(1, 5),
                move: StarMove,
                display: StarsDisplay,
                col:color('palegoldenrod'),
            }
    return st;
}

When thinking about a generative landscape, my mind went straight to space, with planets and stars passing by.

                                                    Image of the original sketch

I started off by referring to the bulding base code and changing it to planets of various sizes. I then added strokes of different random weights and lengths to be the planet’s rings. The stars behind the planets were made in a similar way, but with more of them. I then added some shooting stars for fun. I think it turned out pretty well.