リファレンス
操作とキャンバスの表示
import { … } from "@johnmorrisdotca/karakuri/play";
最小化と gzip 圧縮をしたサイズは 40.0 kB(読み込むものをすべて含み、esbuild で計測)
リファレンスの説明と例は英語です。見出しと目次は日本語です。
エクスポート
| 名前 | 種類 | 概要 |
|---|---|---|
Controller | 型 | One level of one game, played. |
createController | 関数 | Makes a controller for level level (from 1) of a game; a level out of range is held to the nearest. |
defaultTheme | 関数 | The theme without a page: the light one, for a drawing made where there is no style to read (a test, a server). |
GameInfo | 型 | What a game of the package is, for a chooser. |
Info | 型 | What the player reads in the bar above the board. |
KARAKURI_GAME_IDS | 定数 | The ids of the games, in the order the package lists them (kebab case, the same in every address and attribute). |
KARAKURI_GAMES | 定数 | THE GAMES of the package, by id. |
KARAKURI_STYLE | 定数 | THE STYLE the player wears: the colours as custom properties on .karakuri (light, and dark when the page asks for it by prefers-color-scheme or by data-theme="dark" on the root), the layout of the bar, the play area and the buttons, and the one rule that matters for games played with fingers: nothing on the board can be selected, dragged or double-tapped, and the play area stops the page scrolling under a finger only for the games that read a finger's whole path. |
KARAKURI_THEMES | 定数 | The look the games draw with, as custom properties, so a page can change any of them. |
KarakuriGame | 型 | The id of a game of the package. |
KarakuriMount | 型 | The native handle, including its controller and focused keyboard canvas. |
mountKarakuri | 関数 | Plays one game of the package in host: a canvas that scales to the box it is given, the pointer (finger or mouse) wired to the game, a fixed-step loop that runs only while something moves, and (with ui: "full") the bar, the buttons and the card that says how a level ended. |
MountOptions | 型 | Initial native controller, level, layout, keyboard, clock and host callbacks. |
Point | 型 | A place in a game's own world, in its own units (not pixels). |
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. |
Say | 型 | A line of words to be said in the player's language: a key of KARAKURI_STRINGS and the values for its {name}s. |
Status | 型 | How a level stands: still being played, won, or lost. |
StatusEvent | 型 | What a status callback is given. |
Theme | 型 | The colours and sizes a game draws with, read from the page's custom properties (--kk-*) so that it follows light, dark and the family's cloths. |
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。