本文へ移動

Kazu数

検証済みの数独や論理パズルを作り、標準の規則とヒントを読み、盤を描いたり埋め込んだりできます。

「数」は数字を表す言葉です。 名前について(英語)

目次

リファレンス · 数字の盤のSVG

drawKazu関数

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

A PUZZLE AS SVG TEXT: the grid with its printed numbers, whatever has been written in it, pencil marks, and everything the kind of puzzle prints: the heavier rules round the boxes or a Jigsaw's regions, the shaded diagonals, a cage's dashed outline with its sum, the more-than marks between cells, and the tower clues round the edge. The chosen cell, the cells that break a rule, the cells Check flagged and the cell a hint pointed at are washed in colour.

Returns the <svg> as a string: put it in a page, a file or an image, with nothing to load. It is one steady square whatever is drawn, so nothing moves as numbers are written. Nothing in it can be selected or dragged. Null for givens that are not a puzzle of that kind and side.

インポート

import { drawKazu } from "@johnmorrisdotca/kazu/draw";

定義

function drawKazu(kind: KazuKind, size: number, givensCode: string, options?: KazuDrawOptions): string | null

引数

名前型説明
kind"number-place" | "jigsaw" | "diagonal" | "sum-cages" | "more-or-less" | "towers"

The native number-grid puzzle key.

sizenumber

The supported square grid side length.

givensCodestring

The original native printed-clue code.

options (省略可)KazuDrawOptions

Native drawing or restored-game choices.

戻り値

string | null

Native SVG text, or null for invalid kind, size or printed-clue code.

例

import type { KazuPuzzle } from "@johnmorrisdotca/kazu";
import { drawKazu } from "@johnmorrisdotca/kazu/draw";

const puzzle: KazuPuzzle = {"kind":"number-place","size":4,"level":"easy","seed":42,"givens":"14..2..1412.3..4","solution":"1432234141233214"};
const kind = puzzle.kind;
const size = puzzle.size;
const givens = puzzle.givens;
console.log(drawKazu(kind,size,givens,{language:"en"})?.startsWith("<svg"));
true

出力(このページを作ったときに実行した結果)

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

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