We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › display arrays of images and pixels with the mouse
Page Index Toggle Pages: 1
display arrays of images and pixels with the mouse (Read 1812 times)
display arrays of images and pixels with the mouse
Jun 9th, 2010, 9:26pm
 
Hy i´m new with processing and i wonder if you could help me.
I need to display pixlels from 9 images with the mouse and then show the 10 and repeat the exact same process with the others (rom 10 to 18). Here´s the code.  hope u could help me!



PImage[] images = new PImage[9];
int cantImagenes = 9;

int[][] capas;
boolean[][] antes;

int ancho = 800;
int alto = 600;

PImage pantalla;

void setup(){
 size(ancho,alto);

 capas = new int[ancho][alto];
 antes = new boolean[ancho][alto];

 for(int i=0;i<images.length;i++){
   //String s = "g"+(i+1)+".jpg";
   String s = (i+1)+".jpg";
   images[i] = loadImage(s);
 }

 pantalla = createImage( ancho , alto , RGB );
 pantalla.copy( images[0] , 0 , 0 , ancho , alto , 0 , 0 , ancho , alto );

 background(0);
}
void draw(){

 image( pantalla , 0 , 0 );

 for( int i=0 ; i<ancho ; i++ ){
   for( int j=0 ; j<alto ; j++ ){
   
     if( dist(i,j,mouseX,mouseY) < 50 ){ //esta el mouse encima
     
       if( !antes[i][j] ){ //entro en este fotograma
         if( capas[i][j] < 8 ){
           capas[i][j]++;
           
           int cualCapa = capas[i][j];
           color c = images[ cualCapa ].get(i,j);
                       
           pantalla.set( i , j , c );
         }
       }
       
       antes[i][j] = true;
     }else{ // NO esta el mouse encima
       antes[i][j] = false;        
     }
     
     
     
   }
 }
}
Re: display arrays of images and pixels with the mouse
Reply #1 - Jun 10th, 2010, 1:40am
 
http://processing.org/discourse/yabb2/?num=1276129560
Page Index Toggle Pages: 1