Skip to content

Instantly share code, notes, and snippets.

@sleibrock
Created August 16, 2017 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sleibrock/13cd2f8cf155ebdc82f9914ee8e58ca0 to your computer and use it in GitHub Desktop.
Save sleibrock/13cd2f8cf155ebdc82f9914ee8e58ca0 to your computer and use it in GitHub Desktop.
Basic Mandelbrot Loop
unsigned char iter;
for(unsigned int y=0; y < h; y++)
{
for(unsigned int x=0; x < w; x++)
{
iter = 0;
z_re = 0;
z_im = 0;
z_re2 = 0;
z_im2 = 0;
while(z_re2 + z_im2 < THRESHOLD && iter++ < MAX_ITERS)
{
z_re2 = z_re * z_re;
z_im2 = z_im * z_im;
z_im = (2.0 * z_re * z_im) + c_im;
z_re = z_re2 - z_im2 + c_re;
}
c_re += inc_re;
ofs << iter << iter << iter;
}
c_re = init_re;
c_im += inc_im;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment