Lingfan Jiang – Project 11 – Composition

click to draw

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

var nPoints = 10;
var x = [];
var y = [];


function setup(){
    createCanvas(480, 480);
    background(0);
    //generate random points around mouse
    for (var i = 0; i < nPoints; i++) {
        x.push(random(mouseX - 50, mouseX + 50));
        y.push(random(mouseY - 50, mouseY + 50));

    };

}

function draw(){
    strokeJoin(MITER);
    strokeCap(PROJECT);

    //generate new random points around mouse
    if (mouseIsPressed) {
        for (var i = 0; i < nPoints; i++) {
            x.push(random(mouseX - 20, mouseX + 20));
            y.push(random(mouseY - 20, mouseY + 20));
        }; 
        //get rid of the old ones in the array
        x.splice(0, nPoints);
        y.splice(0, nPoints);

        for (var i = 0; i < nPoints; i++) {
            var ttl = makeTurtle(x[i], y[i]);
            //create the sine curve in the middle
            var targetY = 240 + 90 * sin(radians(mouseX))
                ttl.setWeight(4);
                ttl.setColor(color(random(255),random(255),random(255)), 50);
                ttl.penDown();
                //connect the points towards the center sin curve
                ttl.goto(mouseX,targetY);
                ttl.penUp();
        };
    };
}



function turtleLeft(d) {
    this.angle -= d;
}
 
 
function turtleRight(d) {
    this.angle += d;
}
 
 
function turtleForward(p) {
    var rad = radians(this.angle);
    var newx = this.x + cos(rad) * p;
    var newy = this.y + sin(rad) * p;
    this.goto(newx, newy);
}
 
 
function turtleBack(p) {
    this.forward(-p);
}
 
 
function turtlePenDown() {
    this.penIsDown = true;
}
 
 
function turtlePenUp() {
    this.penIsDown = false;
}
 
 
function turtleGoTo(x, y) {
    if (this.penIsDown) {
      stroke(this.color);
      strokeWeight(this.weight);
      line(this.x, this.y, x, y);
    }
    this.x = x;
    this.y = y;
}
 
 
function turtleDistTo(x, y) {
    return sqrt(sq(this.x - x) + sq(this.y - y));
}
 
 
function turtleAngleTo(x, y) {
    var absAngle = degrees(atan2(y - this.y, x - this.x));
    var angle = ((absAngle - this.angle) + 360) % 360.0;
    return angle;
}
 
 
function turtleTurnToward(x, y, d) {
    var angle = this.angleTo(x, y);
    if (angle < 180) {
        this.angle += d;
    } else {
        this.angle -= d;
    }
}
 
 
function turtleSetColor(c) {
    this.color = c;
}
 
 
function turtleSetWeight(w) {
    this.weight = w;
}
 
 
function turtleFace(angle) {
    this.angle = angle;
}
 
 
function makeTurtle(tx, ty) {
    var turtle = {x: tx, y: ty,
                  angle: 0.0, 
                  penIsDown: true,
                  color: color(128),
                  weight: 1,
                  left: turtleLeft, right: turtleRight,
                  forward: turtleForward, back: turtleBack,
                  penDown: turtlePenDown, penUp: turtlePenUp,
                  goto: turtleGoTo, angleto: turtleAngleTo,
                  turnToward: turtleTurnToward,
                  distanceTo: turtleDistTo, angleTo: turtleAngleTo,
                  setColor: turtleSetColor, setWeight: turtleSetWeight,
                  face: turtleFace};
    return turtle;
}

For this project, I am interested in creating a brush myself. Therefore, I generated random points at the position of the mouse and then connected them with the center sin curve. It could look like a curtain sometime.

Alice Fang – Project 11

sketch

/*
Alice Fang
Section E
acfang@andrew.cmu.edu
Project-11-Turtle Graphics
*/

var ttl;
var r;  
var g; 
var b; 

var state = 0;

function setup() {
    createCanvas(400, 400);
   	background(180, 40, 80);
    ttl = makeTurtle(width / 2, height / 2);
}

function mousePressed() {
	if (state === 0) { // make line strokes based on mouse location
		r = random(0, 256); // randomized colors
		g = random(0, 256);
		b = random(0, 256);

		ttl.goto(mouseX, mouseY);
		ttl.setWeight(random(1, 10)); // randomized stroke weight, length, angle
		ttl.setColor(color(r, g, b));
		ttl.penDown();
		ttl.forward(random(10, 100));
		ttl.right(random(30, 355));

	} else if (state === 1) { // make swirlies
		ttl.penUp();
		ttl.goto(mouseX, mouseY);
		ttl.setWeight(random(1, 4));
		ttl.penDown();
		swirly();
		ttl.penUp(); 
	}
}

function swirly() { // function to create swirly
	for (var i = 0; i < 30; i++) {
		ttl.setColor(color(240, 240, 80));
		ttl.forward((30 - i) / random(2, 4));
		ttl.right(random(20, 40));
	}
}

function keyPressed() { // press ENTER key to change between. lines and swirlies
	if (keyCode === ENTER) {
		state = state + 1;
	} 
	if (state > 1) {
		state = 0;
	}
}

