FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Information Visualization
(Moderators: forkinsocket, REAS)
   Mandelbrot Zoomer
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Mandelbrot Zoomer  (Read 855 times)
Jerronimo

WWW
Mandelbrot Zoomer
« on: Sep 1st, 2003, 6:03pm »

I started working on a mandelbrot zoomer...
 
http://www.cis.rit.edu/~sdlpci/Software/p5/mandelzoom/mandelzoom.pde
 
but I got lost in the math to do the actual zooming... well, really the math to figure out where the cursor is in the mandelbrot itself.
 
I've never worked with mandelbrots before, so any input would be awesome.  
 
Oh, I also have a small routine in there which does gradients of colors for the palette.  It might be useful to someone out there.  
« Last Edit: Sep 2nd, 2003, 9:38pm by Jerronimo »  
rgovostes

rgovostes
Re: Mandelbrot Zoomer
« Reply #1 on: Oct 7th, 2003, 3:32am »

I am sorry I could not be of assistance with your original problem, but I thought I'd post that I used your gradient code as a basis to a new system.
 
You just call addToPalette() each time you want to add another gradient to the palette. The parameters are:
     int count - The number of steps it should take to fade between the colors
     color colorA - The beginning color, to fade from
     color colorB - The ending color, to fade to
 
Code:
color palette[] = new color[0];
void addToPalette(int count, color colorA, color colorB) {
  float r1 = red(colorA);   float r2 = red(colorB);
  float g1 = green(colorA); float g2 = green(colorB);
  float b1 = blue(colorA);  float b2 = blue(colorB);
   
  color neopalette[] = new color[palette.length + count];
  System.arraycopy(palette, 0, neopalette, 0, palette.length);  
   
  for (int i = palette.length; i < (palette.length + count); i ++) {
    float a = float(i - palette.length) / float(count);
    float b = 1 - a;
    neopalette[i] = color(r2 * a + b * r1, g2 * a + b * g1, b2 * a + b * b1);
  }
   
  palette = neopalette;
}

 
If you want to clear the palette and start over, just run that first line again.
 
Cheers.
« Last Edit: Oct 7th, 2003, 3:43am by rgovostes »  
JohnG

WWW
Re: Mandelbrot Zoomer
« Reply #2 on: Oct 7th, 2003, 11:59am »

on Sep 1st, 2003, 6:03pm, Jerronimo wrote:
I started working on a mandelbrot zoomer...
 
http://www.cis.rit.edu/~sdlpci/Software/p5/mandelzoom/mandelzoom.pde
 
but I got lost in the math to do the actual zooming... well, really the math to figure out where the cursor is in the mandelbrot itself.
 
I've never worked with mandelbrots before, so any input would be awesome.  
 
Oh, I also have a small routine in there which does gradients of colors for the palette.  It might be useful to someone out there.  

 
Sorry for the slow reply, I managed to miss this message first time around.
 
The way to calculate the mouse point in real world co-ordinates can be hard to get your head around, but I think this will work:
 
float mx = ((xmax-xmin) / width) * mouseX + xmin;
float my = ((ymax-ymin) / height) * mouseY + ymin ;
 
The first 3 variables work out how wide each pixel is, e..g if xmax is 1 and xmin is -1, you get 2/width.
So if width is 200 that's 2/200 = 0.01. so if the mouse is at (100,100), that's 100*0.01 == 1. Then add that on to the value whem mouseX==0 (I.e. xmin), you get 1+(-1) == 0, so the middle will work out right, as being (0,0) in fractal co-ordinates.
As long as you can work out the xmax/xmin/ymax/ymin this should work fine for about 20 zooms, until you start getting to the point where floats start being of limited precision.
 
shadeone

WWW
Re: Mandelbrot Zoomer
« Reply #3 on: Nov 5th, 2003, 8:33pm »

hello
 
i've noticed on many sources i've found the instruction :  setPixel( value, value, value );
 
BUT
 
my processing cannot compile. i've got the error :  
 
Semantic Error: No method named "setPixel" was found in type "Temporary_2988_3386".
 
someone can help me ? my version is not up to date ?
 
thank you
 
rgovostes

rgovostes
Re: Mandelbrot Zoomer
« Reply #4 on: Nov 5th, 2003, 11:47pm »

The latest versions of processing use 'set' instead of 'setPixel'.
 
shadeone

WWW
Re: Mandelbrot Zoomer
« Reply #5 on: Nov 6th, 2003, 2:04pm »

yes, i noticed that. thank you for the quick answer anyways.
 
Pages: 1 

« Previous topic | Next topic »