Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double re = -0.235125;
- double imag = 0.827215;
- double r = 4.0e-5;
- const int maxIters = 2048;
- double c_re;
- double c_im;
- double x;
- double y;
- int iteration;
- const double c1 = 4.0/width*r;
- const double c2 = width/2.0*c1;
- const double c3 = height/2.0*c1;
- double xx;
- double yy;
- for(int row = 0; row < height; row++){
- c_im = imag + (row * c1) - c3;
- for(int col = 0; col < width; col++){
- c_re = re + (col * c1) - c2;
- x = 0; y = 0;
- iteration = 0;
- do {
- xx = x*x;
- yy = y*y;
- y = x*y;
- y += y;
- y += c_im;
- x = xx - yy + c_re;
- iteration++;
- }while(xx+yy <= 4 && iteration < maxIters);
- if(iteration < maxIters){
- //Calculate a color from the value of the "iteration" variable and set the pixel color to that
- //I use int rgb = HSBtoRGB((float)iteration/256.0f, 1.0f, (float)iteration/(iteration+8.0f));
- //But idk if that's a thing in JS
- }else{
- //pixel Color = black (RGB 0,0,0)
- }
- }
- PORTD ^= (1 << PD4);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement