use 256 shades of grey

master
neingeist 12 years ago
parent 7dc7d474f8
commit 13b3971d3e

@ -2,12 +2,15 @@
#include <complex.h> #include <complex.h>
#include <stdbool.h> #include <stdbool.h>
/* The maximum iteration count. */
const int max_it = 170;
/* Compute the out-coloring based on the iteration counter. */ /* Compute the out-coloring based on the iteration counter. */
Uint32 outcolor(int it) { Uint32 outcolor(int it) {
return 0x00010001 * it; return 0x00010001 * ((it * 0xff) / max_it);
} }
/* Compute the in-coloring. */ /* "Compute" the in-coloring. */
Uint32 incolor() { Uint32 incolor() {
return 0x00000000; /* black */ return 0x00000000; /* black */
} }
@ -28,7 +31,6 @@ void drawmandelbrot(SDL_Surface *surface) {
bool diverges = false; bool diverges = false;
float complex z = 0; float complex z = 0;
int it; int it;
const int max_it = 170;
for (it = 1; it <= max_it; it++) { for (it = 1; it <= max_it; it++) {
/* z = z² + c */ /* z = z² + c */
z = cpowf(z, 2) + c; z = cpowf(z, 2) + c;

Loading…
Cancel
Save