Search Apps Documentation Source Content File Folder Download Copy Actions Download State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

v0 state

Back to all declarations

Size

untyped bigint

Size is the canvas edge length; the canvas is Size x Size cells.

Value

(16 <untyped> bigint)

palette

[]string (len=9)

palette maps a colour index to the block rendered for it. Index 0 is the blank canvas. Kept parallel to paletteNames.

Open
OID
09a813…f098:4
palette details (len=9)

+9 more Inspect slice

paletteNames

[]string (len=9)

paletteNames are the names Paint accepts, in palette order.

Open
OID
09a813…f098:6
paletteNames details (len=9)

+9 more Inspect slice

cells

[256]int

// palette index per cell, row-major

Open
OID
09a813…f098:8
cells details

Inspect array

painters

[256]string

Package-level persistent state.

Open
OID
09a813…f098:10
painters details

Inspect array

tally

*v0.Tree

// address string -> \*int paint count

Open
OID
09a813…f098:12
tally details

Inspect pointer

strokes

int

// total paints ever

Value

0

lastAt

int64

// height of the most recent paint

Value

0

Paint

func(x int, y int, colour string) int

Paint colours the cell at (x, y) and returns the total number of strokes. Coordinates are 0-based with (0,0) at the top-left. Colour is a palette name ("red", "blue", …) — see Palette. Painting over an existing cell is allowed: the canvas is last-write-wins, which is the whole point of a shared board.

Open
OID
09a813…f098:16
Paint details

Inspect func

colourIndex

func(name string) int

colourIndex resolves a palette name to its index, or -1.

Open
OID
09a813…f098:18
colourIndex details

Inspect func

bump

func(addr string)

bump increments an address's paint tally.

Open
OID
09a813…f098:19
bump details

Inspect func

At

func(x int, y int) string

At returns the palette name of the cell at (x, y), or "" when out of bounds.

Open
OID
09a813…f098:20
At details

Inspect func

PainterAt

func(x int, y int) string

PainterAt returns the address that last painted (x, y), or "" if untouched.

Open
OID
09a813…f098:21
PainterAt details

Inspect func

Strokes

func() int

Strokes returns how many paints the canvas has taken.

Open
OID
09a813…f098:22
Strokes details

Inspect func

Palette

func() string

Palette returns the accepted colour names, comma-separated.

Open
OID
09a813…f098:23
Palette details

Inspect func

scorer

type

scorer is one row of the contribution leaderboard.

Value

v0.scorer

byCount

type

byCount ranks painters by strokes descending, ties broken on address so the board is deterministic.

Value

v0.byCount

Render

func(path string) string

Render renders the canvas for gnoweb. Render("") / Render("/") -> the canvas, palette and leaderboard Render("/<x>,<y>") -> who painted that cell, and what colour

Open
OID
09a813…f098:24
Render details

Inspect func

grid

func() string

grid renders the canvas as rows of coloured blocks.

Open
OID
09a813…f098:25
grid details

Inspect func

leaderboard

func() string

leaderboard renders the top painters, or "" when nobody has painted.

Open
OID
09a813…f098:26
leaderboard details

Inspect func

renderCell

func(q string) string

renderCell renders a single "x,y" lookup.

Open
OID
09a813…f098:27
renderCell details

Inspect func

parseArg

func(path string) string

parseArg extracts the first path segment.

Open
OID
09a813…f098:28
parseArg details

Inspect func

parseCoord

func(s string) (int, int, bool)

parseCoord parses "x,y" and reports whether it is in bounds.

Open
OID
09a813…f098:29
parseCoord details

Inspect func
Size : untyped bigint =(16 <untyped> bigint)
palette : []string (len=9) Inspect
paletteNames : []string (len=9) Inspect
cells : [256]int Inspect
painters : [256]string Inspect
tally : *v0.Tree Inspect
strokes : int =0
lastAt : int64 =0
Paint : func(x int, y int, colour string) int Inspect
colourIndex : func(name string) int Inspect
bump : func(addr string) Inspect
At : func(x int, y int) string Inspect
PainterAt : func(x int, y int) string Inspect
Strokes : func() int Inspect
Palette : func() string Inspect
scorer : type =v0.scorer
byCount : type =v0.byCount
Render : func(path string) string Inspect
grid : func() string Inspect
leaderboard : func() string Inspect
renderCell : func(q string) string Inspect
parseArg : func(path string) string Inspect
parseCoord : func(s string) (int, int, bool) Inspect