Add color options, bump minor version

This commit is contained in:
2021-05-09 18:20:46 -04:00
parent d5475ba2de
commit e05724ea53
8 changed files with 121 additions and 16 deletions

View File

@@ -3,9 +3,8 @@ pkg_search_module(POPT REQUIRED popt)
add_executable(mazemaker)
target_sources(mazemaker PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/mazemaker.c)
target_link_libraries(mazemaker PRIVATE mazemaker_shared PUBLIC ${POPT_LIBRARIES})
target_link_libraries(mazemaker PUBLIC mazemaker_shared ${POPT_LIBRARIES})
target_include_directories(mazemaker PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../include PUBLIC ${POPT_INCLUDE_DIRS})
target_compile_options(mazemaker PUBLIC ${POPT_CFLAGS_OTHER})
target_link_options(mazemaker PUBLIC -L${POPT_LIBDIR})
install (TARGETS mazemaker DESTINATION bin)

View File

@@ -6,12 +6,16 @@
int main(int argc, char* argv[]) {
char c;
int width = 0, height = 0;
char const *filename = NULL;
char const *filename = NULL, *fg_color = NULL, *bg_color = NULL;
struct poptOption options_table[] = {
{ "width", 'w', POPT_ARG_INT, &width, 0,
"Width of the maze", "BLOCKS" },
{ "height", 'h', POPT_ARG_INT, &height, 0,
"Height of the maze", "BLOCKS" },
{ "foreground", 'f', POPT_ARG_STRING, &fg_color, 0,
"Foreground (wall) color", "#rrggbb" },
{ "background", 'b', POPT_ARG_STRING, &bg_color, 0,
"Background color", "#rrggbb" },
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0 }
};
@@ -36,8 +40,12 @@ int main(int argc, char* argv[]) {
return 1;
}
mazegrid_t maze;
mazeoptions_t* options = mazemaker_options_new();
if (fg_color != NULL) mazemaker_options_set_wall_color(options, fg_color);
if (bg_color != NULL) mazemaker_options_set_background_color(options, bg_color);
mazemaker_generate_maze(width, height, &maze);
mazemaker_maze_to_png(&maze, filename);
mazemaker_maze_to_png_opt(&maze, filename, options);
mazemaker_free_maze(&maze);
mazemaker_options_free(options);
poptFreeContext(ctx);
}