MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / main

Function main

examples/graphics/fractal.cpp:67–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65}
66
67int main(int argc, char **argv) {
68 int device = argc > 1 ? atoi(argv[1]) : 0;
69 int iter = argc > 2 ? atoi(argv[2]) : 100;
70 bool console = argc > 2 ? argv[2][0] == '-' : false;
71 try {
72 af::setDevice(device);
73 info();
74 printf("** ArrayFire Fractals Demo **\n");
75 af::Window wnd(WIDTH, HEIGHT, "Fractal Demo");
76 wnd.setColorMap(AF_COLORMAP_SPECTRUM);
77
78 float center[] = {-0.75f, 0.1f};
79 // Keep zomming out for each frame
80 for (int i = 10; i < 400; i++) {
81 int zoom = i * i;
82 if (!(i % 10)) {
83 printf("iteration: %d zoom: %d\n", i, zoom);
84 fflush(stdout);
85 }
86
87 // Generate the grid at the current zoom factor
88 array c = complex_grid(WIDTH, HEIGHT, zoom, center);
89
90 iter = sqrt(abs(2 * sqrt(abs(1 - sqrt(5 * zoom))))) * 100;
91 // Generate the mandelbrot image
92 array mag = mandelbrot(c, iter, 1000);
93
94 if (!console) {
95 if (wnd.close()) break;
96 array mag_norm = normalize(mag);
97 wnd.image(mag_norm);
98 }
99 }
100
101 } catch (af::exception &e) {
102 fprintf(stderr, "%s\n", e.what());
103 throw;
104 }
105
106 return 0;
107}

Callers

nothing calls this directly

Calls 10

infoFunction · 0.85
complex_gridFunction · 0.85
sqrtFunction · 0.85
mandelbrotFunction · 0.85
setColorMapMethod · 0.80
closeMethod · 0.80
imageMethod · 0.80
normalizeFunction · 0.70
setDeviceFunction · 0.50
absFunction · 0.50

Tested by

no test coverage detected