function turtleLeft(d){this.angle-=d;}function turtleRight(d){this.angle+=d;}
function turtleForward(p){var rad=radians(this.angle);var newx=this.x+cos(rad)*p;
var newy=this.y+sin(rad)*p;this.goto(newx,newy);}function turtleBack(p){
this.forward(-p);}function turtlePenDown(){this.penIsDown=true;}
function turtlePenUp(){this.penIsDown = false;}function turtleGoTo(x,y){
if(this.penIsDown){stroke(this.color);strokeWeight(this.weight);
line(this.x,this.y,x,y);}this.x = x;this.y = y;}function turtleDistTo(x,y){
return sqrt(sq(this.x-x)+sq(this.y-y));}function turtleAngleTo(x,y){
var absAngle=degrees(atan2(y-this.y,x-this.x));
var angle=((absAngle-this.angle)+360)%360.0;return angle;}
function turtleTurnToward(x,y,d){var angle = this.angleTo(x,y);if(angle< 180){
this.angle+=d;}else{this.angle-=d;}}function turtleSetColor(c){this.color=c;}
function turtleSetWeight(w){this.weight=w;}function turtleFace(angle){
this.angle = angle;}function makeTurtle(tx,ty){var turtle={x:tx,y:ty,
angle:0.0,penIsDown:true,color:color(128),weight:1,left:turtleLeft,
right:turtleRight,forward:turtleForward, back:turtleBack,penDown:turtlePenDown,
penUp:turtlePenUp,goto:turtleGoTo, angleto:turtleAngleTo,
turnToward:turtleTurnToward,distanceTo:turtleDistTo, angleTo:turtleAngleTo,
setColor:turtleSetColor, setWeight:turtleSetWeight,face:turtleFace};
return turtle;}

For this project, I wanted to create something simple and colorful. I was inspired by my current phone wallpaper, and I couldn’t choose between which version I liked better so I included both as potential interactions someone could have with the program.

My current phone wallpaper!

Click on the canvas to make marks, and press the ENTER key to switch between the lines and the jagged swirlies!

Sarah Yae – Project 11 – Section B

sketch

//Sarah Yae
//smyae@andrew.cmu.edu
//Section B
//Project 11

var baseface; 

//Load Base Face Image
function preload() {
    var basefaceload = "https://i.imgur.com/FXyP6ss.gif";
    baseface = loadImage(basefaceload);
}

//Set up loaded Base Face 
function setup () {
    createCanvas(280,400);
    background(0);
    image(baseface, 0, 0);
    text("drag the mouse to make my brows thicker!", 10, 10);
}

function draw() {

    var distmousex = map(mouseX, 0, width, 0, 5);
    var distmousey = map(mouseY, 0, height, 0, 5);

//Right brow
    var browr = makeTurtle((width / 2) + 40 + distmousex, height/3 + distmousey);
    browr.setColor(color(210, 180, 140));
    browr.setWeight(4);
    browr.face(0);
    browr.forward(50);

//Left brow
    var browl = makeTurtle((width / 2) + distmousex, height/3 + distmousey);
    browl.setColor(color(210, 180, 140));
    browl.setWeight(4);
    browl.face(180);
    browl.forward(50); 

//Right Eye 
    var eyer = makeTurtle((width / 2) + 60, (height/3) + 15);
    eyer.setColor(50); 
    eyer.setWeight(1);

    for (var i = 0; i < 100; i++) {
        eyer.right(360/100);
        eyer.forward(0.7);
    }

//Left Eye 
    var eyel = makeTurtle((width / 2) - 20, (height/3) + 15);
    eyel.setColor(50); 
    eyel.setWeight(1);

    for (var i = 0; i < 100; i++) {
        eyel.right(360/100);
        eyel.forward(0.7);
    }

//Mouth
    stroke("Salmon");
    strokeWeight(6);
    arc((width / 2) + 20, (height/2) + 15, 80, 40, 0, PI);

//Right Iris 
    var irisr = makeTurtle((width / 2) + 60, (height/3) + 23);
    irisr.setColor(color(30, 17, 0));
    irisr.setWeight(7);

    for (var i = 0; i < 100; i++) {
        irisr.right(360/100);
        irisr.forward(0.2); 
    }

//Left Iris 
    var irisl = makeTurtle((width / 2) - 20, (height/3) + 23);
    irisl.setColor(color(30, 17, 0));
    irisl.setWeight(7);

    for (var i = 0; i < 100; i++) {
        irisl.right(360/100);
        irisl.forward(0.2);
    }   

}

