Project 9: Computational Portrait

For this project, I decided to draw a picture of me when I was a child. I created random shapes similar to snowflakes to represent a time of innocence and delicacy. I created the portrait with an emoticon that reflects my feeling toward that time of my life.

sketch
/*
Bon Bhakdibhumi
bbhakdib
Section D
*/

var img;
var transparent = 0;

function preload() {
  img = loadImage('https://i.imgur.com/9gYfG3D.jpg');
}

function setup() {
    createCanvas(400, 567);
    imageMode(CENTER);
    noStroke();
    img.loadPixels();
    background(255);
}

function draw() {
// random x & y positions for where to draw
  var x = floor(random(img.width));
  var y = floor(random(img.height));
// selecting color from the actual picture
  var pix = img.get(x, y);
  snowFlake(x, y, pix);
  cuteEmojicon(x, y, pix);
}

function snowFlake(x, y, pix) {
  fill(pix, 50);
  beginShape();
    for (var i = 0; i < 20; i++) {
       vertex(x + random(-5, 5), y + random(-5, 5));
    }
    endShape(CLOSE);
}

function cuteEmojicon(x, y, pix) {
  fill(pix, 50);
  textSize(random(5, 15));
  text('♡´・ᴗ・`♡', x, y);
}



Image rendering as time goes by

Leave a Reply