jdperez Project 11

Although I wouldn’t say that this project is polished or complete, I think it was a great learning opportunity for me. While playing around with a turtle, or many turtles, creating hundreds of thin lines, I realized that turtle graphics (or at least that style of turtle graphics) allowed me to create an entirely different aesthetic — one reminiscent of hand drawing.

This is a bit ironic, since the final product is not that reminiscent of hand drawing…

After I had gotten all excited about making these pencil sketch images, I began to play around with more abstract drawings. There were a bunch of these that I was playing around with, and honestly I’m not sure which I like best compositionally, but the last one I worked on was this eyeball-esque shape.

open stage of curling process

The program takes a bunch of straight lines, and bends them towards the center, creating the illusion of a hard circle filled with a bunch of ellipses.

mid way through curling

Then, as the line reaches the center, sin() switches from positive to negative, and it bends in the other direction, moving out towards the parameter.

final and most condensed stage

The lines then proceed to curl again towards the center, creating a sort of loose rim around the circle. I enjoy the slowing effect as the line curls, since it creates the feeling of tension or elasticity. I hope you enjoy!

sketch

//Jonathan Perez
//Section B
//jdperez@andrew.cmu.edu
//Project 11
var t1; //turtle
var r0 = [] //initialized random radii from center
var face1 = [] //initialized random face
var face2 = [] //second initialzed face before drawing line
var w = .25 //starting angle

function curl(d) {
    //function that produces the furling and unfurling effect
    //the w variable is incremented to return values from 1 to -1 smoothly
    //and the value is scaled by d / 9
    return sin(2 * PI * (w)) * d / 9; 
}


function drawLine() {
    t1.penDown();
    for (var i = 0; i < 53; i++) {
        var d = t1.distanceTo(240, 240); //turtle distance from center
        t1.setWeight(d / 400 + 0.00); //line thickens as it gets further from center
        t1.forward(10);
        t1.left(curl(d)); //
        if (t1.x > width || t1.x < 0 || t1.y > height || t1.y < 0) {
            return;
        }
    }
}


function setup() {
    createCanvas(480, 480);
    t1 = makeTurtle(240, 240);
    for (var i = 0; i < 250; i++) {
        //create the starting points for each line
        face1.push(random(360));
        r0.push(random(0 + random(20)));
        face2.push(random(360));
    }
}

function draw() {
    //background(200, 200, 170);
    background(255)
    //fill(0);
    //ellipse(width/2, height/2, 37, 37)
    t1.setColor(0);
    t1.setWeight(0.3);
    for (var i = 0; i < 250; i++) {
        t1.penUp();
        //go to respective starting position
        t1.goto(width/2, height/2);
        t1.face(face1[i]);
        t1.forward(r0[i]);
        t1.face(face2[i]);
        //draw line
        drawLine();
    }
    w += .0025
}

//------------------------------------------

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;
}

SaveSave

heeseoc-Project-11-Composition

sketch

//Steph Chun
//Section A
//heeseoc@andrew.cmu.edu
//Project-11

var turtle, turtle2;
var angle = 20;
var side = 5;
var angle2 = 160;
var side2 = 10;

function setup(){
    createCanvas(400,400);
    background(20,20,50);
	frameRate(10);
	//circular geometric shape
	turtle = makeTurtle(random(0,width), random(0,height));
	//spikey geometric shape expanding from the center
	turtle2 = makeTurtle(width/2, height/2);
}

function draw(){
	stroke(255);
	strokeWeight(.8);
	textSize(14);
	text("click anywhere!", 5, 20);

	//circular geometric shape 
	for (var i = 0; i < 30; i++){
		turtle.setColor(color(random(150,255), random(200,255), random(200,255)));
	    turtle.penDown();
	    turtle.setWeight(.2);
	    turtle.left(angle);
	    turtle.forward(side);
}
	turtle.right(10);
    side += .5;

    //spikey geometric shape expanding from the center
	turtle2.setColor(color(random(150,255), random(200,255), random(100,255)));
    turtle2.penDown();
    turtle2.setWeight(.3);
    turtle2.left(angle2);
    turtle2.forward(side2);
    turtle2.right(5);
    side2 += 2;

}

