Erin Fuller Project-04-String-Art


//Erin Fuller
//SectionA
//efuller@andrew.cmu.edu
//Project 04

// please view on safari, does not work on chrome

var x; //mouseX global
var y; //mosueY global

var control; // laser position based on for loop increments

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

function draw() {
    background(0);

    var x = mouseX * (255 / width); // changes g value relative to width
    var y = mouseY * (255 / height); // changes b value relative to width

    stroke(255, x, y); //g and b values changed 
    strokeWeight(.005); // very thin lines to look like lasers

    for (var i = 0; i < 100; i++) {
        var control = (i * mouseX) / 75; //control increases based on mouseX postion
        
        line(0, 0, control, height);//top left "laser" pointing down
        line(0, 0, width, control);//top left "laser" pointing right
   
        line(width, height, control, 0);//bottom right "laser" fanning left and up
        line(0, control, width, height);//bottom right "laser" fanning left and down
    }
}

I wanted my “String Art” to be reminiscent of a laser light show like what you see at concerts. So as you move your mouse you change how wide the “lasers” fan out and their color.

Leave a Reply