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 › A Bilboard like effect. Moving Billboard problem.
Page Index Toggle Pages: 1
A Bilboard like effect. Moving Billboard problem. (Read 1573 times)
A Bilboard like effect. Moving Billboard problem.
May 14th, 2010, 6:02pm
 
Hi , i am doing this sketch
...


http://www.openprocessing.org/visuals/?visualID=9715



So what i want to do is this :


I want the firs row to be a row like anyone  of the current sketch , that means , equally placed , but random size and random opacity.


But then i want this row to move down to the next row , and then to the next and so on.


After the first row passes to the second , another random row is created in the first row.


The effect is the same you can see here in the text , the lower one , where the text moves from right to left, but i want to do it as if the movement is  going down :

http://www.youtube.com/watch?v=T5m9WXbgJzg&feature=related



Any ideas


heres the code

Code:

int c_opacity ;



void setup (){
size ( 400 , 800 );
smooth ();
background (255);
frameRate (3);


}


void draw (){
background (255);
int c_r = width/20;

for ( int x = c_r/2 ; x<width ; x+= width/20){
for ( int y = c_r/2 ; y<height ; y+= height/40 ){
fill (0);
//ellipseMode (CENTER);
drawC ( x,y,int (random(c_r)),int (random(c_r)));




}
}
}



void drawC (int x, int y, int r ,int r2) {
noStroke ();
fill ( #ff0044,int( random (255)));
ellipse (x,y,r,r);
}



This is the image that inspired me :

...
Re: A Bilboard like effect. Moving Billboard problem.
Reply #1 - May 15th, 2010, 1:13am
 
You need an array of 20 rows holding each an array of 20 columns.
You create a class just to hold the values of each dot: the random numbers you draw for opacity and radius (the r2 parameter seems unused).
So on first frame you create the first row, storing the values in the column array.
Then on each next (nth) frame, you "slide" down the values (assigning row n to row n+1).
And you draw all rows you have in the array, skipping the row if it is null (not assigned yet).
Re: A Bilboard like effect. Moving Billboard problem.
Reply #2 - May 15th, 2010, 10:32am
 
Thanx philHo , i think i got the first part , but i dont know how to make it slide ,


any clues ??

here my new code :


Code:
int r_c ;
int ranC ;

void setup (){
size ( 400 , 800 );
smooth ();
background (255);
frameRate (12);


}


void draw (){
background (25);
r_c = width/20 ;

for ( int x= r_c/2 ; x<width ; x+= width/20){

drawC(x);

// for ( int y= r_c/2 ; y<height ; y+= height/20){
// drawC(x);



}
}







void drawC (int x) {
ranC = int ( random (r_c));
noStroke ();
fill ( #ff0044);
ellipse (x, r_c,ranC,ranC);
}

Re: A Bilboard like effect. Moving Billboard problem.
Reply #3 - May 15th, 2010, 11:12am
 
you didnt create a class nor did you create some arrays that hold the information like PhiLho suggested. You randomly recreate it every frame but you have to store it in arrays.
I have to leave, but i will give some more information and examples when i am back. but read about arrays here : http://processing.org/reference/Array.html  and classes here : http://processing.org/reference/class.html
if this is new to you.

Re: A Bilboard like effect. Moving Billboard problem.
Reply #4 - May 15th, 2010, 11:39am
 
yes its true     Shocked  ,  i realised , that , ill try again with arrays


thanx cedric    Wink


Re: A Bilboard like effect. Moving Billboard problem.
Reply #5 - May 15th, 2010, 1:34pm
 
PhiLho  wrote on May 15th, 2010, 1:13am:
You need an array of 20 rows holding each an array of 20 columns.
You create a class just to hold the values of each dot: the random numbers you draw for opacity and radius (the r2 parameter seems unused).
So on first frame you create the first row, storing the values in the column array.
Then on each next (nth) frame, you "slide" down the values (assigning row n to row n+1).
And you draw all rows you have in the array, skipping the row if it is null (not assigned yet).



Allright , ill try that , so i need to do a class for the circle with random size and color,

then an array for the rows and then another array for the columns


right


Re: A Bilboard like effect. Moving Billboard problem.
Reply #6 - May 15th, 2010, 2:00pm
 
hmm my first thought was to create a class that holds the size and transparency, but you can actually create just two arrays. you dont need to create a class.
I made a sketch, look at it and try to understand what i did.
There are probably better ways to copy an array, but its easy to understand.

I fill both 2d arrays for size and transparency in setup and then, copy each row to the next row and refill the first row with random data.


hope that helps.

Code:
int cols = 20 ;
int rows = 30;
float[][] size = new float[cols][rows];
float[][] trans = new float[cols][rows];

void setup() {
 size(400,600);
 smooth();
 background(0);
 for(int i =0; i<cols; i++){
   for(int j =0; j<rows; j++){
size[i][j] = random(2,15);
trans[i][j] = random(20,255);
   }
 }
 noStroke();
 frameRate(10);
}


void draw() {

 background(0);
 fill(255,0,0);
 for(int i =0; i<cols; i++){
   for(int j =0; j<rows; j++){
fill(255,0,0,trans[i][j]);
ellipse(i*(width/cols+1),j*(height/rows+1),size[i][j],size[i][j]);
   }
 }
shift();
}


void shift(){

 //copy the rows
 for(int i =0; i<cols; i++){
   for(int j =rows-1; j>0; j--){
trans[i][j] = trans[i][j-1];  
size[i][j] = size[i][j-1];  

   }
 }
 //fill the first row with new random data
  for(int i =0; i<cols; i++){
    size[i][0] = random(2,15);
   trans[i][0] = random(20,255);
  }

}



Re: A Bilboard like effect. Moving Billboard problem.
Reply #7 - May 15th, 2010, 3:26pm
 
Awesome , ill try to understand it , but it looks allready pretty beautifull to me.

thanx !!!!   Smiley Smiley Smiley Smiley
Page Index Toggle Pages: 1