pseudo

package
v0.0.0-...-b362443 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package pseudo turns the compact, text-friendly "pseudo-image" descriptions that ANY ordinary (non-diffusion) language model can emit into real graphics: a terminal.Frame for the live renderer, or an image.Image for the BABE video path. It is the answer to "let a plain chat model paint" — the model speaks a few tokens of JSON (a coarse color grid, a glyph map, a list of sigils, or vector shapes) and this package deterministically expands it into a picture.

Formats (all producible by a text model with no image head):

  • grid : a coarse grid of named colors -> bilinear "pseudo-diffusion"
  • pixels : the same grid rendered crisp (mosaic / pixel art)
  • glyphs : a character grid + a char->color palette (colored ASCII/Unicode art)
  • sigils : named pictographs (sun, moon, star, mountain...) placed on a canvas
  • vector : the full draw-DSL (pkg/scene): rects, discs, gradients, text
  • sketch : the weak-model sketch format (pkg/sketch): named scene shapes

"Pseudo-diffusion" is the grid path: a 12x8-ish color seed is upscaled and blurred into a smooth, painterly raster — visually diffusion-like, but with no diffusion model, no GPU, and fully deterministic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Color

func Color(tok string, def color.RGB) color.RGB

Color resolves a token to an RGB: a palette name, "#rrggbb"/"#rgb", or "r,g,b".

func RasterizeFrame

func RasterizeFrame(f *terminal.Frame, w, h int) image.Image

RasterizeFrame turns a terminal.Frame (grid of colored cells) into an RGBA image of the requested pixel size: a drawn glyph takes its foreground color, blank cells take their background. This lets cell-native formats (glyphs, sigils, vector, sketch) flow through the BABE -> terminal video path.

func Render

func Render(doc []byte) (*terminal.Frame, error)

Render parses a pseudo-image spec document and renders it to a Frame.

Types

type Format

type Format string

Format names a pseudo-image encoding.

const (
	FormatGrid   Format = "grid"
	FormatPixels Format = "pixels"
	FormatGlyphs Format = "glyphs"
	FormatSigils Format = "sigils"
	FormatVector Format = "vector"
	FormatSketch Format = "sketch"
	FormatMixed  Format = "mixed"
	FormatMarks  Format = "marks"
)

type GlyphArt

type GlyphArt struct {
	Rows    []string          `json:"rows"`              // lines of characters
	Palette map[string]string `json:"palette,omitempty"` // single-char key -> color token
	Bg      string            `json:"bg,omitempty"`      // background color token
	Fg      string            `json:"fg,omitempty"`      // default foreground token
	// contains filtered or unexported fields
}

GlyphArt is colored ASCII / Unicode art: lines of characters plus an optional per-character color map. This is the most natural format for a text model — it literally "types the picture" and tags which character is which color.

type Grid

type Grid struct {
	Rows [][]string `json:"rows"`
	// contains filtered or unexported fields
}

Grid is a coarse grid of color tokens — the smallest "image" a text model can emit. Rows may be ragged; they are normalized to a rectangle on render.

func (*Grid) DiffuseFrames

func (g *Grid) DiffuseFrames(pxW, pxH, steps int) []image.Image

DiffuseFrames produces a deterministic "denoising" animation: seeded RGB noise resolves into the pseudo-diffusion target over the given number of steps, with blur fading out as the picture sharpens. Handy for transitions and demos.

type Label

type Label struct {
	Text  string  `json:"text"`
	X     float64 `json:"x"`
	Y     float64 `json:"y"`
	Color string  `json:"color,omitempty"`
}

Label is a short text caption placed at a normalized (0..1) position.

type MarkArt

type MarkArt struct {
	Rows   [][]string `json:"rows"`             // grid of mark tokens
	Colors [][]string `json:"colors,omitempty"` // optional parallel grid of color tokens
	Bg     string     `json:"bg,omitempty"`
	Fg     string     `json:"fg,omitempty"`
	// contains filtered or unexported fields
}

MarkArt is a picture composed from the sub-cell alphabet (pkg/glyphset): a grid of mark tokens (names like "tri-ll" or literal glyphs like ◣), with optional per-cell colors. It lets a text model draw with diagonals/triangles/quadrants — e.g. a mountain from ◣◢, a roof from ◤◥ — not just place sigils.

type Mixed

type Mixed struct {
	Grid   *Grid   `json:"grid,omitempty"`
	Sigils []Sigil `json:"sigils,omitempty"`
	Labels []Label `json:"labels,omitempty"`
	// contains filtered or unexported fields
}

Mixed layers crisp symbols and captions over a soft pseudo-diffusion grid: the best of both worlds — a painterly background a text model describes as a color grid, with sharp sigils/labels it places on top.

type Palette

type Palette map[string]color.RGB

Palette is a set of named-color overrides applied on top of the base palette, letting a model pick a mood ("neon", "ocean") without re-specifying colors.

type Sigil

type Sigil struct {
	Name  string  `json:"name"`
	X     float64 `json:"x"`
	Y     float64 `json:"y"`
	Color string  `json:"color,omitempty"`
}

Sigil is a single named pictograph placed at a normalized (0..1) position.

type SigilScene

type SigilScene struct {
	Bg     string  `json:"bg,omitempty"`
	Sky    string  `json:"sky,omitempty"`
	Ground string  `json:"ground,omitempty"`
	Items  []Sigil `json:"items"`
	Labels []Label `json:"labels,omitempty"`
	// contains filtered or unexported fields
}

SigilScene composes named pictographs over an optional sky/ground wash. This is the "hieroglyph / icon" route: a model picks symbols and where they go.

type Spec

type Spec struct {
	Format  Format          `json:"format"`
	Cols    int             `json:"cols,omitempty"`
	Rows    int             `json:"rows,omitempty"`
	Title   string          `json:"title,omitempty"`
	Grid    *Grid           `json:"grid,omitempty"`
	Pixels  *Grid           `json:"pixels,omitempty"`
	Glyphs  *GlyphArt       `json:"glyphs,omitempty"`
	Sigils  *SigilScene     `json:"sigils,omitempty"`
	Vector  json.RawMessage `json:"vector,omitempty"`
	Sketch  json.RawMessage `json:"sketch,omitempty"`
	Mixed   *Mixed          `json:"mixed,omitempty"`
	Marks   *MarkArt        `json:"marks,omitempty"`
	Palette string          `json:"palette,omitempty"` // preset: dawn|dusk|neon|mono|forest|ocean
}

Spec is the unified request a text model fills in. It picks one Format and supplies the matching payload; Cols/Rows are the target terminal size.

func (Spec) Frame

func (s Spec) Frame() (*terminal.Frame, error)

Frame renders the spec to a terminal.Frame for the live renderer.

func (Spec) Image

func (s Spec) Image(pxW, pxH int) (image.Image, error)

Image renders the spec to an RGBA raster of the given pixel size, suitable for the BABE -> terminal video path (downsampled later by the renderer).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL