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 › Buddhabrot 2.0
Page Index Toggle Pages: 1
Buddhabrot 2.0 (Read 2098 times)
Buddhabrot 2.0
Jul 8th, 2009, 3:47pm
 
Hi there Smiley
I'm new here but I use- or rather try to use processing since a while now.

I'm reworking Buddhabrot - a processing program of J. Tarbell, who based his Version on an even older implementation by Paul Bourke.
Buddhabrot is a modified way to look at the Mandelbrot-set, as discovered and described by Melinda Green.


After several problems ( a) I can't yet post links and b) the 6000 character limit), I'll now post the source in several sections. I hope you like it Smiley
Re: Buddhabrot 2.0
Reply #1 - Jul 8th, 2009, 3:47pm
 
// Buddhabrot
// j.tarbell   January, 2004
// Albuquerque, New Mexico
// complexification.net

// based on code by Paul Bourke
// astronomy.swin.edu.au/~pbourke/

// Processing 0085 Beta syntax update
// j.tarbell   April, 2005

// Processing 0105 syntax update, simplify and added features*
// m.faderbauer June, 2009


//* changelog see bottom

// main setup settings
int dimy = 1681;            // screen width 1681
int dimx = 1019;            //screen height 1019
int bailout = 2000;         // number of iterations before bail
int plots = 171294;        // number of plots to execute per frame (x30 = plots per second) 171294
//zoom/magnification
float magx = 3.0; // default 3.0, smaller means more zoom
float magy = magx*(dimy/float(dimx));
//pan
float panx = 0.0; //default is 0.5
float pany = 0.0; //default is 0.0
//brightness multiplier
float brt = 1.0; // brightness factor

// 2D array to hold exposure values
int[] exposure = new int[dimx*dimy];
int maxexposure;           // maximum exposure value
int time = 0;
int exposures = 0;

 float x, y;
 float x0, y0;

boolean drawing;
Re: Buddhabrot 2.0
Reply #2 - Jul 8th, 2009, 3:48pm
 
//  MAIN ----------------------------------------------------------------

int sgn(float value) {            //if signus is needed sgn(x)=x/abs(x) = 1, 0 or -1
 if (value < 0) {return -1;}
 if (value > 0) {return 1;}
 return 0;
}

float cosh(float value1) {
 return 0.5*(exp(value1)+exp(-value1));
}

float sinh(float value2) {
 return 0.5*(exp(value2)-exp(-value2));
}

float arg(float axis1, float axis2) {
 if (axis2==0) {return PI;}
 else {return -atan(axis1/axis2)+PI*sgn(axis2)*0.5;}
}

float spharg(float axisa, float axisb, float axisc) {
 return acos(axisc/sqrt(sq(axisa)+sq(axisb)+sq(axisc)));
}

void setup() {
 // set up drawing area
 size(dimy,dimx,P3D);
}

void draw() {
 plotPlots();
 time++;
 if (time%1==0) { //every second
   findMaxExposure();
   renderBrot();
 }
}



void plotPlots() {

 // iterate through some plots
 for (int n=0;n<plots;n++) {
   // Choose a random point in same range
   x = random(-2.0,1.0);
   y = random(-1.5,1.5);
   x0 = random(-2.0,2.0);
   y0 = random(-2.0,2.0);
   if (iterate(x,y,false)) {
     iterate(x,y,true);
     exposures++;
   }
 }
}

void renderBrot() {
 colorMode(RGB,1.0);
 // draw to screen
 for (int i=0;i<dimx;i++) {
   for (int j=0;j<dimy;j++) {
     float ramp = brt * exposure[i*dimy+j] / maxexposure;
     // blow out ultra bright regions
     if (ramp > 1)  {
       ramp = 1;
     }
     //different shading formulae
     //color c = color(pow(ramp,0.45454545454545454545),pow(ramp,0.45454545454545454545),pow(ramp
,0.45454545454545454545)); //default greyscale
     color c = color(pow(ramp,0.413223140495867768595041322314049586776859504132231404958677685
950413223140495867769),pow(ramp,0.45454545454545454545),pow(ramp,0.3787878787878
78787878787878787878787878787878787878787878787878787878787878787878788)); //purple touch
     //color c = color(pow(sin(ramp*1.57079632679489661923132169163975144209858469968755291048747
2296153908203143104499314),0.4),pow(ramp,0.75),pow(ramp,2.5)); // sunset
     //color c = color(pow(sin(ramp*1.57079632679489661923132169163975144209858469968755291048747
2296153908203143104499314),0.45454545455),pow(ramp,17/11.0),pow(ramp,109/55.0));
// "love"
     set(j,i,c);
   }
 }
}
Re: Buddhabrot 2.0
Reply #3 - Jul 8th, 2009, 3:50pm
 
//   Iterate the Mandelbrot and return TRUE if the point exits
//   Also handle the drawing of the exit points
boolean iterate(float x0, float y0, boolean drawIt) {
 float x = 0.0;
 float y = 0.0;
 //float t = random(0,1);
 //float r = random(0,1);  


 //x0 = 0.0;
 //y0 = 0.0;
 
 float xnew, ynew;
 int ix,iy;

 for (int i=0;i<bailout;i++) {
   
   //set your costum formula here...
   //example:
   /* //default Mandelbrot
   xnew = x * x - y * y + x0;
   ynew = 2 * x * y + y0;
   */
   //...
if (drawIt && (i > 3)) {
     ix = int(dimx*(panx+xnew+magx/2.0)/magx);
     iy = int(dimy*(pany+ynew+magy/2.0)/magy);
     
     if (ix >= 0 && iy >= 0 && ix < dimx && iy < dimy) {
       // rotate and expose point
       exposure[ix*dimy+iy]++;
     }

   }
   if ((xnew*xnew + ynew*ynew) > 4) {
     // escapes
     return true;
   }
   x = xnew;
   y = ynew;
 }
 // does not escape
 return false;
}

void findMaxExposure() {
 // assume no exposure
 maxexposure=0;
 // find the largest density value
 for (int i=0;i<dimy;i++) {
   for (int j=0;j<dimx;j++) {
     maxexposure = max(maxexposure,exposure[i*dimx+j]);
   }
 }
}
Re: Buddhabrot 2.0
Reply #4 - Jul 8th, 2009, 3:50pm
 
// Buddhabrot
//http://www.superliminal.com/fractals/bbrot/bbrot.htm
// j.tarbell   January, 2004
// m.faderbauer June, 2009
//_____________________________________________________________
//Changelog:
//_____________________________________________________________
//simplifyed code, cutting out unnessecary stuff
//changed code to allow variable output dimensions
//added shift to render different regions
//added magnify to zoom (not the best solution)
//switched RGB from 8bit to normalized float (0-1)
//added gamma to gradient &
//added gradient variations
// -> made overboost of brightness variable, as
// better gradients don't need cut-offs of info
//
//added different formulasets, doing Buddhabrot-
// like renders of different IFSs
//added sgn() [returns the signus of a number:]
//            [<0 -> -1; ==0 -> 0; >0 -> 1    ]
//added cosh() and sinh() - the hyperbolic sine and cosine
//added arg() and spharg() - argument on a circle or a sphere
//______________________________________________________________
//ToDo:
//save the file without poor screenshot and save
//possibility to directly mix a three channeled
// picture, based on bailout values (rendering
// once for a picture like Melinda Green's
// original colouring version, rather than
// trice, once for each channel)
//allowing true complex numbers
//allowing also the "buddhagram"
// ( http://www.superliminal.com/fractals/bgram/ZrZiOut.htm )
//rotating the set (4D rotation)
//optimizing
//UI & GUI
//  with preset formulae to switch the image and the colours
//  for instance, the general form of Mset^5
//  az^5+bz^4+cz^3+dz^2+ez+f
//  and a possibility to add ANY other formula - maybe just a
//  little script window, where no programming skills are needed.
//gimmick
//  instead of current hardcoded navigation, a preview window
//  to zoom in and out, rotate as wanted and also pan around.
Re: Buddhabrot 2.0
Reply #5 - Jul 8th, 2009, 3:54pm
 
Now that I have 5 posts, it should be possible to link you to the current results:
http://kram1032.deviantart.com/gallery/#Fractals
all of the pictures, you'll find in that section, except two, are made with my modified version of buddhabrot.

Here is Melinda Green's Page about Buddhabrot:
http://www.superliminal.com/fractals/bbrot/bbrot.htm

and there is, where I found my original source:
http://www.complexification.net/gallery/machines/buddhabrot/appletm/buddhaBrot_m.pde

The ToDo in my former post is rather a wishlist... but if anyone can help me with any of the points, I'd be very happy Smiley
Re: Buddhabrot 2.0
Reply #6 - Jul 8th, 2009, 5:57pm
 
These are really beautiful!
Re: Buddhabrot 2.0
Reply #7 - Jul 9th, 2009, 5:09am
 
Thanks Smiley
Page Index Toggle Pages: 1