[ create a new paste ] login | about

Link: http://codepad.org/rjbEHryH    [ raw code | fork ]

joel_f - C++, pasted on Feb 17:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <complex>  
void Mandelbrot(float x1, float y1, float x2, float y2,   
                   int width, int height, int maxIters, unsigned short * image)  
{  
    float dx = (x2-x1)/width, dy = (y2-y1)/height;  
    for (int j = 0; j < height; ++j)  
        for (int i = 0; i < width; ++i)  
        {  
            complex<float> c (x1+dx*i, y1+dy*j), z(0,0);  
            int count = -1;  
            while ((++count < maxIters) && (norm(z) < 4.0))  
                z = z*z+c;  
            *image++ = count;  
        }  
} 


Create a new paste based on this one


Comments: