Bo Yang-Project-04-String-Art

sketch

/*
    Bo Yang
    byang2@andrew.cmu.edu
    SectionA
    Project-04
*/

var y = 0;
var x = 0;
var angle = 0;
var angle1 = 0;
function setup() {
    createCanvas(300, 300);
}

function draw() {
    background(0);

    push();
    translate(width / 2, height / 2);
    rotate(radians(angle));
    fill(255, 255, 0);
    ellipse(mouseX, 0, 8, 8);
    pop();
    angle = angle + 30;

    push();
    translate(width / 2, height / 2);
    rotate(radians(angle1));
    ellipse(mouseX, 0, 8, 8);
    pop();
    angle1 = angle1 + 15;


    for (var i = 0; i < width; i += 15){
        stroke(255);
        strokeWeight(0.5);
        line(i, 0, i + mouseX, 300);
        line(i + mouseX, 0, i, 300);
    }

    for(var i = 0; i < width; i += 8){
        stroke(0, 153, 153);
        line(i, 300, 0, i - mouseX);
        line(300, i, i - mouseX, 0);
    }
}

In this program, I use the line drawing a background. When you move your mouse, it can open and close. And also, I’m draw the line like an eye. That is why, I also draw two ellipses, making it looks more like an eye.

Leave a Reply