Skip to the content

Suido水道

Turn pipes to connect the pumps and drains, through fixed levels or seeded puzzles.

Suido means water supply in Japanese. About the name

Contents

Reference · SVG board

attachSuidoViewfunction

Lets the box box move and zoom the board drawn in svg (which must have a viewBox of the whole board). A press that moves is not a tap: the click that follows a drag is swallowed. Call it once the drawing is in the page; destroy removes every listener it added.

Import it

import { attachSuidoView } from "@johnmorrisdotca/suido/draw";

Definition

function attachSuidoView(box: HTMLElement, svg: SVGSVGElement, layout: { width: number; height: number; }, options?: SuidoViewerOptions): SuidoViewer

Parameters

NameTypeDescription
boxHTMLElement

The board drawing dimensions or DOM viewport specified by this signature.

svgSVGSVGElement

The existing native SVG board element.

layout{ width: number; height: number; }

The decoded board with its dimensions, pipe masks and rule settings.

options (optional)SuidoViewerOptions

Drawing, mounting or generator choices specified by the signature.

Returns

SuidoViewer

Lets the box box move and zoom the board drawn in svg (which must have a viewBox of the whole board). A press that moves is not a tap: the click that follows a drag is swallowed. Call it once the drawing is in the page; destroy removes every listener it added.

Examples

import { SUIDO_5X5 } from "@johnmorrisdotca/suido/levels-5x5";
import { decodeLayout } from "@johnmorrisdotca/suido";
import { attachSuidoView, drawSuido } from "@johnmorrisdotca/suido/draw";

const row = SUIDO_5X5[0];
const code = row[0];
const layout = decodeLayout(code)!;
const host = document.createElement("div");
document.body.append(host);
host.innerHTML = drawSuido(layout);
const svg = host.querySelector("svg")!;
const viewer = attachSuidoView(host,svg,layout);
console.log(viewer.get().zoom);
viewer.destroy();

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/suido 1.7.0.