//Turtle Graphics 
function turtleLeft(d) {
    this.angle -= d;
}
 
 
function turtleRight(d) {
    this.angle += d;
}
 
 
function turtleForward(p) {
    var rad = radians(this.angle);
    var newx = this.x + cos(rad) * p;
    var newy = this.y + sin(rad) * p;
    this.goto(newx, newy);
}
 
 
function turtleBack(p) {
    this.forward(-p);
}
 
 
function turtlePenDown() {
    this.penIsDown = true;
}
 
 
function turtlePenUp() {
    this.penIsDown = false;
}
 
 
function turtleGoTo(x, y) {
    if (this.penIsDown) {
      stroke(this.color);
      strokeWeight(this.weight);
      line(this.x, this.y, x, y);
    }
    this.x = x;
    this.y = y;
}
 
 
function turtleDistTo(x, y) {
    return sqrt(sq(this.x - x) + sq(this.y - y));
}
 
 
function turtleAngleTo(x, y) {
    var absAngle = degrees(atan2(y - this.y, x - this.x));
    var angle = ((absAngle - this.angle) + 360) % 360.0;
    return angle;
}
 
 
function turtleTurnToward(x, y, d) {
    var angle = this.angleTo(x, y);
    if (angle < 180) {
        this.angle += d;
    } else {
        this.angle -= d;
    }
}
 
 
function turtleSetColor(c) {
    this.color = c;
}
 
 
function turtleSetWeight(w) {
    this.weight = w;
}
 
 
function turtleFace(angle) {
    this.angle = angle;
}
 
 
function makeTurtle(tx, ty) {
    var turtle = {x: tx, y: ty,
                  angle: 0.0, 
                  penIsDown: true,
                  color: color(128),
                  weight: 1,
                  left: turtleLeft, right: turtleRight,
                  forward: turtleForward, back: turtleBack,
                  penDown: turtlePenDown, penUp: turtlePenUp,
                  goto: turtleGoTo, angleto: turtleAngleTo,
                  turnToward: turtleTurnToward,
                  distanceTo: turtleDistTo, angleTo: turtleAngleTo,
                  setColor: turtleSetColor, setWeight: turtleSetWeight,
                  face: turtleFace};
    return turtle;
}

I wanted to originally create a makeup simulation, but as I was working on the project, I found that to be difficult, as turtle graphics work more as a pen, rather than a painting function. I feel like my final product turned out to be way different than my first ideas.

First Sketches
Finished Product

Jisoo Geum – Project 11

sketch

// Jisoo Geum
// Section B
// jgeum@andrew.cmu.edu 
// Project 11
var tt1;
var startX; 
var startY;
var aa;
var ttlength;

function setup() {
    createCanvas(480, 400);
    background(173, 255, 244);
    tt1 = makeTurtle(startX,startY);
    tt1.setColor(color(255,144,0));
    tt1.setWeight(0.5);
    startX = width/2; // set the starting point to center of the canvas 
    startY = height/2;
    aa = random(20,340) // randomise angle
    ttlength = random(100,400); // randomize the length of the lines
    

  
}


function mousePressed() {

    for( var i=0; i <height/4; i +=2){
        tt1.penDown();
        tt1.forward(ttlength);
        tt1.right(aa);
        tt1.forward(ttlength);
        tt1.penUp();
        tt1.goto(startX,startY+i);
        
    }
}


function turtleLeft(d){this.angle-=d;}function turtleRight(d){this.angle+=d;}
function turtleForward(p){var rad=radians(this.angle);var newx=this.x+cos(rad)*p;
var newy=this.y+sin(rad)*p;this.goto(newx,newy);}function turtleBack(p){
this.forward(-p);}function turtlePenDown(){this.penIsDown=true;}
function turtlePenUp(){this.penIsDown = false;}function turtleGoTo(x,y){
if(this.penIsDown){stroke(this.color);strokeWeight(this.weight);
line(this.x,this.y,x,y);}this.x = x;this.y = y;}function turtleDistTo(x,y){
return sqrt(sq(this.x-x)+sq(this.y-y));}function turtleAngleTo(x,y){
var absAngle=degrees(atan2(y-this.y,x-this.x));
var angle=((absAngle-this.angle)+360)%360.0;return angle;}
function turtleTurnToward(x,y,d){var angle = this.angleTo(x,y);if(angle< 180){
this.angle+=d;}else{this.angle-=d;}}function turtleSetColor(c){this.color=c;}
function turtleSetWeight(w){this.weight=w;}function turtleFace(angle){
this.angle = angle;}function makeTurtle(tx,ty){var turtle={x:tx,y:ty,
angle:0.0,penIsDown:true,color:color(128),weight:1,left:turtleLeft,
right:turtleRight,forward:turtleForward, back:turtleBack,penDown:turtlePenDown,
penUp:turtlePenUp,goto:turtleGoTo, angleto:turtleAngleTo,
turnToward:turtleTurnToward,distanceTo:turtleDistTo, angleTo:turtleAngleTo,
setColor:turtleSetColor, setWeight:turtleSetWeight,face:turtleFace};
return turtle;}

For this project, I wanted to use randomized angles and line lengths to explore different compositions. I also wanted to see shapes created from the repetition and overlaps of thin lines.

Joanne Lee – Project 11

Project-11

// Joanne Lee
// Section C
// joannele@andrew.cmu.edu
// Project-11

// global variables
var maze;
var character = [];
var brightnessThreshold = 10; // low threshold bc working with black background

// color variables
var redR = 255;
var redG = 96;
var redB = 95;

var pinkR = 255;
var pinkG = 184;
var pinkB = 255;

