Kyle plays with 3D pixels and may or may not have created an image of God

I worked with a friend to learn how to take an image that I had grabbed color values from and pixelated, and make each of the pixels into a 3-dimensional box. we used “brightness” to sense how bright each square was and then correlated that to the magnitude of the pixel’s height.

I also correlated the zoom and overall pixel height to mouse X and mouse Y via a map.

PImage img;
float increment = 5;
float increment2 = 150;

void setup() {
  size(700, 700, P3D);
  imageMode(CENTER);
  img = loadImage("god.jpg");
  rectMode(CENTER);
}

void draw() {
  noStroke();
  background(0);
  translate(50, 50);
  rotateY(0);
  
 // pushStyle();
 // imageMode(CENTER);
 // PImage section= img.get (mouseX,mouseY,50,50);
 // image(section, mouseX,mouseY, 200, 200);
 // //translate(50,50);
  
 //popStyle();

  for (int y = 0; y<img.height; y+= increment) {           
    for (int x = 0; x <img.width; x+= increment) { 
      img.loadPixels();
int index = (x + y * img.width);
      color pix = img.pixels[index];
      fill(pix); 
      float diam = map(brightness(pix), 0, 255, 2, increment2/2);
      pushMatrix();
      translate(x, y, diam);
     float a = map (mouseX, 0,700, 0, 20);
     float b = map (mouseY, 0,700, 0, 20);
      box(increment, increment, map(a, 0, b, 0, increment2));
       
      popMatrix();
    
    }
  }
  
  
 img.updatePixels();
 
}

 

Leave a Reply