//creating spiral shape on mouseclick 
function mousePressed(){
	turtle = makeTurtle(mouseX, mouseY);
}


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;}

While I was exploring what I can do with turtles, I noticed how I can make interesting spirals through drawing lines and manipulating angles. At first, I was trying to execute these (not-so-exactly) circular spirals with some random factors on mouseclick, but then it looked somewhat boring with only those on a dark background. So I re-generated one of the spirals that I thought was interesting and placed it at the center. After a while I left the code alone, it made this interesting circular shape even though it started off as a rather angular and spikey shape, which I thought resonated with the circular shapes that are being created on mouseclick. I liked how it has an interactive component, but later on, the user is like swallowed by the dense spiral and notice the connection between the two seemingly different elements.

ssharada-project11-composition

sketch-132.js

//shariwa sharada 
//ssharada@andrew.cmu.edu
//section a 
//project 11

//setting initial starting points for the turtles
dx = 127
dX = 127

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

//creating the turtles using the below trutle commands
  turtle  = new makeTurtle(dx+20, 50);
  turtle2  = new makeTurtle(dx+50, 305);
  turtle3  = new makeTurtle(dx+90, 255);
  turtle4  = new makeTurtle(dx-60, 285);
  turtle5  = new makeTurtle(dx-90, 0);
  turtle6  = new makeTurtle(dx-110, 275);
  turtle7  = new makeTurtle(dx+100, 575);

}

function draw(){

  background(0, 10);
  noFill();

//drawing turtle shapes
  drawShape1();
  drawShape2();
  drawShape3();
  drawShape4();
  drawShape5();
  drawShape6();
  drawShape7();

}

//creating the different circles 
//sizing is varied using  the size of the object moving forward
//speed of the circles moving is depedent on the angle

//the stroke weight of each line depends on the position of the y point of the cursor
//radius of each circle is dependent on the mouseX cursor position

function drawShape1(){
    turtle.setWeight(1 + mouseY/30)
    turtle.right(2 + mouseX/100);
    turtle.forward(1);
}

function drawShape2(){
    turtle2.setWeight(random(2 + mouseY/30,9 + mouseY/30))
    turtle2.right(-3 );
    turtle2.forward(4 + mouseX/100);
}

function drawShape3(){
    turtle3.setWeight(random(1 + mouseY/30, 2 + mouseY/30))
    turtle3.right(6 + mouseX/150);
    turtle3.forward(10);
}

function drawShape4(){
    turtle4.setWeight(random(3 + mouseY/30,6 + mouseY/30))
    turtle4.right(10);
    turtle4.forward(6 + mouseX/175);
}

function drawShape4(){
    turtle4.setWeight(random(4 + mouseY/30, 2 + mouseY/30))
    turtle4.right(10);
    turtle4.forward(6 + mouseX/200);
}

function drawShape5(){
    turtle5.setWeight(random(3 + mouseY/30,6 + mouseY/30))
    turtle5.right(7);
    turtle5.forward(20 + mouseX/225);
}

function drawShape6(){
    turtle6.setWeight(random(1 + mouseY/30, 5 + mouseY/30))
    turtle6.right(-7);
    turtle6.forward(13 + mouseX/250);
}

function drawShape7(){
    turtle7.setWeight(random(1 + mouseY/30, 5 + mouseY/30))
    turtle7.right(-4);
    turtle7.forward(10 + mouseX/250);
}


//-----------------------------------------------------------------------
//-----------------------------------------------------------------------

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(255, random(40, 110)),
                  weight: 5,
                  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 was inspired by brush strokes and watercolour paint because of which I tried to create these circles by making the flow of the circles the brush stroke style. As the cursor moved, the thickness of the stroke changes like the brush stroke.

