Reference
Playable board
import { … } from "@johnmorrisdotca/tsunagi/play";
24.7 kB minified and gzipped, with everything it imports (measured with esbuild)
Tsunagi, played in a page: mountTsunagi draws a level into any element and
plays it by touch and mouse, with Undo, Restart, Check and Cheat, the zoom
pad for big boards, and the words in English and Japanese. A separate entry
(@johnmorrisdotca/tsunagi/play), so a server never loads any of it.
Exports
| Name | Kind | What it is |
|---|---|---|
edgeNudge | function | How far to move a zoomed view in a frame, for a finger at (x, y) in a box: toward the edge it is near, or not at all. |
ensureTsunagiPlayStyle | function | Put the style in the page once: in the document's head, or in the shadow root the host is in. |
keptView | function | A view kept inside the board: never a gap between the board's edge and the box's. |
mountTsunagi | function | Draw a level into host and play it. |
TSUNAGI_EDGE | constant | How near an edge of the box a line's end must be dragged to move the view, and how far each frame moves it, in pixels. |
TSUNAGI_EDGE_STEP | constant | The native pixel increment for nudging the view near an edge. |
TSUNAGI_FITTED | constant | The whole board, fitted. |
TSUNAGI_MOST_ZOOM | constant | How far a board may be zoomed in, as a multiple of the whole board fitted to its box. |
TSUNAGI_PLAY_STYLE | constant | THE STYLE a playable Tsunagi board wears (mountTsunagi, <tsunagi-board>): the drawing's own (TSUNAGI_STYLE) and the board's box, its buttons, its lines of words and its zoom pad. |
TSUNAGI_ZOOM_FROM | constant | The smallest board a player is given the pad for. |
TsunagiEventDetail | type | What a mounted board tells of itself in every event. |
TsunagiLook | type | What a board looks like: every option drawTsunagi takes that does not depend on the lines. |
TsunagiMount | type | The mounted native board handle and its game, display, action and cleanup methods. |
TsunagiMountOptions | type | The puzzle, native display choices, controls and event callbacks for mounting a board. |
TsunagiView | type | A BIG BOARD LOOKED AT THROUGH A BOX: from 10×10 up, a phone's cells are smaller than a thumb, so the board is drawn up to three times the box's width and looked at through it, zoomed and moved by a pad of buttons, the wheel and (while a line is dragged) the box's edge, never by scrolling the page. |
zoomedAbout | function | A view zoomed by factor about the point (px, py) of the box, which stays over the same spot of the board. |