var cyanR = 2;
var cyanG = 255;
var cyanB = 255;

var orangeR = 255;
var orangeG = 184;
var orangeB = 82;

// array with color r,g,b values
var randomCol = [redR, redG, redB, pinkR, pinkG, pinkB, cyanR, cyanG, cyanB, orangeR, orangeG, orangeB]

function preload() {
    maze = loadImage("https://i.imgur.com/hGU36Hn.png") // load maze image
}

function setup() {
    createCanvas(480, 323);
    image(maze, 0, 0, 480, 323);
    maze.loadPixels();

    for (var a = 0; a < 6; a ++) { // create 6 hexagonal character in the maze
        if (a < 3) { // positions for character startion left on maze
            character[a] = makeCharacter(112, 57 + (95 * a));
        }
        else if (a >= 3) { // positions for character starting right on maze
            character[a] = makeCharacter(360, 57 + (95 * (a % 3)));
        }
        setColor(a); // randomly set colors
        character[a].setWeight(6);
        character[a].penDown(); // begin drawing
        character[a].forward(6);
        // note that it doesn't stop drawing
    }
}

function setColor(a) { // pick a random color from red, pink, cyan, orange
    var randNum = random(0,4);
    var index = floor(randNum) * 3; // take floor to make sure they're whole #'s
    character[a].setColor(color(randomCol[index], randomCol[index + 1], randomCol[index + 2]));
}

function draw() {
    for (var x = 0; x < 6; x ++) {
        chrMove(x);
        chrReset(x);
    }
}

// getPixel: fast access to pixel at location x, y from image 
function getPixel(image, x, y) {
    var i = 4 * (y * image.width + x);
    return color(image.pixels[i], image.pixels[i + 1], image.pixels[i + 2]);
}

function chrMove(x) { // update the object's position
    var theColorAtPxPy = getPixel(maze, character[x].x, character[x].y); // get color of px, py position
        
    // Fetch the brightness at PxPy, and save it.
    var theBrightnessOfTheColorAtPxPy = brightness(color(theColorAtPxPy));

    // If the brightness at PxPy is greater than the brightness threshold, move it down.
    if (theBrightnessOfTheColorAtPxPy < brightnessThreshold) {
        character[x].forward(1);
    }

    // If the brightness at PxPy is lower than darkness threshold, move up until it isn't.
    while (theBrightnessOfTheColorAtPxPy > brightnessThreshold & this.py != 0) {
        character[x].back(2);
        if (random(0,1) < 0.5) {
            character[x].right(90);
        }
        else {
            character[x].left(90);
        }
        theColorAtPxPy = getPixel(maze, character[x].x, character[x].y);
        theBrightnessOfTheColorAtPxPy = brightness(color(theColorAtPxPy));
        }
}

function chrReset(x) { // reset the object to the top of the screen
    if (character[x].x > width) { // bring back to left of screen if it moves off the right
        character[x].x = 0;
    }
    else if (character[x].x < 0) { // bring back to right of screen if it moves off the left
        character[x].x = width;
        character[x].back(150);
        character.right(90);
    }
}

// turtle graphic commands

function turtleLeft(d) {
    this.angle -= d;
}


function turtleRight(d) {
    this.angle += d;
}


function turtleForward(p) {
    var rad = radians(this.angle);
    var newx = this.x + cos(rad) * p;
    var newy = this.y + sin(rad) * p;
    this.goto(newx, newy);
}


function turtleBack(p) {
    this.forward(-p);
}


function turtlePenDown() {
    this.penIsDown = true;
}


function turtlePenUp() {
    this.penIsDown = false;
}


function turtleGoTo(x, y) {
    if (this.penIsDown) {
      stroke(this.color);
      strokeWeight(this.weight);
      line(this.x, this.y, x, y);
    }
    this.x = x;
    this.y = y;
}


function turtleDistTo(x, y) {
    return sqrt(sq(this.x - x) + sq(this.y - y));
}


function turtleAngleTo(x, y) {
    var absAngle = degrees(atan2(y - this.y, x - this.x));
    var angle = ((absAngle - this.angle) + 360) % 360.0;
    return angle;
}

function turtleTurnToward(x, y, d) {
    var angle = this.angleTo(x, y);
    if (angle < 180) {
        this.angle += d;
    } else {
        this.angle -= d;
    }
}


function turtleSetColor(c) {
    this.color = c;
}


function turtleSetWeight(w) {
    this.weight = w;
}


function turtleFace(angle) {
    this.angle = angle;
}


function makeCharacter(tx, ty) {
    var turtle = {x: tx, y: ty,
                  angle: 0.0, 
                  penIsDown: true,
                  color: color(128),
                  weight: 1,
                  left: turtleLeft, right: turtleRight,
                  forward: turtleForward, back: turtleBack,
                  penDown: turtlePenDown, penUp: turtlePenUp,
                  goto: turtleGoTo, angleto: turtleAngleTo,
                  turnToward: turtleTurnToward,
                  distanceTo: turtleDistTo, angleTo: turtleAngleTo,
                  setColor: turtleSetColor, setWeight: turtleSetWeight,
                  face: turtleFace, move: chrMove, // update the character's position
                  reset: chrReset, // reset the character to maze entrance
                  }
    return turtle;
}

