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 › 64-bit images - Just for fun project
Page Index Toggle Pages: 1
64-bit images - Just for fun project (Read 4562 times)
64-bit images - Just for fun project
Jun 18th, 2010, 12:35pm
 
So last night i was scrolling through the sample for "Processing: a programming handbook for visual designers and artists" to see what it's about and the interview with Jared Tarbell really caught my eye with his "Fractal.Invaders" and i remember trying to do something like it myself some years ago but failing badly, basically my idea was to do it all with one "big" recursive function - long story short: Stack overflow.

Anyways, so i thought "hey lets try it again, i must be able to come up with some smart way of doing it" and as it turns out i was. So i thought i'd share what i came up with:

Code:

int number;
int rectWidth;
int offset;
void setup(){
 size(800,800);
 background(255);
 fill(0);
 noStroke();
 number = 1515175624; //magic constant!
 offset = 5; //ofset from the edge of the window.. sort of
 rectWidth = height/8-offset; // width of the boxes
}

void draw(){
 background(255);
 int temp = number;
 for(int y = 0; y < 8;y++){
   for(int x = 0; x < 4;x++){
     if(temp%2 == 0){
       fill(255);
     }else{
       fill(0);
     }
     rect(offset*4+(width-height)/2+x*rectWidth,offset*4+y*rectWidth,rectWidth,rectWidth);
     rect(-(width-height)/2-offset*4+width-(x+1)*rectWidth,offset*4+y*rectWidth,rectWidth,rectWidth);
     temp = temp >>1;
   }
 }
//number = int(random(-(MAX_INT)))+int(random((128))); //uncomment this - shit brix
}

void mousePressed(){
 number = int(random(-(MAX_INT)))+int(random((128)));
}


I'd like to point out that while the code is indeed mine, the idea of mirroring the random-pattern to create space invader-like creature belongs to Jared (as far as i can tell). This code is just my solution to the program he described. Also i haven't actually seen Jared's source code for it was in .fla format and im still downloading flash.
There, just wanted to point that out so no one is offended or confused :)


Usage: Click to create a new random thingy.
Page Index Toggle Pages: 1