Project 09 Portrait

sketch

//Tim Nelson-Pyne
//tnelsonp@andrew.cmu.edu
//section C
//Assignment-09-Project



var img;
var x = [];
var y = [];
    



function preload() {
    //loads the walking Images
    img = loadImage('https://i.imgur.com/gCoIwkQ.jpg');
    
}

function setup() {
    createCanvas(480, 480);
    img.resize(width, height);
    background(255);
    img.loadPixels();

    
}




function draw() {
    //ellipse width
    var w = 1;
    //change in ellipse width
    var dw = .8;
    
    for(var row = 0; row < width; row += 5) {
        for (var col = 0; col < height; col +=5) {
            //gets the color of the current pixel location
            var pix = img.get(col, row);
            //generates an inverse color reading of the image
            var invR = 255 - pix[0];
            var invG = 255 - pix[1];
            var invB = 255 - pix[2];
            noStroke();
            fill(invR, invG, invB);
            //draws the inverse image in background
            rect(col, row, 5, 5)
            fill(pix);
            //changes the width of ellipses
            w += dw;
            if (w > 6 || w < 1) {
                dw = - dw;
            }

            ellipse(col, row, w, 6);
        }
    }

    



noLoop();
}

Leave a Reply