I created an endless self-navigating maze inspired by Pac-Man! The colors of the lines are randomly generated from the red, cyan, pink, orange colors of the ghosts from the games. I wish I had the ability and time to add more randomness in the maze’s twists and turns as well as more smooth line as opposed to hitting the wall then moving back a step. However, I am very happy with my final product as is. I’ve included pictures of different iterations below.

The start of one iteration. You can clearly see the different paths here since it is early on in its stages.
Another iteration in a more advanced stage of completion. Lines go back the same path it took sometimes due to the slight randomness in its turns.

Christine Seo – Project 11

sketch

// Christine Seo
// Section C
// mseo1@andrew.cmu.edu
// Project-11

var turtle1;
var turtle2;
var turtle3;
var turtle4;
var turtle5;
var turtle6;

function setup() {
  createCanvas(480, 460);
  background(0);
  turtle1 = makeTurtle(160, 200);
  turtle2 = makeTurtle(210, 100);
  turtle3 = makeTurtle(370, 210);
  turtle4 = makeTurtle(480, 20);
  turtle5 = makeTurtle(150, 470);
  turtle6 = makeTurtle(8, -15);
  frameRate(10); //gradually draw
}


function draw() {
  // Draw turtle 1
  turtle1.penDown();
  turtle1.setWeight(0.25);
  turtle1.setColor("Khaki"); 
  for (var i = 0; i < 10; i++) {
    turtle1.forward(1); //go straight
    turtle1.right(55); //go right 
    turtle1.forward(38);
    turtle1.left(15); //go left 
    if (i % 9 === 0) { //angles
      turtle1.forward(13);
    }
  }

  // Draw turtle 2
  turtle2.penDown();
  turtle2.setWeight(0.25);
  turtle2.setColor("LightPink");
  for (var i = 0; i < 10; i++) {
    turtle2.forward(15);
    turtle2.left(70);
    turtle2.forward(38);
    if (i % 9 === 0) {
      turtle2.forward(13);
    }
  }

  // Draw turtle 3
  turtle3.penDown();
  turtle3.setWeight(0.25);
  turtle3.setColor("DarkSeaGreen");
  for (var i = 0; i < 10; i++) {
    turtle3.forward(15);
    turtle3.right(40);
    turtle3.forward(120);
    turtle3.right(70);
    if (i % 9 === 0) {
      turtle3.forward(13);
    }
  }

  // Draw turtle 4
  turtle4.penDown();
  turtle4.setWeight(0.25);
  turtle4.setColor("Khaki"); 
  for (var i = 0; i < 10; i++) {
    turtle4.forward(1);
    turtle4.right(55);
    turtle4.forward(38);
    turtle4.left(15);
    if (i % 9 === 0) {
      turtle4.forward(13);
    }
  }

  // Draw turtle 5
  turtle5.penDown();
  turtle5.setWeight(0.25);
  turtle5.setColor("LightPink");
  for (var i = 0; i < 10; i++) {
    turtle5.forward(15);
    turtle5.left(70);
    turtle5.forward(38);
    if (i % 9 === 0) {
      turtle5.forward(13);
    }
  }



  // Draw turtle 6
  turtle6.penDown();
  turtle6.setWeight(0.25);
  turtle6.setColor("DarkSeaGreen");
  for (var i = 0; i < 10; i++) {
    turtle6.forward(15);
    turtle6.right(40);
    turtle6.forward(120);
    turtle6.right(70);
    if (i % 9 === 0) {
      turtle6.forward(13);
    }
  }
}


function turtleLeft(d){this.angle-=d;}function turtleRight(d){this.angle+=d;}
function turtleForward(p){var rad=radians(this.angle);var newx=this.x+cos(rad)*p;
var newy=this.y+sin(rad)*p;this.goto(newx,newy);}function turtleBack(p){
this.forward(-p);}function turtlePenDown(){this.penIsDown=true;}
function turtlePenUp(){this.penIsDown = false;}function turtleGoTo(x,y){
if(this.penIsDown){stroke(this.color);strokeWeight(this.weight);
line(this.x,this.y,x,y);}this.x = x;this.y = y;}function turtleDistTo(x,y){
return sqrt(sq(this.x-x)+sq(this.y-y));}function turtleAngleTo(x,y){
var absAngle=degrees(atan2(y-this.y,x-this.x));
var angle=((absAngle-this.angle)+360)%360.0;return angle;}
function turtleTurnToward(x,y,d){var angle = this.angleTo(x,y);if(angle< 180){
this.angle+=d;}else{this.angle-=d;}}function turtleSetColor(c){this.color=c;}
function turtleSetWeight(w){this.weight=w;}function turtleFace(angle){
this.angle = angle;}function makeTurtle(tx,ty){var turtle={x:tx,y:ty,
angle:0.0,penIsDown:true,color:color(128),weight:1,left:turtleLeft,
right:turtleRight,forward:turtleForward, back:turtleBack,penDown:turtlePenDown,
penUp:turtlePenUp,goto:turtleGoTo, angleto:turtleAngleTo,
turnToward:turtleTurnToward,distanceTo:turtleDistTo, angleTo:turtleAngleTo,
setColor:turtleSetColor, setWeight:turtleSetWeight,face:turtleFace};
return turtle;}

