more mandelbrot

master
neingeist 12 years ago
parent 1e6f8726a6
commit cb4baa4479

@ -1,11 +1,16 @@
CFLAGS=-std=c99 -Wall -g
INDENTOPTS=-kr --no-tabs --braces-on-func-def-line --indent-level2
all: approximate-pi linked-list
.PHONY: all
all: approximate-pi linked-list mandelbrot
.PHONY: clean
clean:
rm -f approximate-pi linked-list *~
rm -f approximate-pi linked-list mandelbrot *~
.PHONY: indent
indent:
indent $(INDENTOPTS) *.c
mandelbrot: mandelbrot.c
$(CC) $(CFLAGS) $(shell sdl-config --cflags) -o $@ $< $(shell sdl-config --libs) -lm

@ -22,8 +22,8 @@ int main(int argc, char *argv[]) {
printf("y = %d\n", y);
}
float complex c = (3.0 * x / 640.0) - 2.0
+ I * ((2.0 * y / 480.0) - 1.0);
float complex c = ((3.0 * x / screen->w) - 2.0)
+ I * ((2.0 * y / screen->h) - 1.0);
bool diverges = false;
float complex z = 0;
@ -36,17 +36,21 @@ int main(int argc, char *argv[]) {
}
}
Uint32 color = 0x00000000;
Uint32 color;
if (diverges) {
color = 0x01010101 * it;
color = 0x00020304 * it;
} else {
color = 0x00000000;
}
pixels[i] = color;
if (y % 10 == 0)
SDL_Flip(screen);
}
if (SDL_MUSTLOCK(screen)) {
SDL_UnlockSurface(screen);
}
SDL_Flip(screen); /* XXX */
SDL_Flip(screen);
SDL_Delay(20000);

Loading…
Cancel
Save