forked from hkc/cc-stuff
1
0
Fork 0

Rename character_mode to conversion_mode

This commit is contained in:
Vftdan 2024-10-03 22:40:17 +02:00
parent 53c9ba3db5
commit 30b6534fc1
1 changed files with 16 additions and 16 deletions

View File

@ -40,11 +40,11 @@ const extern struct palette DEFAULT_PALETTE, DEFAULT_GRAY_PALETTE;
struct arguments { struct arguments {
int width, height; int width, height;
enum character_mode { enum conversion_mode {
CHARACTER_BLOCK, CONVERSION_BLOCK,
CHARACTER_CHAR_PRECISE, CONVERSION_CHAR_PRECISE,
CHARACTER_CHAR_FAST, CONVERSION_CHAR_FAST,
} character_mode; } conversion_mode;
enum cpi_version { enum cpi_version {
CPI_VERSION_AUTO, CPI_VERSION_AUTO,
CPI_VERSION_RAW, CPI_VERSION_RAW,
@ -73,7 +73,7 @@ struct arguments {
} args = { } args = {
.width = 4 * 8 - 1, // 4x3 blocks screen .width = 4 * 8 - 1, // 4x3 blocks screen
.height = 3 * 6 - 2, .height = 3 * 6 - 2,
.character_mode = CHARACTER_CHAR_PRECISE, .conversion_mode = CONVERSION_CHAR_PRECISE,
.cpi_version = CPI_VERSION_AUTO, .cpi_version = CPI_VERSION_AUTO,
.placement = PLACEMENT_FULL, .placement = PLACEMENT_FULL,
.input_path = NULL, .input_path = NULL,
@ -204,7 +204,7 @@ int main(int argc, char **argv) {
} }
struct image *canvas; struct image *canvas;
if (args.character_mode == CHARACTER_BLOCK) { if (args.conversion_mode == CONVERSION_BLOCK) {
canvas = image_new(args.width * 2, args.height * 3); canvas = image_new(args.width * 2, args.height * 3);
} else { } else {
canvas = image_new(args.width * 8, args.height * 11); canvas = image_new(args.width * 8, args.height * 11);
@ -257,18 +257,18 @@ int main(int argc, char **argv) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
switch (args.character_mode) { switch (args.conversion_mode) {
case CHARACTER_BLOCK: case CONVERSION_BLOCK:
convert_2x3(quantized_image, characters); convert_2x3(quantized_image, characters);
break; break;
case CHARACTER_CHAR_PRECISE: case CONVERSION_CHAR_PRECISE:
convert_8x11(quantized_image, characters, true); convert_8x11(quantized_image, characters, true);
break; break;
case CHARACTER_CHAR_FAST: case CONVERSION_CHAR_FAST:
convert_8x11(quantized_image, characters, false); convert_8x11(quantized_image, characters, false);
break; break;
default: default:
fprintf(stderr, "BUG: invalid args.character_mode\n"); fprintf(stderr, "BUG: invalid args.conversion_mode\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
@ -320,7 +320,7 @@ bool parse_cmdline(int argc, char **argv) {
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
break; break;
case 'f': // --fast case 'f': // --fast
args.character_mode = CHARACTER_BLOCK; args.conversion_mode = CONVERSION_BLOCK;
fprintf(stderr, "Warning: `--fast` is deprecated, use `--mode block` instead\n"); fprintf(stderr, "Warning: `--fast` is deprecated, use `--mode block` instead\n");
if (args.cpi_version != CPI_VERSION_AUTO) { if (args.cpi_version != CPI_VERSION_AUTO) {
fprintf(stderr, "Warning: text mode ignores version\n"); fprintf(stderr, "Warning: text mode ignores version\n");
@ -329,11 +329,11 @@ bool parse_cmdline(int argc, char **argv) {
case 'm': // --mode case 'm': // --mode
{ {
if (0 == strcmp(optarg, "block") || 0 == strcmp(optarg, "fast") || 0 == strcmp(optarg, "2x3")) { if (0 == strcmp(optarg, "block") || 0 == strcmp(optarg, "fast") || 0 == strcmp(optarg, "2x3")) {
args.character_mode = CHARACTER_BLOCK; args.conversion_mode = CONVERSION_BLOCK;
} else if (0 == strcmp(optarg, "char") || 0 == strcmp(optarg, "char-precise") || 0 == strcmp(optarg, "8x11") || 0 == strcmp(optarg, "6x9")) { } else if (0 == strcmp(optarg, "char") || 0 == strcmp(optarg, "char-precise") || 0 == strcmp(optarg, "8x11") || 0 == strcmp(optarg, "6x9")) {
args.character_mode = CHARACTER_CHAR_PRECISE; args.conversion_mode = CONVERSION_CHAR_PRECISE;
} else if (0 == strcmp(optarg, "char-fast") || 0 == strcmp(optarg, "8x11-fast") || 0 == strcmp(optarg, "6x9-fast")) { } else if (0 == strcmp(optarg, "char-fast") || 0 == strcmp(optarg, "8x11-fast") || 0 == strcmp(optarg, "6x9-fast")) {
args.character_mode = CHARACTER_CHAR_FAST; args.conversion_mode = CONVERSION_CHAR_FAST;
} }
} }
break; break;