I really liked how in this weeks project, it was more open ended. I was able to research and find interesting visual forms that the turtles can make. Some of the designs reminded me of flowers in some way and I wanted to portray that through my composition as well as implement the slow crawling turtles to make the designs more opaque.

Close to stage one of composition
Close to stage two of composition (gradually draws more, and gets more opaque)
Close to final stage of composition (most opaque and vibrant)

 

Jonathan Liang – Project 11 – Composition

sketch

//Jonathan Liang
//jliang2
//Section A

//draw lines on people haha

var t1;
var underlyingImage;
var longboy = -1;

function preload() {
    var myImageURL = "https://i.imgur.com/UveUHg1l.jpg";
    underlyingImage = loadImage(myImageURL); //load picture
}



function setup() {
	background(255);
    createCanvas(350, 480);
    image(underlyingImage, 0, 0);
    underlyingImage.loadPixels();
    t1 = makeTurtle(width/2, height/2);
    frameRate(35);
   
   
}

function draw() {
	if (longboy == 1) {
		t1.goto(mouseX, mouseY);
		t1.penDown();
		followTheMouse();

	}	

	if (longboy == -1) {
		t1.penUp();
		// t1.goto(mouseX, mouseY);

	}

	
}

function followTheMouse() {
	
	t1.setColor('black');
	t1.setWeight(3);
	t1.forward(2);
	t1.turnToward(mouseX, mouseY, 10);
	
}

function mousePressed() {
	longboy *= -1;
}

function turtleLeft(d) {
    this.angle -= d;
}


function turtleRight(d) {
    this.angle += d;
}


function turtleForward(p) {
    var rad = radians(this.angle);
    var newx = this.x + cos(rad) * p;
    var newy = this.y + sin(rad) * p;
    this.goto(newx, newy);
}


function turtleBack(p) {
    this.forward(-p);
}


function turtlePenDown() {
    this.penIsDown = true;
}


function turtlePenUp() {
    this.penIsDown = false;
}


function turtleGoTo(x, y) {
    if (this.penIsDown) {
      stroke(this.color);
      strokeWeight(this.weight);
      line(this.x, this.y, x, y);
    }
    this.x = x;
    this.y = y;
}


function turtleDistTo(x, y) {
    return sqrt(sq(this.x - x) + sq(this.y - y));
}


function turtleAngleTo(x, y) {
    var absAngle = degrees(atan2(y - this.y, x - this.x));
    var angle = ((absAngle - this.angle) + 360) % 360.0;
    return angle;
}


function turtleTurnToward(x, y, d) {
    var angle = this.angleTo(x, y);
    if (angle < 180) {
        this.angle += d;
    } else {
        this.angle -= d;
    }
}


function turtleSetColor(c) {
    this.color = c;
}


function turtleSetWeight(w) {
    this.weight = w;
}


function turtleFace(angle) {
    this.angle = angle;
}


function makeTurtle(tx, ty) {
    var turtle = {x: tx, y: ty,
                  angle: 0.0, 
                  penIsDown: true,
                  color: color(128),
                  weight: 1,
                  left: turtleLeft, right: turtleRight,
                  forward: turtleForward, back: turtleBack,
                  penDown: turtlePenDown, penUp: turtlePenUp,
                  goto: turtleGoTo, angleto: turtleAngleTo,
                  turnToward: turtleTurnToward,
                  distanceTo: turtleDistTo, angleTo: turtleAngleTo,
                  setColor: turtleSetColor, setWeight: turtleSetWeight,
                  face: turtleFace};
    return turtle;
}

It all starts with an idea, but you can never tell where an idea can end up. Because ideas spread, they change, they grow, they connect us with the world. And in a fast-moving world, where good news moves at the speed of time and bad news isn’t always what is seems. Because when push comes to shove, we all deserve a second chance, to score. A simple picture of an ordinary boy can be transformed. Ordinary boy can become the incredible hulk, thanks to turtles.

Connor McGaffin – Project 11

sketch

/*
Connor McGaffin
Section C
cmcgaffi@andrew.cmu.edu
Project-11
*/

var option = 1;
var b = 2;
var gold = 137.507764;

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

function draw() {
    background(0); 

    //each option provides diff colors and 
    if(option == 1){
        greenHex();
    }
    if(option == 2){
        yellowTri();
    }
    if(option == 3){
        orangSq
    ();
    }
}

function greenHex () {
    var swim = mouseX / 10;
    var turtle = makeTurtle(width / 2, height / 2);
    turtle.setWeight(3);

    for(i = 0; i < 300; i++){
        if( i % 3 == 1){
            turtle.setColor("darkgreen");
        } else {
            turtle.setColor("pink");
            var swim = mouseX / 5;
        }
            turtle.penDown();
            turtle.forward(swim);
            turtle.right(60);
            turtle.forward(swim);
            turtle.right(60);
            turtle.forward(swim);
            turtle.right(60);
            turtle.forward(swim);
            turtle.right(60);
            turtle.forward(swim);
            turtle.right(60);
            turtle.forward(swim);
            turtle.right(60);
            turtle.penUp();
            turtle.right(gold);
            turtle.forward(i * 1.5);
        }
}

