summaryrefslogtreecommitdiff
path: root/web/hitomezashi_web.c
diff options
context:
space:
mode:
authoruntir_l <87096069+untir-l@users.noreply.github.com>2022-02-27 13:23:43 +0000
committeruntir_l <87096069+untir-l@users.noreply.github.com>2022-02-27 13:28:20 +0000
commit1ddd20748d01570929a88672366dff69ce300a51 (patch)
tree5c53f1765484427fc9334acfb7fa463c1d65b77b /web/hitomezashi_web.c
parenta492064a97a04939ca5e995c3c6df4935b9e2cb9 (diff)
downloadhitomezashi-1ddd20748d01570929a88672366dff69ce300a51.tar
hitomezashi-1ddd20748d01570929a88672366dff69ce300a51.tar.gz
hitomezashi-1ddd20748d01570929a88672366dff69ce300a51.zip
Add support for choosing foreground and background colours
Diffstat (limited to 'web/hitomezashi_web.c')
-rw-r--r--web/hitomezashi_web.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/web/hitomezashi_web.c b/web/hitomezashi_web.c
index 4859c20..539fa96 100644
--- a/web/hitomezashi_web.c
+++ b/web/hitomezashi_web.c
@@ -32,6 +32,9 @@ int EMSCRIPTEN_KEEPALIVE main(void) {
int gap = strtol(strtok(NULL, "\n"), NULL, 0);
int line_thickness = strtol(strtok(NULL, "\n"), NULL, 0);
+ Uint32 fg_colour = strtol(strtok(NULL, "\n"), NULL, 0);
+ Uint32 bg_colour = strtol(strtok(NULL, "\n"), NULL, 0);
+
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
return Hitomezashi_Web_Result_Err_Sdl_Init;
}
@@ -42,7 +45,8 @@ int EMSCRIPTEN_KEEPALIVE main(void) {
struct Hitomezashi_State state;
if (hitomezashi_state_init(&state, x_pattern_len, y_pattern_len, x_pattern,
- y_pattern, gap, line_thickness) != 0) {
+ y_pattern, gap, line_thickness, fg_colour,
+ bg_colour) != 0) {
return Hitomezashi_Web_Result_Err_State_Init;
}
@@ -81,6 +85,16 @@ EM_JS(char *, hitomezashi_web_get_args, (void), {
const y_pattern = search_params.get("y_pattern");
const gap = search_params.get("gap");
const line_thickness = search_params.get("line_thickness");
+ let fg_colour = search_params.get("fg_colour");
+ let bg_colour = search_params.get("bg_colour");
+ if (!fg_colour) {
+ fg_colour = "#000000";
+ }
+ if (!bg_colour) {
+ bg_colour = "#FFFFFF";
+ }
+ fg_colour = "0x" + fg_colour.slice(1);
+ bg_colour = "0x" + bg_colour.slice(1);
if (!(x_pattern && y_pattern && gap && line_thickness)) {
result_js = "i";
@@ -91,7 +105,7 @@ EM_JS(char *, hitomezashi_web_get_args, (void), {
result_js = "i";
} else {
result_js = x_pattern + "\n" + y_pattern + "\n" + gap + "\n" +
- line_thickness + "\n";
+ line_thickness + "\n" + fg_colour + "\n" + bg_colour + "\n";
}
}