Documentation
¶
Overview ¶
Package canvas owns the fixed 80x24 cell grid that the lobby and every game render into. The Cell type and the Grid type are defined here and aliased by the game SDK; a single shared definition governs every composed frame.
Index ¶
Constants ¶
const ( Cols = 80 Rows = 24 )
The fixed drawable canvas. This is a system-wide invariant in v1.
Variables ¶
var ( White = RGB(0xff, 0xff, 0xff) Black = RGB(0x00, 0x00, 0x00) Red = RGB(0xff, 0x55, 0x55) Green = RGB(0x55, 0xff, 0x55) Yellow = RGB(0xff, 0xff, 0x55) Blue = RGB(0x55, 0x99, 0xff) Cyan = RGB(0x55, 0xff, 0xff) Magenta = RGB(0xff, 0x77, 0xff) DimGray = Gray(0x6c) )
Some shared palette entries used by the lobby and games.
Functions ¶
func GridToASCII ¶
GridToASCII renders g as a deterministic, color-independent text block: every cell's rune (rune 0 → space), trailing spaces trimmed per row, and the 24 rows joined with "\n" (no trailing newline). It is stable across runs for identical grid content — color and attribute differences do not affect the output — so it is suitable for before/after snapshot artifacts and golden tests.
Types ¶
type Cell ¶
type Cell struct {
Rune rune
Cp2 rune // second grapheme code point (0 = unused)
Cp3 rune // third grapheme code point (0 = unused)
FG Color
BG Color
Attr Attr
Cont bool // continuation column of a wide rune to the left
}
Cell is a single drawable position: a rune plus foreground/background color and attributes. A double-width rune occupies two columns; the trailing column is a continuation cell (Cont == true, Rune == 0).
In ABI v2 a cell may carry up to three code points of a grapheme cluster: Rune is the base, Cp2/Cp3 the extra code points (0 = unused; e.g. a VS16 selector, a skin-tone modifier, a ZWJ piece, or a keycap U+20E3). Renderers emit base+Cp2+Cp3 as one contiguous UTF-8 burst. Single-code-point cells leave Cp2/Cp3 zero by zero-value, so existing content is unchanged.
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
Color is a truecolor source value. The renderer downgrades it per the session's color depth at encode time; the canvas itself only stores the authoritative RGB (or "default / unset").
type Grid ¶
Grid is the fixed Rows x Cols cell grid. It is intrinsically 80x24, so a game can never accidentally exceed the canvas. It is passed by value as a Frame.
func (*Grid) SetRune ¶
SetRune writes one rune with a style. Out-of-bounds is dropped. Width is treated as 1 (v1 corpus is ASCII); callers wanting wide-rune handling should pre-account for the continuation column.