Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

v1 source pure

Package cantiere is a Sinopia showcase engine: isometric maquettes of imaginary hill towns on a ruled drafting sheet,...

Overview

Package cantiere is a Sinopia showcase engine: isometric maquettes of imaginary hill towns on a ruled drafting sheet, with red scaffolding for the storeys not yet built ("cantiere" is Italian for building site).

A plan generator writes an N x N height map (N = 6..8); columns are drawn back to front, one anti-diagonal at a time. Columns on one diagonal never overlap, so each diagonal is a handful of merged paths, one per fill, and windows are skewed <pattern> tiles instead of one element per window. That keeps the SVG small (median ~5.5 KB) and the render cheap.

Determinism: the same FNV-1a + splitmix64 stream as Genesis, with separate streams for traits (seed+"|traits") and art (seed+"|art"), so art draws never shift traits. Pure integer math; every division truncates (Go). The TypeScript twin (frontend/src/engines/cantiere.ts) is byte-identical; the golden vectors in cantiere_test.gno pin both.

Params ("" = the showcase): canonical JSON in schema order, e.g. {"light":"Night","material":"Any","plan":"Any","scaffold":true}. A param pins one trait after all trait draws, so the other traits of a seed stay the same in every variant.

Constants 2

const MaxSVGBytes

1const MaxSVGBytes = 32768
source

MaxSVGBytes: the largest output measured is 15,448 B (5,000 default seeds) and 15,174 B (19,600 renders over every param set); median ~5.5 KB. 2x margin.

const ParamsSchema

1const ParamsSchema = `{"type":"object","properties":{` +
2	`"light":{"type":"string","title":"Light","enum":["Any","Morning","Evening","Noon","Night"],"default":"Any"},` +
3	`"material":{"type":"string","title":"Material","enum":["Any","Tufa","Brick","Travertine","Painted Plaster","Concrete","Basalt"],"default":"Any"},` +
4	`"plan":{"type":"string","title":"Plan","enum":["Any","Hill Town","Ziggurat","Courtyard","Terraces","Towers","Ruin"],"default":"Any"},` +
5	`"scaffold":{"type":"boolean","title":"Scaffolding","default":true}}}`
source

ParamsSchema is the Studio form: three trait pins and a scaffolding switch.

Functions 8

func Manifest

1func Manifest() engine.Manifest
source

Manifest describes the engine. Author and FeeBps are set by the adapter realm that registers it.

func Render

1func Render(in engine.Input) string
source

Render returns the raw SVG for in.Seed and in.Params.

func SVG

1func SVG(seed, params string) string
source

SVG renders the artwork for a seed and params; it panics on invalid params.

func TraitString

1func TraitString(seed, params string) string
source

TraitString is "Type=Value;…" in TraitTypes order (the golden-vector form shared with the TypeScript twin).

func Traits

1func Traits(in engine.Input) []engine.Trait
source

Traits returns the nine traits of in.Seed in TraitTypes order. It never renders: a few table draws only.

func ValidateParams

1func ValidateParams(params string) error
source

ValidateParams accepts "" or exactly the canonical params JSON.

func ParseParams

1func ParseParams(s string) (Params, error)
source

ParseParams decodes "" (defaults) or the canonical JSON Studio sends (schema order, no whitespace). Anything else is an error.

func TraitsOf

1func TraitsOf(seed, params string) TraitSet
source

TraitsOf returns the decoded traits of a seed; it panics on invalid params.

Types 2

type Params

struct
1type Params struct {
2	Light, Material, Plan string
3	Scaffold              bool
4}
source

Params are the decoded collection params.

type TraitSet

struct
1type TraitSet struct {
2	Plan, Material, Light, Scaffold, Openings, Garden, Water string
3	Storeys                                                  int // tallest built column
4	Score                                                    int
5	Rarity                                                   string
6	material                                                 int // index into materials
7}
source

TraitSet is the decoded properties of a seed; the SVG and the trait list both read it, so picture and metadata cannot disagree.

Dependencies

Source Files 2