diff options
| author | Ben Harris <bjh21@bjh21.me.uk> | 2022-12-05 19:34:09 +0000 |
|---|---|---|
| committer | Ben Harris <bjh21@bjh21.me.uk> | 2022-12-05 23:25:12 +0000 |
| commit | ea223a23503c80759d5579626285eda0e617d6b4 (patch) | |
| tree | c0efcb64e92694d776d778a751f54746c15acd08 /emcclib.js | |
| parent | e5b0bcae5615d8829c8b5af2e3127397e7b72d8c (diff) | |
| download | puzzles-ea223a23503c80759d5579626285eda0e617d6b4.zip puzzles-ea223a23503c80759d5579626285eda0e617d6b4.tar.gz puzzles-ea223a23503c80759d5579626285eda0e617d6b4.tar.bz2 puzzles-ea223a23503c80759d5579626285eda0e617d6b4.tar.xz | |
js: Put the puzzle background colour in a CSS variable
It's sometimes useful to be able to have an HTML element that visually
forms an extension of the puzzle's border. By putting the puzzle's
colour 0 (which we assume to be its background) into a CSS variable,
such elements can do something like "background-color:
var(--puzzle-background)" to get that effect even if the puzzle uses a
non-default background colour.
Diffstat (limited to 'emcclib.js')
| -rw-r--r-- | emcclib.js | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -144,6 +144,17 @@ mergeInto(LibraryManager.library, { }, /* + * void js_set_background_colour(const char *bg); + * + * Record the puzzle background colour in a CSS variable so + * the style sheet can use it if it wants. + */ + js_set_background_colour: function(bgptr) { + document.documentElement.style.setProperty("--puzzle-background", + UTF8ToString(bgptr)); + }, + + /* * void js_get_date_64(unsigned *p); * * Return the current date, in milliseconds since the epoch |