aboutsummaryrefslogtreecommitdiff
path: root/emcc.c
diff options
context:
space:
mode:
authorBen Harris <bjh21@bjh21.me.uk>2022-12-10 17:49:49 +0000
committerBen Harris <bjh21@bjh21.me.uk>2022-12-10 17:58:41 +0000
commit14eb35da4aa8a66a05012af9860a7088dbf21c6d (patch)
treea93b255cf2e0b3294a24c58cb373391fe85c108d /emcc.c
parent02f1d55a023eeab52b20cb5db6428f8ff40b9459 (diff)
downloadpuzzles-14eb35da4aa8a66a05012af9860a7088dbf21c6d.zip
puzzles-14eb35da4aa8a66a05012af9860a7088dbf21c6d.tar.gz
puzzles-14eb35da4aa8a66a05012af9860a7088dbf21c6d.tar.bz2
puzzles-14eb35da4aa8a66a05012af9860a7088dbf21c6d.tar.xz
js: Set the default colour from the CSS background of the canvas
This allows the HTML/CSS to decide that it would like a different background colour without the need to recompile. The default if the CSS specifies no colour (and hence the canvas is transparent) is the same grey as before.
Diffstat (limited to 'emcc.c')
-rw-r--r--emcc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/emcc.c b/emcc.c
index 1a84efb..75ca396 100644
--- a/emcc.c
+++ b/emcc.c
@@ -51,6 +51,7 @@ extern void js_add_preset(int menuid, const char *name, int value);
extern int js_add_preset_submenu(int menuid, const char *name);
extern int js_get_selected_preset(void);
extern void js_select_preset(int n);
+extern void js_default_colour(float *output);
extern void js_set_background_colour(const char *bg);
extern void js_get_date_64(unsigned *p);
extern void js_update_permalinks(const char *desc, const char *seed);
@@ -226,12 +227,13 @@ void restore_puzzle_size(int w, int h)
}
/*
- * HTML doesn't give us a default frontend colour of its own, so we
- * just make up a lightish grey ourselves.
+ * Try to extract a background colour from the canvas's CSS. In case
+ * it doesn't have a usable one, make up a lightish grey ourselves.
*/
void frontend_default_colour(frontend *fe, float *output)
{
output[0] = output[1] = output[2] = 0.9F;
+ js_default_colour(output);
}
/*