myoungsh-project-09-Emma

sketch

var Emma;
var z = .5;
function preload() {
  Emma = loadImage("https://i.imgur.com/pWLCrQJ.jpg"); //image from imgur
}
function setup() {
  createCanvas(400, 400);
  background(0);
  for (var i = 0; i < width/2; i+=z) { 
    for (var j = 0; j < height/2; j+=z) {               //nested for loop image sized
      var pixelColor1 = Emma.get(i, j);                 //storing pixels info
      var pixelBrightness1 = brightness(pixelColor1);   //sampling brightness of pixles
      noStroke();
      fill(256, 0, 256, pixelBrightness1 + 30);              //solid color brightness from image
      ellipse(i, j, z, z);                              //draw new image using colors
    }
  }
  for (var k = 0; k < width/2; k+=z) {
    for (var l = 0; l < height/2; l+=z) {
      var pixelColor2 = Emma.get(k, l);
      var pixelBrightness2 = brightness(pixelColor2);
      noStroke();
      fill(256, 256, 256, pixelBrightness2 + 50);
      ellipse(k + width/2, l + width/2, z, z);
    }
  }
  for (var m = 0; m < width/2; m+=z) {
    for (var n = 0; n < height/2; n+=z) {
      var pixelColor3 = Emma.get(m, n);
      var pixelBrightness3 = brightness(pixelColor3);
      noStroke();
      fill(0, 256, 256, pixelBrightness3 + 30);
      ellipse(m + width/2, n, z, z);
    }
  }
  for (var x = 0; x < width/2; x+=z) {
    for (var y = 0; y < height/2; y+=z) {
      var pixelColor4 = Emma.get(x, y);
      var pixelBrightness4 = brightness(pixelColor4);
      noStroke();
      fill(256, 256, 0, pixelBrightness4 + 30);
      ellipse(x, y + width/2, z, z);
    }
  }
}

Leave a Reply