FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Getting strated... help needed.
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Getting strated... help needed.  (Read 568 times)
Arsis

WWW Email
Getting strated... help needed.
« on: Dec 21st, 2002, 10:36pm »

OK I'm trying to code a file that interprets images and rerenders them usinf different size rects:
 
size(230, 366);
 
BImage depths;  
int[][] depthPixels = new int[230][366];  
 
BImage colors;  
int[][] colorPixels = new int[230][366];  
 
 
depths = loadImage("levels.gif");  
image(depths, 0, 0);  
for(int i=0; i<366; i++) {  
  for(int j=0; j<230; j++) {  
    depthPixels[j][i] = pixels[i*width+j];  
  }  
}  
  
colors = loadImage("man.gif");  
image(colors, 0, 0);  
for(int i=0; i<366; i++) {  
  for(int j=0; j<230; j++) {  
   colorPixels[j][i] = pixels[i*width+j];  
  }  
}
fill(0);
rect(0,0,230,366);
 
for(int i=0; i<366; i=i+10) {  
  for(int j=0; j<230; j=j+10) {
    fill(colorPixels[j][i]);
    noStroke();
    float size = depthPixels[j][i]/1200000;  
    rect(j,i,size,size);  
  }  
}
 
 
This all works fine until I try and use void setup() and void loop(). Whenever I put the size(320,366) into void setup() all my variables break.  
 
// store z depth for each pixel
BImage depths;  
int[][] depthPixels = new int[230][366];  
depths = loadImage("levels.gif");  
image(depths, 0, 0);  
for(int i=0; i<366; i++) {  
  for(int j=0; j<230; j++) {  
    depthPixels[j][i] = pixels[i*width+j];  
  }  
}  
 
// store color for each pixel
BImage colors;  
int[][] colorPixels = new int[230][366];  
colors = loadImage("man.gif");  
image(colors, 0, 0);  
for(int i=0; i<366; i++) {  
  for(int j=0; j<230; j++) {  
   colorPixels[j][i] = pixels[i*width+j];  
  }  
}
 
// clear screen
fill(0);
rect(0,0,230,366);
 
void setup()  
{  
  size(230, 366);  
  background(49,114,151);  
  stroke(255);  
}  
 
void loop()  
{  
  for(int i=0; i<366; i=i+10) {  
    for(int j=0; j<230; j=j+10) {
 fill(colorPixels[j][i]);
 noStroke();
 float size = depthPixels[j][i]/1200000;  
 rect(j,i,size,size);  
    }  
  }
}  
 
How would I structure this code so I can animate the output...
 
This is my first attempt at using proce55ing so I am sure I have overlooked something simple.
 
TIA  
Arsis
« Last Edit: Dec 21st, 2002, 10:56pm by Arsis »  

Social Dichotomy: While I'm gone please be note to the care of my love, as she apts to be sticked by dusts and hand-fat.
fry


WWW
Re: Getting strated... help needed.
« Reply #1 on: Jan 2nd, 2003, 5:58pm »

i don't see anything obviously wrong with the code (though i'm not entirely clear what you want to do) what do you mean by the variables 'break'?
 
Pages: 1 

« Previous topic | Next topic »