Skip to main content

Draw a puzzle

The repository has a reference renderer, tools/render_svg.py, that draws a sudoku-puzzle file as SVG in the default style of Drawing and style. It is not part of the installed package; run it from a clone.

python tools/render_svg.py docs/examples/mini-thermo-kropki.json mini.svg
python tools/render_svg.py docs/examples/mini-thermo-kropki.json mini-dark.svg --dark
The 6×6 thermo and Kropki puzzleThe 6×6 thermo and Kropki puzzle

This is the puzzle from Write a variant puzzle file. --cell N sets the size of a cell in pixels (48 by default).

From Python, with the tools folder on the path:

import json, render_svg

doc = json.load(open("docs/examples/mini-thermo-kropki.json"))
svg = render_svg.render(doc, dark=False, cell=48)

The small drawings on the rule pages come from this renderer. It always uses the default style, with line colours most puzzle setters use; Drawing and style lists every size and colour, and docs/palette.json holds them in one file for other renderers.