2 #include <unistd.h> // Because we can.
3 int main(int argc, char ** argv)
5 Debug("Compiled with REAL = %d => \"%s\"", REAL, g_real_name[REAL]);
10 enum {OUTPUT_TO_BMP, LOOP} mode = LOOP;
14 const char * input_bmp = NULL;
15 const char * output_bmp = NULL;
16 const char * input_filename = NULL;
17 float b[4] = {0,0,1,1};
22 if (argv[i][0] != '-')
24 input_filename = argv[i];
32 Fatal("No input argument following -o switch");
35 Fatal("No output argument following -o switch");
41 Debug("Reading paint colour");
42 for (int j = 1; j <= 4; ++j)
45 Fatal("No %d colour component following -c switch", j);
47 float * comp = (j == 1) ? (&c.r) : ((j == 2) ? (&c.g) : ((j == 3) ? (&c.b) : &(c.a)));
48 *comp = strtof(argv[i+j], &e);
50 Fatal("Colour component %d not a valid float", j);
57 Debug("Reading view bounds");
58 for (int j = 1; j <= 4; ++j)
61 Fatal("No %d bounds component following -b switch", j);
63 b[j-1] = strtof(argv[i+j], &e);
65 Fatal("Bounds component %d not a valid float", j);
73 if (input_filename != NULL)
75 doc.Load(input_filename);
79 for(int i = 0; i < 1024; ++i)
81 for (int j = 0; j < 1024; ++j)
83 doc.Add(((i^j)&1)?RECT_OUTLINE:RECT_FILLED, Rect(0.2+i-512.0,0.2+j-512.0,0.6,0.6));
88 Rect bounds(b[0],b[1],b[2],b[3]);
91 MainLoop(doc, bounds, c);
92 else if (mode == OUTPUT_TO_BMP)
93 OverlayBMP(doc, input_bmp, output_bmp, bounds, c);