^thin line weights with a lower mouseY value

^thick line weights with a higher mouseY value

Ziningy1-project 11

sketch

//Zining Ye 
//15104 lecture 1 recitation C
//ziningy1@andrew.cmu.edu 
//Project-10 

var mturtle;
var angle=90;
var path=10;

function setup(){
    createCanvas(480,480);
    background(150,170,200);
    frameRate(20); //set the framerate 
    mturtle=makeTurtle(width/2,height/2);
}

function draw(){
 
        
        for(var i=0;i<4;i++){ //make the turtle draw a square
        
        mturtle.setWeight(1)
        mturtle.left(angle);
        mturtle.forward(path);
    }

 mturtle.setColor(color(random(0,150),random(50,150),random(0,255))); //set the randomness of the color 
    mturtle.penUp();
    mturtle.right(2); //turn 2 degree every time it loops 
    path+=0.3 //the length of the square increases 
    mturtle.penDown(); 
    

}


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;}




   


    







This composition is inspired by one of the lecture notes where we put put the turtle codes in the draw function, so this way it loops and draws the pattern gradually. I made the square shape rotates certain degree everytime, while it is also growing in size.

abradbur – Project – 11

sketch


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

}


function draw() {
    //sunset palette
    var r = 255 + 25 * sin(millis() / 1000.0 );
    var g = 200 + 25 * sin(millis() / 1000.0 + HALF_PI);
    var b = 150 + 25 * sin(millis() / 1000.0 - HALF_PI);
    background (r,g,b);
    //make a hill
    noStroke();
    fill(0);
    arc(235, 480, 500, 200, PI, 0, OPEN);

    //tree
    t1 = makeTurtle(240,380);
    t2 = makeTurtle(240, 230);
    t3 = makeTurtle(240, 230);
    t4 = makeTurtle(240, 230);
    t5 = makeTurtle(240, 230);
    t6 = makeTurtle(240, 230);
    t7 = makeTurtle(240, 230);
    t8 = makeTurtle(200, 230);
    t1.setColor(0);
    t1.setWeight(10);
    t2.setWeight(4);
    t2.setColor(0);
    t3.setWeight(2);
    t3.setColor(0);
    t4.setColor(0);
    t4.setWeight(4);
    t5.setColor(0);
    t5.setWeight(5);
    t6.setColor(0);
    t6.setWeight(3);
    t7.setColor(0);
    t7.setWeight(4);
    t8.setColor(255);
    t8.setWeight(3);
    t7.left(95);
    t7.forward(100);
    t1.left(90);
    t1.forward(150);
    t2.left(150);
    t2.forward(100);
    t3.right(175);
    t3.forward(130);
    t4.left(175);
    t4.forward(130);
    t5.left(5);
    t5.forward(130);
    t6.left(25);
    t6.forward(140);
    t8.left(25);
    t8.forward(140);
    var i = 0;
    while(i < 10){
    
        
        t2.right(random(82, 90));
        t2.forward(60);
        t2.back(random(60, 70));
        t2.left(55);
        t2.forward(20);

        
        t3.right(90);
        t3.forward(random(40,60));
        t3.back(30);
        t3.left(45);
        t3.forward(30);
        
        t4.right(90);
        t4.forward(60);
        t4.back(60);
        t4.left(45);
        t4.forward(30);
        
        t5.left(90);
        t5.forward(60);
        t5.back(60);
        t5.left(45);
        t5.forward(30);
        
        t6.left(90);
        t6.forward(60);
        t6.back(60);
        t6.left(45);
        t6.forward(30);
        
        t7.right(90);
        t7.forward(60);
        t7.back(random(30,60));
        t7.left(130);
        t7.forward(30);

        t8.right(90);
        t8.forward(60);
        t8.back(60);
        t8.left(130);
        t8.forward(random(10,30));

        i ++;
    }
    

    
    
}
//turtle graphics 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;}

