Hyejo Seo-Project 09 – Portrait

sketch

/*
Hyejo Seo
Section A
hyejos@andrew.cmu.edu
Project - 09 - Portrait
*/
var myPicture;

function preload() {
    var myImageURL = "https://i.imgur.com/1g3A3AE.jpg";
    myPicture = loadImage(myImageURL);
}
function setup() {
    createCanvas(myPicture.width, myPicture.height);
    background(0);
    // loading pixels
    myPicture.loadPixels();
    // setting the rate letter 
    frameRate(200);

}

function draw() {
    var px = random(width);
    var py = random(height);
    var xx = constrain(floor(px), 0, width);
    var xy = constrain(floor(py), 0, height);
    // getting color of each pixel 
    var theColorAtXY = myPicture.get(xx, xy);
    noStroke();
    fill(theColorAtXY);
    // writing the letter R in each pixel randomly
    textSize(20);
    textFont('Avenir');
    text("R", px, py);  

}

For this project, I decided to use a picture of my bestfriend, Raphael. I set the frame rate fairly high so the letter “R” fills up fast enough. This was an interesting project overall, and I got more comfortable with playing around with pixels. 

Leave a Reply