//Sammie Kim
//Section D
//sammiek@andrew.cmu.edu
//Project 09 - Computational Portrait
var img;
var smallPoint;
var largePoint;
var pointSize;
//preloading image from imgur
function preload() {
img = loadImage('https://i.imgur.com/yXi77UB.jpg');
}
//setting the speed and size of loading image pixels
function setup() {
createCanvas(300, 300);
background(0);
imageMode(CENTER);
img.loadPixels();
frameRate(100);
noStroke();
smallPoint = 1;
largePoint = 10;
}
function draw() {
var x = floor(random(img.width)); //random x location for ellipse
var y = floor(random(img.height)); //random y location for ellipse
var imageColor = img.get(x, y); //picking the x, y coordinates from the image
fill(imageColor); //fill the ellipses with the color from image
//let the points get smaller toward the bottom of canvas that has more details
var pointSize = map(y, 0, height, largePoint, smallPoint);
ellipse(x, y, pointSize, pointSize);
}
This project was entertaining as I was able to recreate my own portrait by using points. Observing how the points would gradually generate the full photo, I purposely made the bottom half points tiny to better reflect the detailed areas.