Romi Jin – Project-09-Portrait

sketch

/*
Romi Jin
Section B
rsjin@andrew.cmu.edu
Project-09
*/

var img;

function preload() {

    var imgur = "https://i.imgur.com/tbSmZ90.jpg";
    img = loadImage(imgur);
}

function setup() {

    createCanvas(360, 479); //resize image in photoshop
    background(255, 225, 225);
    imageMode(CENTER);
    frameRate(500); //speed that pixels are drawn 
    img.loadPixels();
    noStroke();

}

function draw() {

    var x = constrain(floor(random(width)), 0, width); //constrains random x values of pixels
    var y = constrain(floor(random(height)), 0, height); //constrains random y values of pixels

    var rgb = img.get(x, y); //extracts colors from image pixels

    fill(rgb);
    ellipse(x, y, 7); //circles drawing the image

}

For this project, I used an image of my best friend from home, Mina! It was a lot easier than I expected! From just a few lines of code, you can produce such a cool animated image! I am excited to try this out with different images and shapes in the future.

Leave a Reply