Claire Yoon Project 9

sketch

//Claire Yoon
//claireyo@andrew.cmu.edu
//Section E
//Project—09—Portrait

function preload() {
    var myImageURL = "https://i.imgur.com/Oo4KTUc.jpg";
    baseImage = loadImage(myImageURL);
}

function setup() {
    createCanvas(300, 400);
    background(0);
    baseImage.loadPixels();
    //rate at which the pixels appear
    frameRate(1000);
}

function draw() {
    var px = random(width);
    var py = random(height);
    var ix = constrain(floor(px), 0, width-1);
    var iy = constrain(floor(py), 0, height-1);
    // color at the current pixel
    var theColorAtLocationXY = baseImage.get(ix, iy);

    //draw ellipses at random sizes
    noStroke();
    fill(theColorAtLocationXY);
    //ellipses increase in size when mouse is pressed
    if (mouseIsPressed) {
        ellipse(px, py, random(10, 17), random(10, 17));
    //ellipses in more smaller sizes
    } else {
        ellipse(px, py, random(2, 10), random(2, 10));
    }
}

I enjoyed experimenting with the different sizes of the ellipses by randomizing the size and increasing the randomized size when clicking on the mouse.

Finished portait

Leave a Reply