#include "common.hpp"
config_t the_config = {
40,
20,
50,
10,
config_t::DIST_LAB
};
const config_t& config = the_config;
int parse_args(int argc, const char** argv) {
unsigned rv = 0;
for (int i=0; i<argc; i++) {
const char* arg = argv[i];
if (*arg != '-') break;
rv++;
if (!strncmp(arg, "--dim=", 6)) {
arg += 6;
the_config.mosaic_dim = atoi(arg);
if (the_config.mosaic_dim < 10 || the_config.mosaic_dim > 100 || the_config.mosaic_dim % 2 != 0) return -1;
the_config.mosaic_dim_half = the_config.mosaic_dim/2;
} else if (!strncmp(arg, "--tint=", 7)) {
arg += 7;
the_config.tint = atoi(arg);
if (the_config.tint > 100 || (the_config.tint == 0 && strcmp(arg, "0"))) return -1;
} else if (!strncmp(arg, "--fulltint=", 11)) {
arg += 11;
the_config.full_tint = atoi(arg);
if (the_config.full_tint > 100 || (the_config.full_tint == 0 && strcmp(arg, "0"))) return -1;
} else if (!strncmp(arg, "--dist=", 7)) {
arg += 7;
if (!strcmp(arg, "avg")) {
the_config.dist_func = config_t::DIST_AVG;
} else if (!strcmp(arg, "euclid")) {
the_config.dist_func = config_t::DIST_EUCLID;
} else if (!strcmp(arg, "lab")) {
the_config.dist_func = config_t::DIST_LAB;
} else {
return -1;
}
} else {
return -1;
}
}
return rv;
}