Documentation
¶
Overview ¶
Package piglogin is PiG's built-in sprite login: the sprite's 16-by-14 pig, which the startup header shows in Pi's logo slot, the full login art (the 12-pixel "PiG." hero wordmark with its drop shadow beside that pig) that /sprite preview shows, the sprites `/sprite` chooses from, and the selection kept under $PIG_HOME/state/pig-standard/login.json.
The artwork, sprite names and colors, the login definition and the golden renders of the color sprites and the sheriff are PiG Standard's piglogin extension (piglets/standard/extensions/piglogin at MichaelKinsy/PiG d86eb93), written by Michael Kinsy and carried by Pigpen's pig-login Package. Its LICENSE is MIT, Copyright Hewlett Packard Enterprise Development LP. The character sprites (PiGrogu, Darth Vader, Kratos, Piglet, Spider-Ham) are the owner's earlier PiG piglogin. The pixel data is unchanged.
pig divergence (D2): Pi's startup header draws Pi's logo (pi-logo.ts, interactive-mode.ts:998-1006); PiG draws the sprite's pig.
Index ¶
- Constants
- Variables
- func Activate(id string) error
- func ArtLines(variant Variant, mode tui.TerminalColorMode) []string
- func ConfigHome() string
- func CreatePrompt() string
- func Extension() (extension.Extension, error)
- func HeadFor(variant Variant) []string
- func HeadLines(variant Variant, mode tui.TerminalColorMode) []string
- func IDs() string
- func LoginDefinitionFor(variant Variant) extension.LoginDefinition
- func MascotPalette(variant Variant) map[byte]color.RGBA
- func MascotSpriteFor(variant Variant) []string
- func PreviewLines(variant Variant, mode tui.TerminalColorMode) []string
- func Refresh()
- func Register(owner string, definition extension.ValidatedSpriteDefinition) error
- func SaveVariant(configHome, id string) error
- func StatePath(configHome string) string
- func TextMark(variant Variant, mode tui.TerminalColorMode) string
- func Unregister(owner string)
- type HeadPixel
- type Logo
- type Variant
Constants ¶
const ( HeadWidth = extension.LoginMascotWidth HeadHeight = extension.LoginMascotHeight HeadCells = HeadWidth HeadRows = HeadHeight / 2 )
The pig head the startup header draws in Pi's logo slot is the sprite's 16-by-14 pig (MascotSpriteFor), the same pixels /sprite preview draws beside the wordmark: two pixel rows per line in half blocks, so HeadCells cells by HeadRows lines.
const ( ArtWidth = extension.LoginHeroWidth + artGap + extension.LoginMascotWidth ArtRows = extension.LoginHeroHeight / 2 )
ArtWidth and ArtRows are the cells of a sprite's full art: the 32-pixel "PiG." wordmark, a 3-pixel gap and the 16-pixel pig, 14 pixels tall, at two pixel rows per line.
const CreateHint = "" /* 179-byte string literal not displayed */
CreateHint explains how to create a sprite.
const CreateNeedsModel = "" /* 129-byte string literal not displayed */
CreateNeedsModel is what `/sprite create` shows when no model is selected.
const CreateOption = "Create your own..."
CreateOption is the last item of the sprite picker and of first-time setup's sprite step. Choosing it shows CreateHint and changes nothing.
const DefaultID = "pig-default"
DefaultID is the sprite used until one is selected.
const Name = "pig-login"
Name is the name of the built-in extension: its path is `builtin:pig-login`.
const TextMarkWidth = 4
TextMarkWidth is the cell width of the text mark. It is as wide as Pi's logo (pi-logo.ts, 4 cells), so key hints beside it wrap where Pi's do.
Variables ¶
var Variants = []Variant{ { ID: "pig-default", Name: "PiG", Tagline: "The minimal coding agent, in Go.", Body: rgb(0x48, 0xA3, 0x81), Highlight: rgb(0x64, 0xBE, 0x9E), Snout: rgb(0x32, 0x77, 0x5E), Blush: rgb(0x82, 0xDB, 0xBA), InnerEar: rgb(0x48, 0xA3, 0x81), PaletteOverrides: map[byte]color.RGBA{ 'O': rgb(0x18, 0x15, 0x1D), 'K': rgb(0x18, 0x15, 0x1D), 'W': rgb(0xFE, 0xFE, 0xFE), }, Logo: &Logo{ Ramp: flatRamp(rgb(0xE8, 0xF4, 0xF0)), Shadow: rgb(0x18, 0x30, 0x2C), Period: rgb(0x16, 0x86, 0x6F), }, }, { ID: "pink", Name: "Classic PiG", Tagline: "Pink, polite, and patient.", Body: rgb(0xFF, 0xA8, 0xB7), Highlight: rgb(0xFF, 0xC4, 0xCE), Snout: rgb(0xE8, 0x83, 0x96), Blush: rgb(0xFF, 0x86, 0x9A), InnerEar: rgb(0xFF, 0x90, 0xA4), }, { ID: "green", Name: "Green PiG", Tagline: "Ready to build.", Body: rgb(0x16, 0xA3, 0x6A), Highlight: rgb(0x45, 0xC8, 0x91), Snout: rgb(0x0F, 0x7A, 0x50), Blush: rgb(0x77, 0xD9, 0xAC), InnerEar: rgb(0x16, 0xA3, 0x6A), }, { ID: "mint", Name: "Mint PiG", Tagline: "Refactors before breakfast.", Body: rgb(0xC8, 0xF0, 0xDD), Highlight: rgb(0xDF, 0xF6, 0xEB), Snout: rgb(0x96, 0xD0, 0xB4), Blush: rgb(0xF4, 0x9A, 0xA6), InnerEar: rgb(0xB8, 0xE4, 0xCF), }, { ID: "sandy", Name: "Sandy PiG", Tagline: "All tabs, no spaces.", Body: rgb(0xE8, 0xC8, 0x9A), Highlight: rgb(0xF4, 0xDB, 0xAF), Snout: rgb(0xC0, 0x99, 0x66), Blush: rgb(0xE8, 0x83, 0x96), InnerEar: rgb(0xD8, 0xAC, 0x78), }, { ID: "grey", Name: "Slate PiG", Tagline: "Reads RFCs for fun.", Body: rgb(0xB6, 0xB2, 0xC0), Highlight: rgb(0xD2, 0xCF, 0xDB), Snout: rgb(0x88, 0x84, 0x95), Blush: rgb(0xE8, 0x83, 0x96), InnerEar: rgb(0xA2, 0x9E, 0xB0), }, { ID: "blush", Name: "Rosy PiG", Tagline: "Compiles with feelings.", Body: rgb(0xFF, 0xB8, 0xC9), Highlight: rgb(0xFF, 0xD4, 0xDD), Snout: rgb(0xE8, 0x6E, 0x88), Blush: rgb(0xFF, 0x52, 0x6E), InnerEar: rgb(0xFF, 0x8C, 0xA2), }, { ID: "lavender", Name: "Lavender PiG", Tagline: "Dreams in async.", Body: rgb(0xC9, 0xB4, 0xEA), Highlight: rgb(0xDD, 0xCC, 0xF2), Snout: rgb(0x9F, 0x82, 0xC4), Blush: rgb(0xE8, 0x83, 0x96), InnerEar: rgb(0xB6, 0x9D, 0xDC), }, { ID: "cloud", Name: "Cloud PiG", Tagline: "Lives at 99.99% uptime.", Body: rgb(0xB0, 0xD8, 0xEC), Highlight: rgb(0xCC, 0xE8, 0xF4), Snout: rgb(0x7C, 0xAE, 0xC8), Blush: rgb(0xF4, 0x9A, 0xA6), InnerEar: rgb(0x9C, 0xCA, 0xE0), }, { ID: "pigrogu", Name: "PiGrogu", Tagline: "Passing tests, this is the way.", Sprite: pigMascotPiGrogu, Body: rgb(0x8B, 0xB5, 0x70), Highlight: rgb(0xB7, 0xD4, 0x96), Snout: rgb(0x72, 0x99, 0x5B), Blush: rgb(0xA8, 0xC9, 0x87), InnerEar: rgb(0xC7, 0x8E, 0x94), PaletteOverrides: map[byte]color.RGBA{ 'B': rgb(0xB7, 0x98, 0x6D), 'b': rgb(0x78, 0x5B, 0x3D), }, }, { ID: "darth-vader", Name: "Darth Vader", Tagline: "I find your lack of tests disturbing.", Sprite: pigMascotDarthVader, Body: rgb(0x0B, 0x0C, 0x14), Highlight: rgb(0x2E, 0x31, 0x45), Snout: rgb(0x22, 0x24, 0x32), Blush: rgb(0xD8, 0x00, 0x00), InnerEar: rgb(0x16, 0x18, 0x24), PaletteOverrides: map[byte]color.RGBA{ 'O': rgb(0x03, 0x03, 0x07), 'K': rgb(0x00, 0x00, 0x03), }, }, { ID: "kratos", Name: "Kratos", Tagline: "War on bugs.", Sprite: pigMascotKratos, Body: rgb(0xD1, 0xC7, 0xB5), PaletteOverrides: map[byte]color.RGBA{ 'E': rgb(0xD1, 0xC7, 0xB5), 'e': rgb(0xAD, 0xA1, 0x91), 's': rgb(0xA6, 0x48, 0x32), 'R': rgb(0x91, 0x1F, 0x1F), 'W': rgb(0xB5, 0xBE, 0xBE), 'O': rgb(0x16, 0x12, 0x11), 'K': rgb(0x16, 0x12, 0x11), }, }, { ID: "piglet", Name: "Piglet", Tagline: "A Very Small Animal with very large diffs.", Sprite: pigMascotPiglet, Body: rgb(0xF6, 0xA6, 0xB6), Highlight: rgb(0xFF, 0xC5, 0xCF), Snout: rgb(0xE8, 0x6F, 0x88), Blush: rgb(0xE8, 0x6F, 0x88), InnerEar: rgb(0xF0, 0x6A, 0x8A), PaletteOverrides: map[byte]color.RGBA{ 'R': rgb(0xD9, 0x1F, 0x4E), 'r': rgb(0xA8, 0x0F, 0x38), }, }, { ID: "spider-ham", Name: "Spider-Ham", Tagline: "Does whatever a spider can.", Sprite: pigMascotSpiderHam, Body: rgb(0xE6, 0x24, 0x29), Highlight: rgb(0xFF, 0x4A, 0x4F), Snout: rgb(0xA9, 0x13, 0x1B), Blush: rgb(0xFF, 0x4A, 0x4F), InnerEar: rgb(0xC8, 0x18, 0x20), PaletteOverrides: map[byte]color.RGBA{ 'R': rgb(0xE6, 0x24, 0x29), 'r': rgb(0x7A, 0x11, 0x18), 'O': rgb(0x12, 0x0B, 0x0D), 'K': rgb(0x12, 0x0B, 0x0D), }, }, { ID: "sheriff", Name: "Sheriff PiG", Tagline: "Laying down the law, one commit at a time.", Sprite: pigMascotSheriff, Body: rgb(0xF2, 0xB8, 0xA8), Highlight: rgb(0xFF, 0xD2, 0xC7), Snout: rgb(0xD9, 0x89, 0x78), Blush: rgb(0xD9, 0x5F, 0x4C), InnerEar: rgb(0xE7, 0x98, 0x88), PaletteOverrides: map[byte]color.RGBA{ 'H': rgb(0x6B, 0x4C, 0x3A), 'h': rgb(0x8B, 0x6F, 0x47), 'S': rgb(0xFF, 0xD7, 0x00), }, }, }
Variants is the built-in catalogue in /sprite order: the default first, then the color sprites, then the characters. The first entry is the default fallback. Every built-in variant is original PiG artwork.
Functions ¶
func Activate ¶
Activate saves the selection under ConfigHome and makes it the active sprite. An unknown ID or a failed save leaves the active sprite unchanged.
func ArtLines ¶
func ArtLines(variant Variant, mode tui.TerminalColorMode) []string
ArtLines draws the variant's full art, the wordmark and the pig of its login definition (LoginDefinitionFor), the scene the native login template draws, in half blocks.
func ConfigHome ¶
func ConfigHome() string
ConfigHome is $PIG_HOME, else ~/.pig. The Pigpen games read the selection from the same root (the SDK's ConfigHome), so XDG_CONFIG_HOME does not move it.
func CreatePrompt ¶
func CreatePrompt() string
CreatePrompt is the user turn `/sprite create` sends: it asks the model to design a sprite with the user and write a TypeScript extension that registers it in the run's global extensions directory, starting from the default pig's mascot and palette.
func Extension ¶
Extension is the built-in `pig-login` extension. It registers `/sprite`, which chooses the sprite the startup header shows. The header itself is the host's built-in header (the one Pi's setHeader(undefined) restores), which draws the active sprite's head, so an extension replaces it with setHeader exactly as in Pi. `/sprite preview` shows a sprite's full art, the wordmark and the pig, in an overlay until a key is pressed.
func HeadLines ¶
func HeadLines(variant Variant, mode tui.TerminalColorMode) []string
HeadLines draws the variant's pig head in half blocks, HeadCells cells wide on each of HeadRows lines: the upper half block in the top pixel's color over the bottom pixel's, the lower half block where only the bottom pixel is opaque. Every cell ends in a reset, so a transparent pixel shows the terminal's background.
func LoginDefinitionFor ¶
func LoginDefinitionFor(variant Variant) extension.LoginDefinition
LoginDefinitionFor expresses a sprite through the native login contract (ctx.ui.setLogin): the hero "PiG." wordmark, the mascot pig and the palette that colors them. The built-in startup header draws its art from this definition, and an extension that sets the same definition draws the same pixels.
func MascotPalette ¶
MascotPalette returns the resolved colors for every mascot symbol of a variant. '.' is transparent.
func MascotSpriteFor ¶
MascotSpriteFor returns the variant-specific mascot or the standard mascot.
func PreviewLines ¶
func PreviewLines(variant Variant, mode tui.TerminalColorMode) []string
PreviewLines are the lines of /sprite preview: the sprite's full art, then its name and tagline and how to close it.
func Refresh ¶
func Refresh()
Refresh makes the next Active read the saved selection again: a game or another PiG may have written it.
func Register ¶
func Register(owner string, definition extension.ValidatedSpriteDefinition) error
Register adds an extension's sprite, or replaces the sprite with the same ID that the same extension registered. An ID taken by a built-in sprite or by another extension's sprite is an error. pig divergence (D2): extension sprites join the built-in ones in /sprite; Pi has no sprites.
func SaveVariant ¶
SaveVariant saves the selection under configHome in an owner-only file.
func StatePath ¶
StatePath is where the selection lives under configHome. The directory name is PiG Standard's, so a selection made there carries over and the games find it.
func TextMark ¶
func TextMark(variant Variant, mode tui.TerminalColorMode) string
TextMark is the one-line "PiG." mark for a terminal that cannot draw the pixel art. "PiG" is bold and each letter takes a mid or dark stop of the variant's wordmark ramp, the way Pi's text wordmark colors "Pi"; a stop that would not read on both light and dark backgrounds gives way to the period color. The period takes the wordmark's period color.
Types ¶
type HeadPixel ¶
HeadPixel is one opaque pixel of a pig head: its column and row in the HeadWidth by HeadHeight grid, its symbol and its color.
func HeadPixels ¶
HeadPixels returns the opaque pixels of the variant's pig head in row-major order, the pixels HeadLines draws.
type Logo ¶
type Logo struct {
// Ramp colors the letter rows from top to bottom.
Ramp [logoRows]color.RGBA
// Shadow is the one-pixel drop shadow below and right of every glyph.
Shadow color.RGBA
// Period colors the trailing period, the accent of the website wordmark.
Period color.RGBA
}
Logo colors the hero "PiG." wordmark.
type Variant ¶
type Variant struct {
ID string
Name string
Tagline string
// Sprite is the 16-by-14 pig: the head the startup header draws and the mascot of /sprite preview. Nil draws the
// standard pig.
Sprite []string
Body color.RGBA
Highlight color.RGBA
Snout color.RGBA
Blush color.RGBA
InnerEar color.RGBA
PaletteOverrides map[byte]color.RGBA
// Logo colors the hero wordmark. Nil uses the classic gradient with the
// period in the variant's body color.
Logo *Logo
}
Variant is one entry in the PiG sprite catalogue.
func Active ¶
func Active() Variant
Active is the sprite the header shows now: the saved one, or the default when it is unknown or its extension has not registered it.
func All ¶
func All() []Variant
All lists every sprite /sprite offers: the built-in catalogue, then the registered sprites.
func ByID ¶
ByID looks a sprite up by ID, among the built-in sprites and those extensions registered, and reports whether it exists.
func Default ¶
func Default() Variant
Default returns the default sprite, the first catalogue entry.
func FindVariant ¶
FindVariant looks up by ID. It returns the default when the ID is unknown.
func LoadVariant ¶
LoadVariant reads the selection saved under configHome. A missing, unreadable or unknown selection is the default.