Skip to the content

Karakuriからくり

Play eight native puzzles, run bounded searches, step deterministic physics and mount a canvas player controlled by pointer or keyboard.

Karakuri is the Japanese word からくり for a mechanism or ingenious device. About the name

Contents

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

NameTypeDescription
elementElement

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

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/karakuri 0.2.1.