Processing – Utopia

PImage img;       
int cellsize = 2;
int columns, rows;   

void setup() {
  size(800, 1260, P3D); 
  img = loadImage("utopia.jpg");  
  columns = img.width / cellsize;  
  rows = img.height / cellsize;  
}

void draw() {
  background(0);
  
  for ( int i = 0; i < columns; i++) {
    
    for ( int j = 0; j < rows; j++) {
      int x = i*cellsize + cellsize/2;
      int y = j*cellsize + cellsize/2;  
      int loc = x + y*img.width;  
      color c = img.pixels[loc];  
     
      float z = (mouseX / float(width)) * brightness(img.pixels[loc]) - 20.0;
      
      pushMatrix();
      translate(x + 200, y + 100, z);
      fill(c, 204);
      noStroke();
      rectMode(CENTER);
      rect(0, 0, cellsize, cellsize);
      popMatrix();
    }
  }
}
Advertisements

About Michael Hunter Photography

Photographer from glasgow
This entry was posted in Uncategorized. Bookmark the permalink.

One Response to Processing – Utopia

  1. zemra76 says:

    all your pics are really good!!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s