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.
IndexDiscussionExhibition › Matrix data screen effect
Page Index Toggle Pages: 1
Matrix data screen effect (Read 595 times)
Matrix data screen effect
Jun 26th, 2008, 4:15pm
 
Hey,
first post:

i wanted to replicate the screen effect from the
movie "The Matrix" as a first test for Processing.


I load up a black and white image of some text.
Random letters scroll over in different intensities.

You need to add two black and white images of size 600x400 with the names filter.PNG and filter2.PNG.
PS: It doesn't have to be text


The Code:

int speed = 1;
int counter = 0;
int nrOfRows = 30;
int nrOfCols = 44;
char screen[][];
int intensity[][];
int margin = 6;
int gap = 13;
int fontsize = 14;
PImage filter;
PImage filter2;


void setup() {
 size(600,400);
 PFont fontA = loadFont("CourierNew36.vlw");
 textFont(fontA, fontsize);
 frameRate(7);
 filter = loadImage("filter.PNG");
 filter2 = loadImage("filter2.PNG");

 screen = new char[nrOfRows][nrOfCols];
 intensity = new int[nrOfRows][nrOfCols];
 for(int i = 0; i < nrOfRows; i++)
 {
   for(int j = 0; j < nrOfCols; j++)
   {
     screen[i][j] = '0';
     intensity[i][j] = 100;
   }
 }
}

void draw(){
 counter++;
 if(counter >= speed)
 {
   counter = 0;
   background(50);
   shiftDown();
   generateNewRow();
   drawText();  
   }
}
void generateNewRow(){
 for(int j = 0; j < nrOfCols; j++)
 {
   screen[0][j] =char( 'a' + int(random(25)));
   intensity[0][j] = 100 + int(random(125));
 }
}
void drawText(){
 //based on width and height, separated the  letters
 for(int i = 0; i < nrOfRows; i++)
 {
   for(int j = 0; j < nrOfCols; j++)
   {
     color c = filter2.get(j*gap + (fontsize/2),i*gap+ (fontsize/2));
     if(screen[i][j] != '0' && red(c) == 0){
     fill(0,intensity[i][j],0);
     text(screen[i][j] , j*gap, i*gap);
     }
   }
 }

}
void shiftDown(){
 for(int i = nrOfRows-1; i> 0; i--)
 {
   for(int j = 0; j < nrOfCols; j++)
   {
     screen[i][j] = screen[i-1][j];
     intensity[i][j] = intensity[i-1][j];
   }
 }

}
Re: Matrix data screen effect
Reply #1 - Jun 26th, 2008, 8:01pm
 
live test
www.spellenplezier.be/applet/
Page Index Toggle Pages: 1