Skip to the content

Kazu数

Generate checked Sudoku and logic puzzles, read native rules and hints, and draw or embed playable boards.

Kazu is the Japanese word 数 for number. About the name

Contents

Reference · Number-grid SVG

drawKazufunction

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 it

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

Definition

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

Parameters

NameTypeDescription
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 (optional)KazuDrawOptions

Native drawing or restored-game choices.

Returns

string | null

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

Examples

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

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kazu 2.1.0.