30 printf(
"%s [argument]* [filename]\n", progname);
31 printf(
"Arguments:\n");
33 printf(
" --help show this usage message and exit\n");
34 printf(
" --version show the version string and exit\n");
36 printf(
" --view X Y R set view coordinates to X + i Y @ R\n");
38 printf(
" --verbose level set the log message verbosity\n");
39 printf(
" valid levels (from quiet to noisy) are:\n");
40 printf(
" fatal error warn notice info debug\n");
41 printf(
" --geometry WxH set window size (default --size)\n");
42 printf(
" --size WxH set image size (default --geometry)\n");
43 printf(
" --de compute distance estimates (default)\n");
44 printf(
" --no-de don't compute distance estimates\n");
45 printf(
" --no-approx don't compute series approximation\n");
46 printf(
" sometimes that optimisation breaks glitch fixing\n");
48 printf(
" --weight W how dark to make the boundary (default 0.0)\n");
49 printf(
" --glitch highlight glitches in ugly colours\n");
50 printf(
" --no-glitch try to mask glitches (default)\n");
51 printf(
" --max-glitch G percentage of glitches allowed (default 0.02)\n");
52 printf(
" lower value gives better image at higher cost\n");
53 printf(
" --max-blob B maximum pixels in glitched blob allowed (default 1)\n");
54 printf(
" lower value gives better image at higher cost\n");
55 printf(
" --sharpness S how sharp to make visible interior (default 0.01)\n");
56 printf(
" lower value gives better image at higher cost\n");
57 printf(
" --timeout T timeout after T seconds (default infinity)\n");
58 printf(
" --slice S split calculations into 4^S blocks\n");
59 printf(
" valid range from 0 (default) to %d\n",
SLICE_MAX);
61 printf(
" --interactive start in interactive mode (default)\n");
62 printf(
" --one-shot render one image and exit\n");
63 printf(
" --tile N[xM] render a large image as NxM tiles\n");
64 printf(
" M defaults to N if it isn't specified\n");
65 printf(
" final image size is (W*N)x(H*M)\n");
66 printf(
" --zoom F render a zoom-in sequence of F frames\n");
67 printf(
" can be combined with --tile\n");
68 printf(
" --overhead quit after startup without rendering anything\n");
69 printf(
" might be useful for benchmarking\n");
71 printf(
"Only use at most one of: --interactive --one-shot (--tile --zoom)\n");
73 printf(
"If a filename argument is given, it will be loaded to set the\n");
74 printf(
"viewing parameters.\n");
78 #define O(flag) (0 == strcmp((flag), argv[i]) && strlen((flag)) == strlen(argv[i]))
79 #define NEXT do{ i++; if (! (i < argc)) { log_message(LOG_FATAL, "%s: argument expected\n", argv[i-1]); return false; } }while(0)
80 #define NEXT2(s) do{ i++; if (! (i < argc)) { log_message(LOG_FATAL, "%s: argument expected\n", s); return false; } }while(0)
81 for (
int i = 1; i < argc; ++i) {
83 }
else if (
O(
"-h") ||
O(
"-?") ||
O(
"-help") ||
O(
"--help")) {
86 }
else if (
O(
"-v") ||
O(
"-V") ||
O(
"-version") ||
O(
"--version")) {
89 }
else if (
O(
"--view")) {
91 const char *sx = argv[i];
93 const char *sy = argv[i];
95 const char *sz = argv[i];
96 mpfr_init2(options->
radius, 53);
97 mpfr_set_str(options->
radius, sz, 10, MPFR_RNDN);
98 if (! (mpfr_regular_p(options->
radius) && mpfr_sgn(options->
radius) > 0)) {
103 mpfr_init2(options->
centerx, bits);
104 mpfr_init2(options->
centery, bits);
105 mpfr_set_str(options->
centerx, sx, 10, MPFR_RNDN);
106 mpfr_set_str(options->
centery, sy, 10, MPFR_RNDN);
108 }
else if (
O(
"--verbose")) {
122 }
else if (
O(
"--de")) {
124 }
else if (
O(
"-no-de") ||
O(
"--no-de")) {
129 }
else if (
O(
"--no-approx")) {
131 }
else if (
O(
"-glitch") ||
O(
"--glitch")) {
136 }
else if (
O(
"--no-glitch")) {
138 }
else if (
O(
"--interactive")) {
140 }
else if (
O(
"-bench") ||
O(
"--one-shot")) {
145 }
else if (
O(
"-tile") ||
O(
"--tile")) {
149 options->
tile =
true;
151 if (strchr(argv[i],
'x')) {
154 if (! (2 == sscanf(argv[i],
"%dx%d", &tile_width, &tile_height))) {
158 if (! (tile_width > 0 && tile_height > 0)) {
165 int tile_count = atoi(argv[i]);
166 if (! (tile_count > 0)) {
173 }
else if (
O(
"-zoom") ||
O(
"--zoom")) {
177 options->
zoom =
true;
179 int zoom_frames = atoi(argv[i]);
180 if (! (zoom_frames > 0)) {
185 }
else if (
O(
"--overhead")) {
187 }
else if (
O(
"--geometry")) {
191 if (! (2 == sscanf(argv[i],
"%dx%d", &width, &height))) {
195 if (! (width > 0 && height > 0)) {
202 }
else if (
O(
"-size") ||
O(
"--size")) {
209 if (! (2 == sscanf(argv[i],
"%dx%d", &width, &height))) {
213 if (! (width > 0 && height > 0)) {
217 options->
size =
true;
218 options->
width = width;
220 }
else if (
O(
"-weight") ||
O(
"--weight")) {
225 options->
weight = atof(argv[i]);
226 }
else if (
O(
"--max-glitch")) {
228 options->
max_glitch = fmin(fmax(atof(argv[i]), 0.0), 100.0);
229 }
else if (
O(
"--max-blob")) {
232 }
else if (
O(
"--sharpness")) {
234 options->
sharpness = fmin(fmax(atof(argv[i]), 0.0), 1.0);
235 }
else if (
O(
"--timeout")) {
237 options->
timeout = atof(argv[i]);
238 }
else if (
O(
"--slice")) {