Zebra Mandelbrot
This is made just for fun. It is a linear interpolation between Julia and Mandelbrot
Sets using iteration number (0=Julia, ITERMAX=Mandelbrot). Code:
x0 = -1 + 2*(i / double(W));
y0 = -1 + 2*(j / double(H));
c0x = -0.93;//19;//2.5 + 3.5*(i / double(W));
c0y = 0.19;//1.25 + 2.5*(j / double(H));
x = x0;
y = y0;
s = 0;
while (s < ITERMAX && x*x+y*y < 5)
{
t = s/(float)ITERMAX;
addx = t*x0 + (1-t)*c0x;
addy = t*y0 + (1-t)*c0y;
y0 = -1 + 2*(j / double(H));
c0x = -0.93;//19;//2.5 + 3.5*(i / double(W));
c0y = 0.19;//1.25 + 2.5*(j / double(H));
x = x0;
y = y0;
s = 0;
while (s < ITERMAX && x*x+y*y < 5)
{
t = s/(float)ITERMAX;
addx = t*x0 + (1-t)*c0x;
addy = t*y0 + (1-t)*c0y;
xt = x*x-y*y+addx;
yt = 2*x*y +addy;
x=xt;
y=yt;
s++;
}
float c = 255*float(s)/ITERMAX;
if(c > 255) c = 255;
img[(i+j*W)*3+0] = c;
img[(i+j*W)*3+1] = c;
img[(i+j*W)*3+2] = c;
No comments:
Post a Comment