mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-20 23:51:29 -07:00
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.
This commit is contained in:
11
emcclib.js
11
emcclib.js
@ -143,6 +143,17 @@ mergeInto(LibraryManager.library, {
|
||||
menuform.elements["preset"].value = n;
|
||||
},
|
||||
|
||||
/*
|
||||
* 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);
|
||||
*
|
||||
|
Reference in New Issue
Block a user