Reference · Controllers and canvas player
readThemefunction
Reads the theme a game draws with from an element's computed style: each colour is --kk-<name>, with the light or the dark default beneath.
Import it
import { readTheme } from "@johnmorrisdotca/karakuri/play";
Definition
function readTheme(element: Element): Theme
Parameters
| Name | Type | Description |
|---|---|---|
element | Element | The real element whose inherited native CSS theme values are read. |
Returns
Theme
Reads the theme a game draws with from an element's computed style: each colour is --kk-<name>, with the light or the dark default beneath.
Examples
import type { BodySpec } from "@johnmorrisdotca/karakuri/physics";
import { createBody } from "@johnmorrisdotca/karakuri/physics";
import { readTheme } from "@johnmorrisdotca/karakuri/play";
const spec: BodySpec={id:"ball",shapes:[{kind:"circle",x:0,y:0,r:3}],x:0,y:0};
const body=createBody(spec);
const host=document.createElement("div");
document.body.append(host);
console.log(readTheme(host).board);