function yellowTri () {
    var swim = mouseX * 3;
    var turtle = makeTurtle(width / 2, height / 2);
    turtle.setWeight(3);

    for(i = 0; i < 500; i++){
        if( i % 3 == 1){
            turtle.setColor("gold");
        } else {
            turtle.setColor("indigo");
            var swim = mouseX / 5;
        }
            turtle.penDown();
            turtle.forward(swim);
            turtle.right(120);
            turtle.forward(swim);
            turtle.right(120);
            turtle.forward(swim);
            turtle.penUp();
            turtle.right(gold);
            turtle.forward(i * 1.5);
        }
}

function orangSq () {
    var swim = mouseX * 3;
    var turtle = makeTurtle(width / 2, height / 2);
    turtle.setWeight(3);

    for(i = 0; i < 500; i++){
        if( i % 3 == 1){
            turtle.setColor("navy");
        } else {
            turtle.setColor("chocolate");
            var swim = mouseX / 5;
        }
            turtle.penDown();
            turtle.forward(swim);
            turtle.right(90);
            turtle.forward(swim);
            turtle.right(90);
            turtle.forward(swim);
            turtle.right(90);
            turtle.forward(swim);
            turtle.penUp();
            turtle.right(gold);
            turtle.forward(i * 1.5);
        }
}

function mousePressed() {
    option++;
    if(option > 3) option = 1;
}


function turtleLeft(d){this.angle-=d;}function turtleRight(d){this.angle+=d;}
function turtleForward(p){var rad=radians(this.angle);var newx=this.x+cos(rad)*p;
var newy=this.y+sin(rad)*p;this.goto(newx,newy);}function turtleBack(p){
this.forward(-p);}function turtlePenDown(){this.penIsDown=true;}
function turtlePenUp(){this.penIsDown = false;}function turtleGoTo(x,y){
if(this.penIsDown){stroke(this.color);strokeWeight(this.weight);
line(this.x,this.y,x,y);}this.x = x;this.y = y;}function turtleDistTo(x,y){
return sqrt(sq(this.x-x)+sq(this.y-y));}function turtleAngleTo(x,y){
var absAngle=degrees(atan2(y-this.y,x-this.x));
var angle=((absAngle-this.angle)+360)%360.0;return angle;}
function turtleTurnToward(x,y,d){var angle = this.angleTo(x,y);if(angle< 180){
this.angle+=d;}else{this.angle-=d;}}function turtleSetColor(c){this.color=c;}
function turtleSetWeight(w){this.weight=w;}function turtleFace(angle){
this.angle = angle;}function makeTurtle(tx,ty){var turtle={x:tx,y:ty,
angle:0.0,penIsDown:true,color:color(128),weight:1,left:turtleLeft,
right:turtleRight,forward:turtleForward, back:turtleBack,penDown:turtlePenDown,
penUp:turtlePenUp,goto:turtleGoTo, angleto:turtleAngleTo,
turnToward:turtleTurnToward,distanceTo:turtleDistTo, angleTo:turtleAngleTo,
setColor:turtleSetColor, setWeight:turtleSetWeight,face:turtleFace};
return turtle;}



 

I approached this project as an exploration in color, shape, and the golden ratio. I created three separate interactions, which can be shuffled through via clicking on the canvas. Each of these options is an exploration in a different color palette and use of shape, each with a similar underlying turtle for loop.

In my explorations, I found a few structures that resemble organic shapes of nature. In the first interaction, Ive found a faint outline of a succulent like growth present in the green strokes when the cursor is all the way to the right. The second interaction generates a negative space at its center which resembles a seashell. Finally, the third interaction yielded a similar succulent-like growth to the first, except it is constrained by right angles on the leftmost sides, dictated so by the 90 degree angles of the squares which make up the structure.

All screenshots below were taken when the cursor was on the far right of the canvas, generating the shapes with line segments at its upper bound.

Jamie Dorst Project 11

sketch

/*
Jamie Dorst
jdorst@andrew.cmu.edu
Section A
Project-11
*/

var turtlesArray = [];
var mouseClicks = [];

function setup() {
    createCanvas(460, 480);
    background(0);
}

