2 ///////////////////////////////////////////////////////////////////////////
3 // This program is free software: you can redistribute it and/or modify //
4 // it under the terms of the version 3 of the GNU General Public License //
5 // as published by the Free Software Foundation. //
7 // This program is distributed in the hope that it will be useful, but //
8 // WITHOUT ANY WARRANTY; without even the implied warranty of //
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU //
10 // General Public License for more details. //
12 // You should have received a copy of the GNU General Public License //
13 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
15 // Written by and Copyright (C) Francois Fleuret //
16 // Contact <francois.fleuret@idiap.ch> for comments & bug reports //
17 ///////////////////////////////////////////////////////////////////////////
21 #include "simple_window.h"
26 SimpleWindow window("Mandelbrot", 600, 600);
30 const int width = window.get_width();
31 const int height = window.get_height();
35 for(int i = 0; i < width; i++)
36 for(int j = 0; j < height; j++) {
37 double cr = -2.0 + 3.0 * (double(i)/double(width));
38 double ci = -1.5 + 3.0 * (double(j)/double(height));
39 double zr = 0, zi = 0;
40 for(n = 0; (n < depth) && (zr*zr + zi*zi < 100); n++) {
41 double t = zr*zr -zi*zi + cr;
46 float a = float(n)/float(depth);
48 if(a < 0.5) window.color(0, 0, a*2);
49 else window.color((a-0.5)*2, (a-0.5)*2, 1.0);
51 window.draw_point(i, j);
56 cout << "Press [ENTER] to close the window.\n";