I started out by wanting to draw some spooky skeletal trees, but then I got bored of drawing straight lines the whole time and decided to make it a Dr. Seus-esque tree instead. I enjoyed making circular pathways with different branches. Best Quality: Its wiggles.

keuchuka – project – 11

project11

//Fon Euchukanonchai
//15-104 Section A
//keuchuka@andrew.cmu.edu
//Project-11

//variables for shape change
var addCai = 0
var addDe = 0
var addFu = 0
var addXi = 0
var addAi = 0
var c = 10
var jitter;

//for differnt turtles
var pX = 40 
var pY = 0
var pYMove = 1

var fX = 130
var fY = 100
var fYMove = 1

var tX = 225
var tY = 0
var tYMove = 1

var cX = 310
var cY = 100
var cYMove = 1

var dX = 405
var dY = 0
var dYMove = 1

//loading Chinese character images
function preload(){

	aiPic = loadImage("https://i.imgur.com/o5xIMAW.png")
	fuPic = loadImage("https://i.imgur.com/GA5Rnem.png")
	xiPic = loadImage("https://i.imgur.com/5sx0vnR.png")
	caiPic = loadImage("https://i.imgur.com/LJIdHCA.png")
	dePic = loadImage("https://i.imgur.com/iuYqMLD.png")

}

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

