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.

Leave a Reply