FAQ
 
 
Cover  \ Exhibition  \ Learning  \ Reference  \ Download  \ Discourse   
    Examples \ Tutorials \ Courses & Workshops
 
   
 
 
Examples for Processing (BETA) version 91+. If you have a previous version, use the examples included with your software. If you see any errors or have comments, please let us know.



Extrusion
by REAS <http://reas.com>

Converts a flat image into spatial data points.

Created 18 August 2002

   
// Extrusion 
// by REAS <http://reas.com> 

PImage a; 
boolean onetime = true; 
int[][] aPixels; 
int[][] values; 
float angle; 
 
void setup() 
{ 
  size(200, 200, P3D); 
  framerate(24); 
  
  aPixels = new int[width][height]; 
  values = new int[width][height]; 
  noFill(); 
 
  // Load the image into a new array 
  // Extract the values and store in an array 
  a = loadImage("ystone08.jpg"); 
  for(int i=0; i<height; i++) { 
    for(int j=0; j<width; j++) { 
      aPixels[j][i] = a.pixels[i*width + j]; 
      values[j][i] = int(blue(aPixels[j][i])); 
    } 
  } 
  framerate(30); 
} 
 
void draw() 
{ 
  background(255); 
  
  // Update and constrain the angle 
  angle += 0.005; 
  if(angle > TWO_PI) { angle = 0; } 
  
  // Rotate around the center axis 
  translate(width/2, 0, 128); 
  rotateY(angle);  
  translate(-width/2, 0, 128); 
  
  // Display the image mass 
  for(int i=0; i<height; i+=2) { 
    for(int j=0; j<width; j+=2) { 
      stroke(values[j][i]); 
      point(j, i, -values[j][i]); 
    } 
  } 
} 
 







   
  Processing is an open project initiated by Ben Fry and Casey Reas  
  © Info