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 kilim is a Sinopia engine: a flat-woven rug computed cell by cell on a warp grid. Medallions are the stepped ...

Overview

Package kilim is a Sinopia engine: a flat-woven rug computed cell by cell on a warp grid. Medallions are the stepped rings of an integer distance field (the grid turns every diagonal into a staircase, as on a loom), the border is a running sawtooth, diamond or stripe band, and "abrash" bands shift a dye lot mid-rug like hand-dyed wool.

It is a port of the kilim prototype (Python). The RNG stream, trait tables and draw order are the prototype's; the deliberate changes are the Weaver's Flaw rule (now visible in every field), the params, and a compact SVG encoding that renders the same pixels. Python's // and % floor towards minus infinity and Go's truncate, so the lattice maths goes through floorDiv/floorMod; kilim_test.gno pins golden vectors produced by the Python reference, and frontend/src/engines/kilim.ts asserts the same ones.

Pure integer maths: no floats, no time, no block data.

Constants 3

const DefaultParams

1const DefaultParams = `{"dyes":"Seeded","field":"Seeded","loom":"Fine","abrash":true}`
source

DefaultParams is the canonical form of the defaults; it renders exactly like "".

const MaxSVGBytes

1const MaxSVGBytes = 16384
source

MaxSVGBytes: the largest output over 10,000 default seeds is 8,514 B (Coarse loom: 5,984 B over 2,000 seeds x field); about 2x margin.

const ParamsSchema

1const ParamsSchema = `{"type":"object","properties":{` +
2	`"dyes":{"type":"string","title":"Dyes","enum":["Seeded","Madder & Indigo","Saffron","Walnut & Bone",` +
3	`"Pomegranate","Night Indigo","Steppe","Undyed","Sinopia Earth"],"default":"Seeded"},` +
4	`"field":{"type":"string","title":"Field","enum":["Seeded","Medallion","Triple","Lattice","Banded","Ladder"],` +
5	`"default":"Seeded"},` +
6	`"loom":{"type":"string","title":"Loom","enum":["Fine","Coarse"],"default":"Fine"},` +
7	`"abrash":{"type":"boolean","title":"Abrash dye lots","default":true}}}`
source

ParamsSchema is the Studio form. Studio sends JSON.stringify of the values in this property order; ValidateParams accepts exactly that or "".

Functions 8

func Manifest

1func Manifest() engine.Manifest
source

Manifest describes the engine. Author and FeeBps are set by the adapter.

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 string, cfg Config) string
source

SVG renders the artwork for a seed under cfg.

func Traits

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

Traits returns the eight traits of in.Seed in TraitTypes order. It never renders: seven table draws and a score.

func ValidateParams

1func ValidateParams(params string) error
source

ValidateParams accepts "" (the showcase defaults) and the canonical JSON.

func Defaults

1func Defaults() Config
source

Defaults is the showcase look (params "").

func ParseParams

1func ParseParams(params string) (Config, error)
source

ParseParams accepts "" or the canonical JSON Studio produces, nothing else.

func TraitsOf

1func TraitsOf(seed string, cfg Config) TraitSet
source

TraitsOf returns the decoded traits for a seed.

Types 2

type Config

struct
1type Config struct {
2	Dyes   int  // -1: drawn from the seed, else an index into the dye table
3	Field  int  // -1: drawn from the seed, else an index into the field table
4	Coarse bool // 27 x 41 cells of 26 px instead of 37 x 55 cells of 20 px
5	Abrash bool // false: no dye-lot bands (Abrash "None")
6}
source

Config is a parsed params string.

type TraitSet

struct
1type TraitSet struct {
2	Dyes, Field, Motif, Border, Abrash, Symmetry, Fringe string
3	Score                                                int
4	Rarity                                               string
5}
source

TraitSet is the decoded properties of a seed under a config.

Dependencies

Source Files 2