Created
March 20, 2009 16:15
-
-
Save syoyo/82421 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
surface | |
mandel() | |
{ | |
float window_size = 512.0; | |
float xx, yy; | |
float x0, y0; | |
float max_iter = 255; | |
float iter = 0; | |
float tmp; | |
float zoom = 2.0 * window_size; | |
xx = -zoom * (s - 0.5) / window_size; | |
x0 = -zoom * (s - 0.5) / window_size; | |
yy = zoom * (t - 0.5) / window_size; | |
y0 = zoom * (t - 0.5) / window_size; | |
while ( ((xx * xx + yy * yy) <= (2.0*2.0)) && (iter < max_iter)) { | |
tmp = xx * xx - yy * yy + x0; | |
yy = 2.0 * xx * yy + y0; | |
xx = tmp; | |
iter = iter + 1; | |
} | |
if (iter == max_iter) { | |
Ci = color(0, 0, 0); | |
} else { | |
Ci = color(iter / 255.0, iter / 255.0, iter / 127.0); // make result bluish a bit. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment