本文へ移動

Suido水道

管を回してポンプと排水口をつなぎます。収録された問題やシード付きの問題で遊べます。

「水道」は、水を届ける設備を表す言葉です。 名前について(英語)

目次

リファレンス · SVGの盤

paintSuido関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Update the existing board SVG with current facings and water, returning its flow state.

インポート

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

定義

function paintSuido(svg: Element, layout: Layout, masks: readonly number[], quarters: readonly number[]): Flow

引数

名前型説明
svgElement

The existing native SVG board element.

layoutLayout

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

masksreadonly number[]

Current pipe masks in row-major cell order.

quartersreadonly number[]

Clockwise quarter turns, per cell or for the piece specified by the signature.

戻り値

Flow

Update the existing board SVG with current facings and water, returning its flow state.

例

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

const row = SUIDO_5X5[0];
const code = row[0];
const layout = decodeLayout(code)!;
const solution = levelSolution(row)!;
const game = newGame(code)!;
const host = document.createElement("div");
document.body.append(host);
host.innerHTML = drawSuido(layout);
const svg = host.querySelector("svg")!;
console.log(paintSuido(svg,layout,solution,game.quarters).solved);

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

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