本文へ移動

Karakuriからくり

8つの標準のパズルで遊び、探索や再現できる物理を使い、ポインターやキーボードで操作する盤を表示できます。

「からくり」は、仕組みや工夫した装置を表す言葉です。 名前について(英語)

目次

リファレンス · 操作とキャンバスの表示

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

引数

名前型説明
elementElement

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);

ソースを見るGitHub で編集@johnmorrisdotca/karakuri 0.2.1 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。