function draw(){
    frameRate(40);
    var backC = 255
    //creating "drag" effect with transaparent bg
    background(backC,60);

	noFill();
	stroke(255,0,0);
	strokeWeight(3)
    rect(0,0,width,height,30)

    noStroke();

////////////AI//////////////

var turtlec = new Turtle(pX + 23, pY - 19);

	//drawing the shape
    for(var i = 0; i < 20; i ++){
    turtlec.penUp();
    turtlec.forward(5)
    turtlec.penDown();
    turtlec.setColor(color(255,0,0,10));
    turtlec.setWeight(2);
    turtlec.forward(c);
    turtlec.right(30+addAi);
    turtlec.forward(c);
    turtlec.right(30+addAi);
    turtlec.forward(c)
    turtlec.right(30+addAi);
    turtlec.forward(c);
    turtlec.left(30+addAi);

    c = random(10,11)
    
    //changing the shape when mouse is pressed
    if (mouseIsPressed){
	addAi = addAi += 1
	}

	if (addAi == 20){
		addAi = 0
	}
}

//inserting the image of character, adding jitter, and reverse motion when it hits walls
image(aiPic, pX+jitter, pY+jitter)
tint(255, 127);    

    pY = pY += pYMove
    jitter = random(1,3)

    if(pY > height-50){
    	pYMove = -1
    } else if (pY < 20){
    	pYMove = 1
    }

// above comments can be used for all following characters

////////////XI//////////////

var turtlec2 = new Turtle(tX + 23, tY - 19);

    for(var i = 0; i < 20; i ++){
    turtlec2.penUp();
    turtlec2.forward(5)
    turtlec2.penDown();
    turtlec2.setColor(color(255,0,0,10));
    turtlec2.setWeight(2);
    turtlec2.forward(c);
    turtlec2.right(30+addXi);
    turtlec2.forward(c);
    turtlec2.right(30+addXi);
    turtlec2.forward(c)
    turtlec2.right(30+addXi);
    turtlec2.forward(c);
    turtlec2.left(30+addXi);

    c = random(10,11)
    if (mouseIsPressed){
	addXi = addXi += 1
	}

	if (addXi == 20){
		addXi = 0
	}

}


image(xiPic, tX+jitter, tY+jitter)
tint(255, 127);

    tY = tY += tYMove

    jitter = random(1,3)


    if(tY > height-50){
    	tYMove = -1
    } else if (tY < 20){
    	tYMove = 1
    }


///////////FU//////////

var turtlec3 = new Turtle(fX + 28, fY - 19);

    for(var i = 0; i < 20; i ++){
    turtlec3.penUp();
    turtlec3.forward(5)
    turtlec3.penDown();
    turtlec3.setColor(color(255,0,0,10));
    turtlec3.setWeight(2);
    turtlec3.forward(c);
    turtlec3.right(30+addFu);
    turtlec3.forward(c);
    turtlec3.right(30+addFu);
    turtlec3.forward(c)
    turtlec3.right(30+addFu);
    turtlec3.forward(c);
    turtlec3.left(30+addFu);

    c = random(10,11)
  
  if (mouseIsPressed){
	addFu = addFu += 1
	}

	if (addFu == 20){
		addFu = 0
	}

}


image(fuPic, fX+jitter, fY+jitter)
tint(255, 127);

    fY = fY += fYMove



    jitter = random(1,3)


    if(fY > height-50){
    	fYMove = -1
    } else if (fY < 25){
    	fYMove = 1
    }




///////////CAI//////////

var turtlec4 = new Turtle(cX + 28, cY - 19);

    for(var i = 0; i < 20; i ++){
    turtlec4.penUp();
    turtlec4.forward(5)
    turtlec4.penDown();
    turtlec4.setColor(color(255,0,0,10));
    turtlec4.setWeight(2);
    turtlec4.forward(c);
    turtlec4.right(30+addCai);
    turtlec4.forward(c);
    turtlec4.right(30+addCai);
    turtlec4.forward(c)
    turtlec4.right(30+addCai);
    turtlec4.forward(c);
    turtlec4.left(30+addCai);

    c = random(10,11)
  
  if (mouseIsPressed){
	addCai = addCai += 1
	}

	if (addCai == 20){
		addCai = 0
	}

}




image(caiPic, cX+jitter, cY+jitter)
tint(255, 127);

    cY = cY += cYMove

    jitter = random(1,3)


    if(cY > height-50){
    	cYMove = -1
    } else if (cY < 25){
    	cYMove = 1
    }

///////////DE//////////

var turtlec5 = new Turtle(dX + 28, dY - 19);

    for(var i = 0; i < 20; i ++){
    turtlec5.penUp();
    turtlec5.forward(5)
    turtlec5.penDown();
    turtlec5.setColor(color(255,0,0,10));
    turtlec5.setWeight(2);
    turtlec5.forward(c);
    turtlec5.right(30+addDe);
    turtlec5.forward(c);
    turtlec5.right(30+addDe);
    turtlec5.forward(c)
    turtlec5.right(30+addDe);
    turtlec5.forward(c);
    turtlec5.left(30+addDe);

    c = random(10,11)

  if (mouseIsPressed){
	addDe = addDe += 1
	}

	if (addDe == 20){
		addDe = 0
	}


}




image(dePic, dX+jitter, dY+jitter)
tint(255, 127);

    dY = dY += dYMove

    jitter = random(1,3)


    if(dY > height-50){
    	dYMove = -1
    } else if (dY < 20){
    	dYMove = 1
    }




}



//=======================================================
// TURTLE GRAPHICS IMPLEMENTATION

function Turtle(x, y) {
  this.x = x;
  this.y = y;
  this.angle = 0.0;
  this.penIsDown = true;
  this.color = color(128);
  this.weight = 1;
 
  this.left = function(d) {
    this.angle -= d;
  };
  this.right = function(d) {
    this.angle += d;
  };
  this.forward = function(p) {
    var rad = radians(this.angle);
    var newx = this.x + cos(rad) * p;
    var newy = this.y + sin(rad) * p;
    this.goto(newx, newy);
  };
  this.back = function(p) {
    this.forward(-p);
  };
  this.penDown = function() {
    this.penIsDown = true;
  };
  this.penUp = function() {
    this.penIsDown = false;
  };
  this.goto = function(x, y) {
    if (this.penIsDown) {
      stroke(this.color);
      strokeWeight(this.weight);
      line(this.x, this.y, x, y);
    }
    this.x = x;
    this.y = y;
  };
  this.distanceTo = function(x, y) {
    return sqrt(sq(this.x - x) + sq(this.y - y));
  };
  this.angleTo = function(x, y) {
    var absAngle = degrees(atan2(y - this.y, x - this.x));
    var angle = ((absAngle - this.angle) + 160) % 160.0;
    return angle;
  };
  this.turnToward = function(x, y, d) {
    var angle = this.angleTo(x, y);
    if (angle < 180) {
      this.angle += d;
    } else {
      this.angle -= d;
    }
  };
  this.setColor = function(c) {
    this.color = c;
  };
  this.setWeight = function(w) {
    this.weight = w;
  };
  this.face = function(angle) {
    this.angle = angle;
  }
}

