readTheme関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
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 { readTheme } from "@johnmorrisdotca/karakuri/play";
定義
function readTheme(element: Element): Theme
引数
| 名前 | 型 | 説明 |
|---|---|---|
element | Element | The real element whose inherited native CSS theme values are read. |
戻り値
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.
例
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);この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。