DEVELOPMENT ENVIRONMENT

~alex/mandelbrot-set-gen

ref: 7f5e734f41ff771a1336de4772b7b9ba6e7a8459 mandelbrot-set-gen/src/main.c -rw-r--r-- 773 bytes
7f5e734fAlejandro Laguna refactor: separate functions into files a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "mandelbrot.h"
#include <stdio.h>

int main() {
    int width = 800;
    int height = 600;
    int max_iter = 100;

    double x_min = -2.0, x_max = 1.0;
    double y_min = -1.2, y_max = 1.2;

    // PPM header (P3 = ASCII, width, height, max color value)
    printf("P3\n%d %d\n255\n", width, height);

    for (int py = 0; py < height; py++) {
        for (int px = 0; px < width; px++) {
            double cr = x_min + (x_max - x_min) * px / (width - 1);
            double ci = y_min + (y_max - y_min) * py / (height - 1);
            int iter = mandelbrot_iterations(cr, ci, max_iter);
            int r, g, b;
            get_color(iter, max_iter, &r, &g, &b);
            printf("%d %d %d ", r, g, b);
        }
        printf("\n");
    }
    return 0;
}