The shape that turtle graphics can make really reminded me of the stamps of lucky red Chinese stamps (they’re flower-like radial compositions). I tried to replicate that in this project, having these stamps bounce in a banner type organization and taking advantage of turtle graphics in loop, have it change shape slightly when the mouse is pressed.


normal state of shape

changed state of shape when mouse is pressed

ifv-Project-11

sketch

//Isabelle Vincent
//Section E
//ifv@andrew.cmu.edu
//Project-11

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;
}

function lines(t1){
  for(var j = 0; j<4;j++){
    t1.penDown();
    t1.forward(10);
    t1.left(180);
  }
}

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

function draw(){
  //inverse the stroke and bg colors
  var v = map(mouseY,0,height,0,255);
  var b = map(mouseY,height,0,0,255);
  background(v);
  var t1 = makeTurtle(mouseX,mouseY);
  t1.setColor(b);
  t1.setWeight(6);
  t1.penUp();
  //t1.forward(20);
  //t1.penDown();
  //t1.left(90);
  //t1.left(10);
  for(var i=0; i<1000; i++){
      t1.penUp();
      //go out from center
      var dist=(-(mouseY+mouseX)/2) +1 + i *1
      t1.forward(dist);
      //draw
      lines(t1);
      //come back
      t1.penUp();
      t1.left(180);
      t1.forward(dist);
      t1.left(180);

      //rotate by some angle
      t1.left(10);
  }
}

jennyzha – project 11

sketch

// Jenny Zhang
// jennyzha@andrew.cmu.edu
// Section D 
// Project 11

function setup() {
    createCanvas(480, 380);
    background(165,236,250);

//making the hilly background

    noStroke();
    fill(0,255,0);
    ellipse(300,380,650,650);

    noStroke();
    fill(0,200,0);
    ellipse(100,380,550,550);

    noStroke();
    fill(178, 255,102);
    ellipse(400,380,850,350);
}

