cmhoward-project11-composition

cmhoward-week-11

var sq1StartWidth = 90;
var sq1StartHeight = 50;
var sq2StartWidth = 375;
var sq2StartHeight = 100;
var sq3StartWidth = 135;
var sq3StartHeight = 150;
var sq4StartWidth = 425;
var sq4StartHeight = 200;
var sq5StartWidth = 240;
var sq5StartHeight = 350;
var sq1length;
var sq2length;
var sq3length;
var sq4length;
var sq5length;

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

function draw() {
    background(0);
    // var mx = constrain(mouseX, 0, width - sq2length);
    // var my = constrain(mouseY, 0, height - sq2length);
    // sq1StartWidth = mx - sq1length;
    // sq1StartHeight = my - sq1length;
    // sq2StartWidth = mouseX + (mx/2);
    // sq2StartHeight = mouseY + (my/2);
    sq1length = map(mouseX, 0, width, 10, 50);
    sq2length = map(mouseX, 0, width, 10, 50);
    sq3length = map(mouseX, 0, width, 20, 40);
    sq4length = map(mouseX, 0, width, 75, 25);
    sq5length = map(mouseX, 0, width, 50, 60);
    square_1();
    square_2();
    square_3();
    square_4();
    square_5();
    lines();
}

function square_1() {
    square1 = makeTurtle(sq1StartWidth, sq1StartHeight);
    square1.color = ('white');
    square1.penDown();
    square1.face(90);
    square1.forward(sq1length);
    square1.right(90);
    square1.forward(sq1length);
    square1.right(90);
    square1.forward(sq1length);
    square1.right(90);
    square1.forward(sq1length);
    square1.penUp();
}

function square_2() {
    square2 = makeTurtle(sq2StartWidth, sq2StartHeight);
    square2.color = ('white');
    square2.penDown();
    square2.face(90);
    square2.forward(sq2length);
    square2.right(90);
    square2.forward(sq2length);
    square2.right(90);
    square2.forward(sq2length);
    square2.right(90);
    square2.forward(sq2length);
    square2.penUp();
}

function square_3() {
    square3 = makeTurtle(sq3StartWidth, sq3StartHeight);
    square3.color = ('white');
    square3.penDown();
    square3.face(90);
    square3.forward(sq3length);
    square3.right(90);
    square3.forward(sq3length);
    square3.right(90);
    square3.forward(sq3length);
    square3.right(90);
    square3.forward(sq3length);
    square3.penUp();
}

function square_4() {
    square4 = makeTurtle(sq4StartWidth, sq4StartHeight);
    square4.color = ('white');
    square4.penDown();
    square4.face(90);
    square4.forward(sq4length);
    square4.right(90);
    square4.forward(sq4length);
    square4.right(90);
    square4.forward(sq4length);
    square4.right(90);
    square4.forward(sq4length);
    square4.penUp();
}

function square_5() {
    square5 = makeTurtle(sq5StartWidth, sq5StartHeight);
    square5.color = ('white');
    square5.penDown();
    square5.face(90);
    square5.forward(sq5length);
    square5.right(90);
    square5.forward(sq5length);
    square5.right(90);
    square5.forward(sq5length);
    square5.right(90);
    square5.forward(sq5length);
    square5.penUp();
}

function lines() {
    line(sq1StartWidth, sq1StartHeight, sq2StartWidth, sq2StartHeight);
    line(sq1StartWidth, sq1StartHeight + sq1length, sq2StartWidth, sq2StartHeight + sq2length);
    line(sq1StartWidth - sq1length, sq1StartHeight, sq2StartWidth - sq2length, sq2StartHeight);
    line(sq1StartWidth - sq1length, sq1StartHeight + sq1length, sq2StartWidth - sq2length, sq2StartHeight + sq2length)   

    line(sq3StartWidth, sq3StartHeight, sq2StartWidth, sq2StartHeight);
    line(sq3StartWidth, sq3StartHeight + sq3length, sq2StartWidth, sq2StartHeight + sq2length);
    line(sq3StartWidth - sq3length, sq3StartHeight, sq2StartWidth - sq2length, sq2StartHeight);
    line(sq3StartWidth - sq3length, sq3StartHeight + sq3length, sq2StartWidth - sq2length, sq2StartHeight + sq2length)   

    line(sq3StartWidth, sq3StartHeight, sq4StartWidth, sq4StartHeight);
    line(sq3StartWidth, sq3StartHeight + sq3length, sq4StartWidth, sq4StartHeight + sq4length);
    line(sq3StartWidth - sq3length, sq3StartHeight, sq4StartWidth - sq4length, sq4StartHeight);
    line(sq3StartWidth - sq3length, sq3StartHeight + sq3length, sq4StartWidth - sq4length, sq4StartHeight + sq4length) 

    line(sq5StartWidth, sq5StartHeight, sq4StartWidth, sq4StartHeight);
    line(sq5StartWidth, sq5StartHeight + sq5length, sq4StartWidth, sq4StartHeight + sq4length);
    line(sq5StartWidth - sq5length, sq5StartHeight, sq4StartWidth - sq4length, sq4StartHeight);
    line(sq5StartWidth - sq5length, sq5StartHeight + sq5length, sq4StartWidth - sq4length, sq4StartHeight + sq4length)     
}

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 explore creating animated geometric forms. With turtle graphics, there are a lot of variables that one can easily explore with easier access so this was the perfect excuse to turn a doodle I always do into an actual project. Doodles below…

