Project 9 Liz Maday

finalfinal2

//Elizabeth Maday
//Section A
//emaday@andrew.cmu.edu
//Project 9

var theImage;

function preload() {
	theImage = loadImage("https://i.imgur.com/zBgacYu.png");
}

function setup() {
	createCanvas(400, 480);
	background(0);
	theImage.loadPixels();
	frameRate(100);
}

function draw() {
    translate(-10, -10);
    
    var x = random(width);
    var y = random(height);
    var col = theImage.get(x, y);

    stroke(col);
    var lengthmap = constrain(map(15, 0, mouseY, 0, 20), 5, 50);
    var weightmap = constrain(map(3, 0, 10, 0, mouseX/50), 0.2, 5);

    push();
    strokeWeight(weightmap);
    line(x + random(-20, 20), y + random(-10, 10), x + lengthmap, y + lengthmap);   
    pop();

    if (mouseX > width/2) {
        fill(col);
        ellipse(x, y, 2, 2);
    }
}

 

 

 

 

 

 

I liked working on this project because I got to see all the things that I could play around with while working in this format of altering a pre-existing image. I am interested in doing more creative things with this in the future. For this project, I used the position of the mouse to manipulate line length, strokeWeight, and whether or not ellipses are drawn.

Leave a Reply