Sharon Yang Project 09 Portrait

Project

/*Sharon Yang
Section C
junginny
Project-09
*/

var underlyingImage;

function preload() {
    var myImageURL = "https://i.imgur.com/ZnYAlHy.jpg"; //image of my boyfriend smiling
    underlyingImage = loadImage(myImageURL);
}

function setup() {
    createCanvas(480, 480);
    background(0);
    underlyingImage.loadPixels();
    frameRate(300);
}

function draw() {
    var px = random(width); //the coordinates of where shapes created are randomized
    var py = random(height);
    var ix = constrain(floor(px), 0, width-1); 
    var iy = constrain(floor(py), 0, height-1);
    var theColorAtLocationXY = underlyingImage.get(ix, iy); //get the colors of the pixel

    noStroke();
    fill(theColorAtLocationXY);
    drawShape(px, py, 5, 10);
}

function drawShape(x, y, radius1, radius2) { //draw star shape
    var angle = TWO_PI/5;
    beginShape();
    for (var i = 0; i < TWO_PI; i += angle) {
    var starX = x + cos(i) * radius2;
    var starY = y + sin(i) * radius2;
    vertex(starX, starY);
    starX = x + cos(i+angle/2) * radius1;
    starY = y + sin(i+angle/2) * radius1;
    vertex(starX, starY);
  }
  endShape(CLOSE);
}

I have used an image of my boyfriend.  The project incorporated a very interesting concept. However, because I used the star shape, and also the image was quite blurry, it became really hard to make out of what the image is.

Leave a Reply