Sewon Park – PO – 11

sketch

//Sewon Park
//sewonp@andrew.cmu.edu
//Section B
//Project 11

var skyspeed = 0.001;
var skyamp = 0.001; //calm fluctuations like the skyline
var grassspeed = 0.001;
var grassamp = 5; //to make fluctuations grasslike

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

function draw() {
    background(255); //white background to represent cloud filled sky
    sky(); //draws sky
    grass(); //draws grass
    totoro(); //draws totoro
    
}


function sky(){
  fill(102, 225, 225); 
  beginShape(); 
  for (var x = 0; x < width; x++) {
    var position = x*skyamp + (millis()*skyspeed);
    var y = map(noise(position), 0, 10, height/5, height);
    vertex(x, y); 
  }
  vertex(width, height);
  vertex(0, height);
  endShape();
}

function grass(){
  fill(0, 255, 0); 
    noStroke();
    beginShape(); 
      for (var x = 0; x < width; x++) {
            var position2 = x*grassamp + (millis()*grassspeed);
            var y = map(noise(position2), 0, 3, height/1.4, height); //height adjustment to make totoro 'walk' on grass
            vertex(x, y); 
      }
      vertex(width, height);
      vertex(0, height);
    endShape();
}



function totoro(){ 
  
  translate(200,300) //translate Totoro as it was made seperately in web editor

  fill(30,144,255);
  ellipse(50,50,40,50); //body
  
  fill(135,206,250);
  ellipse(50,57,15,20); //arm
  
  fill(0);
  triangle(48,67,50,69,52,67); //claw
  
  fill(135,206,250);
  triangle(60,28,55,15,50,25); //ear
  
  fill(255,203,138);
  triangle(58,28,55,21,52,25); //inner ear
  
  fill(255);
  ellipse(60,38,7,7); //eye
  
  fill(0);
  ellipse(60,38,3,3); //pupil
  ellipse(69,42,3,3); //nose
 
}


For the landscape project, I chose my recurring character Totoro to walk across the grass with a beautiful skyline.

Leave a Reply