Austin Garcia – Project 03 – Section C

I tried many different ways to create mountains and alter them somehow with the mouse. I first attempted to create a gradient on the shapes to give a sense of the sun shining on them from different angles. Eventually, I had to settle for drawing lines along the yellow mountains to give the sense of fog crawling across them. Click the canvas then drag your mouse along it.

sketch

/*		Austin Garcia
		Section C
		aegarcia@andrew.cmu.edu
		Project - 03
*/
var x1 = 0;
var y1 = 100;
var x2 = 80;
var y2 = 100;
var x3 = 40;
var y3;
var mountain1 = 5;
var c1;
var c2;
var diffx = 0;
var diffy = 0;
var targetX = 300;
var targetY = 300;
var x = 300;
var y = 300;
var r

function setup() {
    createCanvas(400, 100);
    background(220);
    y3 = random(40, 90);
    c1 = ("yellow");



  //  triangle (x1, y1, x2, y2, x3, y3)

}

function draw() {


    r = random(80);


    fill(c1);

    strokeWeight(4);
    stroke(225);
    diffx = mouseX / 2 - x;
    diffy = mouseY / 2 - y;
    x = x + 0.1 * diffx;
    y = y + 0.1 * diffy;
    line(x1, y1, x, y);
    line(x2, y2, x, y);



}
    function mousePressed() {

      push();
      translate(mountain1, 0);
      strokeWeight(1)
      triangle (x1, y1, x2, y2, x3, y3);
      pop();


    mountain1 = mountain1 + r;
    y3 = r;

    if (mountain1 > 400) {
      strokeWeight(0);
    }
}

Author: Austin Garcia

5th year Architecture Student

Leave a Reply