2 #include <unistd.h> // Because we can.
4 int main(int argc, char ** argv)
6 #ifndef __STDC_IEC_559__
7 Warn("__STDC_IEC_559__ not defined. IEEE 754 floating point not fully supported.\n");
11 Debug("Compiled with REAL = %d => \"%s\" sizeof(Real) == %d bytes", REAL, g_real_name[REAL], sizeof(Real));
16 enum {OUTPUT_TO_BMP, LOOP} mode = LOOP;
20 const char * input_bmp = NULL;
21 const char * output_bmp = NULL;
22 const char * input_filename = NULL;
23 float b[4] = {0,0,1,1};
28 if (argv[i][0] != '-')
30 input_filename = argv[i];
38 Fatal("No input argument following -o switch");
41 Fatal("No output argument following -o switch");
47 Debug("Reading paint colour");
48 for (int j = 1; j <= 4; ++j)
51 Fatal("No %d colour component following -c switch", j);
53 float * comp = (j == 1) ? (&c.r) : ((j == 2) ? (&c.g) : ((j == 3) ? (&c.b) : &(c.a)));
54 *comp = strtof(argv[i+j], &e);
56 Fatal("Colour component %d not a valid float", j);
63 Debug("Reading view bounds");
64 for (int j = 1; j <= 4; ++j)
67 Fatal("No %d bounds component following -b switch", j);
69 b[j-1] = strtof(argv[i+j], &e);
71 Fatal("Bounds component %d not a valid float", j);
79 if (input_filename != NULL)
81 doc.LoadSVG(input_filename, Rect(0,0,Real(1)/Real(800),Real(1)/Real(600)));
85 //doc.AddBezier(Bezier(0,0, 1,0.5, 0.5,1, 1,1));
86 doc.AddText("The quick brown\nfox jumps over\nthe lazy dog",0.1,0,0.5);
87 //doc.AddBezier(Bezier(0,0,0,0.1,0,0.1,0,0.1));
90 Rect bounds(b[0],b[1],b[2],b[3]);
93 MainLoop(doc, bounds, c);
94 else if (mode == OUTPUT_TO_BMP)
95 OverlayBMP(doc, input_bmp, output_bmp, bounds, c);