function draw() {
    // change frame rate slower
    frameRate(5);
    // make turtle in center of screen
    var turtle1 = makeTurtle(width / 2, height / 2);
    turtle1.setColor(255);
    turtle1.goto(random(0, 460), random(0, 460));
    // make another same turtle in center of screen
    var turtle2 = makeTurtle(width / 2, height / 2);
    turtle2.setColor(255);
    turtle2.goto(random(0, 460), random(0, 460));
    // make another same turtle in center of screen
    var turtle3 = makeTurtle(width / 2, height / 2);
    turtle3.setColor(255);
    turtle3.goto(random(0, 460), random(0, 460));
    // draw new turtles on a loop too
    for (var i = 0; i < turtlesArray.length; i++) {
        turtlesArray[i].goto(random(0, 460), random(0, 460));
    }
    // stop updating turtles past 10 clicks by removing them from the array
    if (turtlesArray.length > 10) {
        turtlesArray.shift();
    }
    // put translucent black screen over canvas every 10 clicks
    // not when there have been 0 clicks
    if (mouseClicks.length === 0 & mouseClicks.length < 10) {
        textAlign(CENTER);
        noStroke();
        fill(0);
        rect(0, 460, 460, 480);
        fill(255);
        text("keep clicking to start fading", width / 2, 470);
    } else if (mouseClicks.length % 10 === 0) {
        // translucent box over canvas
        fill(0, 0, 0, 30);
        noStroke();
        rect(0, 0, 460, 460);
        // instructions text
        noStroke();
        fill(0);
        rect(0, 460, 460, 480);
        fill(255);
        text("click to stop fading", width / 2, 470);
    } else if (mouseClicks.length === 11) {
        // clear array so it never exceeds 10 items
        for (var j = 0; j < 11; j++) {
            mouseClicks.shift();
        }
    }
    print(mouseClicks.length)
}

function mousePressed() {
    // new turtle when mouse is pressed at location mouse was pressed
    var newTurtle = makeTurtle(mouseX, mouseY);
    // color and weight are random
    newTurtle.setColor(color(random(255), random(255), random(255)));
    newTurtle.setWeight(random(1, 5));
    // push the new turtle onto the turtles array
    turtlesArray.push(newTurtle);
    // count how many clicks there have been total
    mouseClicks.push("click")
}


//-----------TURTLE-----------//
function turtleLeft(d) {
    this.angle -= d;
}


function turtleRight(d) {
    this.angle += d;
}


function turtleForward(p) {
    var rad = radians(this.angle);
    var newx = this.x + cos(rad) * p;
    var newy = this.y + sin(rad) * p;
    this.goto(newx, newy);
}


function turtleBack(p) {
    this.forward(-p);
}


function turtlePenDown() {
    this.penIsDown = true;
}


function turtlePenUp() {
    this.penIsDown = false;
}


function turtleGoTo(x, y) {
    if (this.penIsDown) {
      stroke(this.color);
      strokeWeight(this.weight);
      line(this.x, this.y, x, y);
    }
    this.x = x;
    this.y = y;
}


function turtleDistTo(x, y) {
    return sqrt(sq(this.x - x) + sq(this.y - y));
}


function turtleAngleTo(x, y) {
    var absAngle = degrees(atan2(y - this.y, x - this.x));
    var angle = ((absAngle - this.angle) + 360) % 360.0;
    return angle;
}


function turtleTurnToward(x, y, d) {
    var angle = this.angleTo(x, y);
    if (angle < 180) {
        this.angle += d;
    } else {
        this.angle -= d;
    }
}


function turtleSetColor(c) {
    this.color = c;
}


function turtleSetWeight(w) {
    this.weight = w;
}


function turtleFace(angle) {
    this.angle = angle;
}


function makeTurtle(tx, ty) {
    var turtle = {x: tx, y: ty,
                  angle: 0.0, 
                  penIsDown: true,
                  color: color(128),
                  weight: 1,
                  left: turtleLeft, right: turtleRight,
                  forward: turtleForward, back: turtleBack,
                  penDown: turtlePenDown, penUp: turtlePenUp,
                  goto: turtleGoTo, angleto: turtleAngleTo,
                  turnToward: turtleTurnToward,
                  distanceTo: turtleDistTo, angleTo: turtleAngleTo,
                  setColor: turtleSetColor, setWeight: turtleSetWeight,
                  face: turtleFace};
    return turtle;
}

For this project, I started with the base white star type thing, where the turtle starts at the center of the canvas but then always spreads out a random amount.  I then wanted to let the user click to add more turtles, where they would have a new random stroke and color, and they would move around randomly within the canvas. Every 10 clicks, a faded black screen is added over the canvas. I implemented this because I felt that the lines became overwhelming at a certain point, and this would help tame them.

A screenshot of my project while the fading is going on
A screenshot of my project when the fading is not going on, and it has run for a while
A screenshot of my project when you’ve only clicked once, and it hasn’t run for too long

Jisoo Geum – Looking Outwards 11

Fedde ten Berge- of Nature and Things ( het Ei (the Egg)) – 2017 

Fedde ten Berge is a Dutch sound artist who studies the sound in different types of material. The installation above is part of a larger project called “Of Nature and Things”, a collection of artificial objects mimicking forms in nature. Through “Of Nature and Things”, the audience is able to investigate different ambient sounds generated from the unique surfaces and shapes that each sculpture has to provide. I particularly liked “The Egg” because of its nature to create a subtle yet powerful sound through indirect contact. The combination of sound and the movement of the person’s hand looked interesting and even magical. From my knowledge, “The Egg” is played by the proximity between the audience and the object using a low latency audio board for embedded applications. I think Berge’s artistic sensibility is best represented from the alien sound contrasted by familiar shapes in nature.