While these are more complex, they are based on the same principle of connecting squares and rectangles which was the basis for my project.

Project 11

sketch

/* Rani Randell
rrandell@andrew.cmu.edu
Section A
Project 11 */

function setup() {
    createCanvas(400, 400);
    background(255, 250, 0);
}
 
function draw() {
	

	var ttl = makeTurtle(160, 430);
	ttl.penDown();
	ttl.setColor(255);

	var i;
	var d;
	for(i=0; i<200;i++){ //makes outmost giant circle
		d=16
		ttl.forward(d);
		ttl.left(360/100);

	}
	
	ttl.penUp();
	ttl.left(90)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 5;
		ttl.forward(r);
		ttl.left(360/100)
	}

	ttl.penUp();
	ttl.right(90)
	ttl.forward(40);
	ttl.penDown();

	for(var k = 0; k<100; k++){
		var q = 10;
		ttl.forward(q);
		ttl.left(360/100)
	}

	ttl.penUp();
	ttl.right(90)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 6;
		ttl.forward(r);
		ttl.left(360/100)
	}

	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}

	ttl.penUp(); //start playing here
	ttl.left(70)
	ttl.forward(-40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(90)
	ttl.forward(80);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 13;
		ttl.forward(r);
		ttl.left(360/100)

	}
	ttl.penUp();
	ttl.forward(50);
	ttl.right(80);
	ttl.forward(240);
	ttl.penDown();

	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp(); //
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(70)
	ttl.forward(40);
	ttl.penDown();

	for(var j = 0; j<100; j++){
		var r = 8;
		ttl.forward(r);
		ttl.left(360/100)
	}

	ttl.penUp();
	ttl.left(100);
	ttl.forward(30);
	ttl.right(10);
	ttl.forward(20);
	ttl.penDown();

	for(var t = 0; t<100; t++){
		var r = 3;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(100);
	ttl.forward(30);
	ttl.right(10);
	ttl.forward(20);
	ttl.penDown();

	for(var t = 0; t<100; t++){
		var r = 3;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(100);
	ttl.forward(30);
	ttl.right(10);
	ttl.forward(20);
	ttl.penDown();

	for(var t = 0; t<100; t++){
		var r = 3;
		ttl.forward(r);
		ttl.left(360/100)
	}
	ttl.penUp();
	ttl.left(100);
	ttl.forward(30);
	ttl.right(10);
	ttl.forward(20);
	ttl.penDown();

	for(var t = 0; t<100; t++){
		var r = 3;
		ttl.forward(r);
		ttl.left(360/100)
	}



	
}

//turtle code template

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 my project I was really inspired by Tomas Saraceno’s large scale installation work Webs of Tension. This work is a vast room of giant cubes made of iron bars on each cube edge. But within the open air cube are thousands of spiderwebs, made to show the vast interconnectivity that they use daily and we admire but isn’t constructed for only human purposes. Underneath the cubes are giant lights that illuminate the thousands of imperfect yet beautiful webs. When I saw this it really spoke to me so I felt I could try to recreate that with turtle graphics. Below is a link to his website:

https://studiotomassaraceno.org/

Vicky Zhou – Project 11 – Computation

sketch

/*Vicky Zhou
vzhou@andrew.cmu.edu
Section E
Project 11 - Freestyle with Turtles*/

//turtle array
var ttl = [];

function setup() {
	createCanvas(480, 480);
	background(180, 200, 250);
	//initializing the turtle array
	for (var i = 0; i < 5; i ++){
		t = makeTurtle(0, 0);
		ttl.push(t);
	}
}


function draw() {
	for (var i = 0; i < 5; i ++){
		fill(190, 210, 210, 200);
		stroke("blue");
		//drawing the triangle
		triangle(ttl[i].x, ttl[i].y,
			ttl[i].x + 10, ttl[i].y + 60,
			ttl[i].x + 100, ttl[i].y + 100);
		//moving the triangle
		moveTurtle();
	}

}

//function to move the triangles 
function moveTurtle() {
	for (var i = 0; i < 5; i ++){
		dx = abs(ttl[i].x - mouseX);
		if (ttl[i].x < mouseX) {
			ttl[i].x += dx / 50;
		}
		else {
			ttl[i].x -= dx / 20;
		}
		dy = abs(ttl[i].y - mouseY);
		if (ttl[i].y < mouseY) {
			ttl[i].y += dy / 100 + i;
		}
		else {
			ttl[i].y -= dy / 100 + 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 week’s project, because the prompt was so vague I was not entirely sure what I wanted my end product to be. However, I did want my computational turtles to be interactive with the mouse, so I centered the project around a turtle that would follow your mouse tracking and leave behind a trace. I played around with ellipses, rectangles, but then settled on a triangle because of how neatly some edges could settle in each other.

Screenshots of images you can create

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.