function mousePressed(){
    
    var flower = makeFlower(mouseX,mouseY); //creates flowers wherever you click 
    flower.setColor(color(random(220,255),random(50,255),random(50,100))); //sets random colors ranging from red to orange to yellow
    flower.setWeight(1) //sets the weight for the lines of the flowers
    var size = random(1,15); //setting random sizes for the flowers
   
    for(var i = 0; i < 1000; i++) {
        flower.penDown();
        flower.forward(size);
        flower.right(30);
        flower.forward(size);
        flower.right(30);
        flower.forward(size);
        flower.right(30);
        flower.forward(size);
        flower.right(30);
        flower.forward(size);
        flower.right(30);
        flower.forward(size);
        flower.penUp();
        flower.right(100);
        flower. right(30);
        flower.setWeight(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 makeFlower(tx,ty){
  var turtle={x:tx,y:ty,angle:0.0,penIsDown:true,color:color(0),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 created a hilly spring terrain, where the user’s clicks create flowers wherever they click. With each click, the color is varied randomly between colors of red to yellow, as are the sizes. I kept the stroke weight consistent since when varied, if it is too thick the large flowers look too blurry and when too thin you can’t see them as well.

yoonyouk-project11-Composition

sketch

//Yoon Young Kim
//Section E
//yoonyouk@andrew.cmu.edu
//Assignment10-A


var turtle;



function setup() {
    var heartmeterangle = random(40, 70);
    var heartmeterlength = random(75, 150);
    createCanvas(480, 360);
    background(random(170, 255));
    frameRate(10);
    turtle = makeTurtle(0, height/2);
    turtle.penDown();
    turtle.setColor(0);
    turtle.setWeight(random(5, 20));


    for(i = 0; i < 8; i++) {

        //rainbow colors
        var r = random(50, 200);
        var g = random(50, 200);
        var b = random(50, 200);
      

        turtle.setColor(color(r, g, b));
        turtle.setWeight(50);


       // turtle.right(sqrt(sq(floor(mouseX - turtle.x))+sq(floor(mouseY-turtle.y))));
        //turtle.forward(floor(mouseX - turtle.x), floor(mouseY-turtle.y));

    turtle.penDown();
    turtle.left(heartmeterangle);
    turtle.forward(heartmeterlength);
    turtle.right(180-heartmeterangle);
    turtle.forward(2*heartmeterlength);
    turtle.left(180-heartmeterangle);
    turtle.forward(heartmeterlength);   
    turtle.right(120-heartmeterangle);

    }

}


function draw() {


}


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 turtle graphics project, I made a heart meter like graphic that changes whenever refreshed. A new turtle is drawn after each jump. When refreshed, the colors and positions and lengths change color as well. 

mecha-project11-composition

sketch

//sets up an empty arrays for turtles
var turtleArray = [];
var turtleArray2 = [];
var turtleArray3 = [];
var turtleMouse = [];
var turtleX;
var turtleY;
var x;
var y;

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

function draw() {
    turtles();
    turtles2();
    turtles3();
}

//when mouse is pressed, new turtles are pushed into array
//(with same x and y values)
function mousePressed() {
    turtleX = 0;
    //allows for stair cases to be at every part of canvas
    turtleY = random(-height, height);
    turtleArray.push(makeTurtle(turtleX, turtleY));
    turtleArray2.push(makeTurtle(turtleX, turtleY));
    turtleArray3.push(makeTurtle(turtleX, turtleY));
}

function turtles() {
    //for every turtle in array, sets new color
    for (var i = 0; i < turtleArray.length; i++) {
        turtleArray[i].penDown();
        turtleArray[i].setColor(random(0, 255));
        turtleArray[i].setWeight(2);

        //will fill up canvas by creating staircase
        for (var j = 0; j <= 12; j++) {
            turtleArray[i].forward(width / 12);
            turtleArray[i].right(90);
            turtleArray[i].forward(width / 12);
            turtleArray[i].left(90);
        }

        turtleArray[i].penUp();
    }
}

function turtles2() {
    for (var i = 0; i < turtleArray.length; i++) {
        turtleArray2[i].penDown();
        turtleArray2[i].setColor(random(0, 255));
        turtleArray2[i].setWeight(2);

        for (var j = 0; j <= 24; j++) {
            turtleArray2[i].forward(width / 24);
            turtleArray2[i].right(90);
            turtleArray2[i].forward(width / 24);
            turtleArray2[i].left(90);
        }

        turtleArray[i].penUp();
    }
}

function turtles3() {
    for (var i = 0; i < turtleArray.length; i++) {
        turtleArray3[i].penDown();
        turtleArray3[i].setColor(random(0, 255));
        turtleArray3[i].setWeight(2);

        for (var j = 0; j <= 36; j++) {
            turtleArray3[i].forward(width / 36);
            turtleArray3[i].right(90);
            turtleArray3[i].forward(width / 36);
            turtleArray3[i].left(90);
        }

        turtleArray[i].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 assignment, I decided that I wanted to try and make an interesting pattern with my turtles. At first, I started with a basic staircase which generated at a random y value in between -480 and 480. Once I was able to figure out the code for that, I started to make new turtle arrays that ended up resembling a snowy mountain peak based on the color and the way that each of the lines intersected.

Every time a user clicks inside of the canvas, three turtles will generate with different color values.


sketch process


examples of turtle compositions