render

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package render holds the visual constant tables shared across screens — body color palette, UI tier colors for status / nodes / trajectory.

v0.7.1+: per-body color lives on bodies.CelestialBody.Color (a hex string in systems/*.json). The hardcoded bodyPalette table here stays as a backward-compat fallback for callers / tests that construct CelestialBody literals without a Color field; v0.8 will drop the table once v0.7.1+ saves are in the wild.

Index

Constants

View Source
const (
	ColorEarthOcean  = lipgloss.Color("#3D7AAB")
	ColorEarthLand   = lipgloss.Color("#5C8C4A")
	ColorEarthDesert = lipgloss.Color("#B59565")
	ColorEarthIce    = lipgloss.Color("#E8EFF5")
	ColorEarthCloud  = lipgloss.Color("#F2F5FA")
)

Earth-surface palette. The base color is intentionally darker than the v0.5.1 #5BB3FF "Earth blue" so land + cloud splotches read against it; the existing palette entry stays the public face for HUD labels and the body-info screen.

View Source
const (
	ColorJupiterZone = lipgloss.Color("#D7B98C") // bright zone (warm)
	ColorJupiterBelt = lipgloss.Color("#8B6240") // dark belt (warm)
	ColorJupiterPole = lipgloss.Color("#7A6450") // muted polar haze
	ColorJupiterGRS  = lipgloss.Color("#A03A28") // Great Red Spot
)

Jupiter-surface palette. Banded ochre clouds — alternating zones (bright) and belts (dark) running parallel to the equator, with the Great Red Spot painted on top.

View Source
const (
	ColorMarsRust   = lipgloss.Color("#B7553A") // base regolith
	ColorMarsDark   = lipgloss.Color("#7A3422") // dark albedo features
	ColorMarsBright = lipgloss.Color("#D9A07A") // bright high-albedo (Arabia)
	ColorMarsIce    = lipgloss.Color("#F0E8E0") // polar caps (CO₂ frost)
)

Mars-surface palette. Base is the hand-eye "rust" tone; darker basaltic regions and lighter polar caps layer on top via the continent-ellipse machinery shared with Earth (see earth.go's continentEllipse type).

View Source
const (
	ColorMoonHighland = lipgloss.Color("#C8C8C8") // matches the legacy bodyPalette["moon"]
	ColorMoonMare     = lipgloss.Color("#5A5A65") // dark basalt, slightly cool grey-blue
	ColorMoonRay      = lipgloss.Color("#F0F0F0") // crater ejecta + fresh ray systems
)

Lunar-surface palette. Highland is the lighter regolith that dominates the southern half + far side; mare is the dark basalt flooding the northeastern near side ("man in the moon" pattern); ray is the very-bright ejecta around fresh impacts (Tycho, Copernicus). Picks tuned so all three read distinctly against the canvas dark background.

View Source
const BodyTextureMinRadius = 12

BodyTextureMinRadius is the minimum body pixel radius at which the per-pixel body textures render. Below this, the body falls back to a solid-color disk because (a) the disk has too few cells to read a continent / mare shape, and (b) the textured fill is more expensive per pixel than a plain disk.

View Source
const EarthTextureMinRadius = BodyTextureMinRadius

EarthTextureMinRadius is the legacy name for BodyTextureMinRadius, preserved for callers / tests that referenced the Earth-specific constant. Drop in v0.8 alongside other v0.7 cleanup.

Variables

View Source
var (
	ColorAlert        = lipgloss.Color("#FF5F5F") // hard errors, peri-below-surface
	ColorWarning      = lipgloss.Color("#FFAF00") // warp clamps, near-collision
	ColorPlannedNode  = lipgloss.Color("#5FD7FF") // maneuver-node markers
	ColorTrajectory   = lipgloss.Color("#FFFFFF") // fallback trajectory preview
	ColorCurrentOrbit = lipgloss.Color("#A8B8C8") // craft's live Keplerian ellipse — pale slate, distinct from any body palette and from maneuver-leg colors
	ColorCraftMarker  = lipgloss.Color("#FFD93D") // craft icon when zoomed out (orbit too small to render) — saturated yellow distinct from Sun gold-white, amber leg, and every body color
	ColorForeignSOI   = lipgloss.Color("#D75FFF") // post-SOI-crossing trajectory segments
	ColorDim          = lipgloss.Color("#5F5F5F") // background / inactive
)

UI tier colors — used for non-body UI elements that need consistent semantic colors across screens. Independent of the body palette so editing one doesn't shift the other.

Functions

func BodyHasTexture added in v0.7.3

func BodyHasTexture(b bodies.CelestialBody, pxRadius int) bool

BodyHasTexture reports whether TextureFor would return non-nil. Convenience wrapper for callers that just need the boolean (e.g. "should I suppress the body-identity glyph?").

func BodyRings added in v0.5.11

func BodyRings(bodyID string) (innerR, outerR float64, ok bool)

BodyRings returns the inner and outer ring radii (meters from body center) for ringed bodies, or ok=false if the body has no renderable rings. Numbers are face-on simplifications — our equatorial-plane projection always shows rings as concentric circles, not the inclination-dependent ellipses real Saturn rings project to.

func ColorFor

func ColorFor(b bodies.CelestialBody) lipgloss.Color

ColorFor returns the palette color for a body. Resolution order:

  1. theme.json `bodies` override (v0.7.2+) keyed by body ID.
  2. b.Color (per-body JSON field, v0.7.1+) when non-empty.
  3. bodyPalette table (legacy hardcoded source-of-truth).
  4. StellarTint by temperature for stars without an explicit entry.
  5. Per-bodyType default.
  6. ColorTrajectory for unrecognised types.

func EarthPixelColor added in v0.7.3

func EarthPixelColor(dx, dy, pxRadius int) lipgloss.Color

EarthPixelColor returns the surface color for a pixel at offset (dx, dy) inside an Earth disk of pixel radius pxRadius. Caller is responsible for clipping pixels to the disk; for points within 1 px of the edge the projection clamps to the limb.

Projection: orthographic with sub-observer point at (lat=0, lon=earthCenterLon). v0.7.6+ derives absolute longitude from the pixel's relative longitude + earthCenterLon, so continents stored in absolute coordinates render at the right place on the disk.

Resolution order: ice cap > cloud > continents (in table order) > ocean. Polar caps win over everything else in their lat band so Antarctic ice doesn't get masked by a stray continent edge.

func GlyphFor added in v0.5.12

func GlyphFor(b bodies.CelestialBody) rune

GlyphFor returns the body-identity Unicode glyph for the given body. Used as a single-cell overlay on top of the body's drawille disk so different body types read distinctly even at small pixel- radius. v0.5.12+.

  • Star → ☉ (sun symbol)
  • Gas giant (radius > 20 000 km) → ◉ (fisheye)
  • Terrestrial planet → ● (filled circle)
  • Moon → ○ (open circle)

Returns 0 (zero rune) when no overlay is appropriate (e.g. system primary already has a ring+dot draw style and shouldn't be double-glyphed).

func JupiterPixelColor added in v0.7.6

func JupiterPixelColor(dx, dy, pxRadius int) lipgloss.Color

JupiterPixelColor returns the surface color for a pixel at (dx, dy) inside a Jupiter disk of pixel radius pxRadius. Banded zones from a latitude lookup; the GRS is layered on top at sub-observer-relative coordinates. v0.7.6+.

func LoadTheme added in v0.7.2

func LoadTheme() (*Theme, []LoadWarning, error)

LoadTheme reads the user theme overlay (if present) and applies it to package-level state. UI overrides mutate the Color* vars in place; body overrides land in bodyOverrides for ColorFor to consult. Returns the parsed Theme (nil if no file) plus any LoadWarnings (parse / I/O failures).

Idempotent — calling twice with the same file produces the same final state. Pre-existing UI defaults are restored before applying overrides so a second call with a smaller theme doesn't keep stale overrides from the first.

func ManeuverSegmentColor added in v0.6.1

func ManeuverSegmentColor(n int) lipgloss.Color

ManeuverSegmentColor returns the color for the post-maneuver-N orbit leg. N=0 is the orbit immediately after the first planted burn fires; N=1 the orbit after the second; etc. Wraps around the palette table.

func MarsPixelColor added in v0.7.6

func MarsPixelColor(dx, dy, pxRadius int) lipgloss.Color

MarsPixelColor returns the surface color for a pixel at offset (dx, dy) inside a Mars disk of pixel radius pxRadius. Mirrors EarthPixelColor's projection — orthographic, sub-observer at (lat=0, lon=marsCenterLon). v0.7.6+.

func MoonPixelColor added in v0.7.3

func MoonPixelColor(dx, dy, pxRadius int) lipgloss.Color

MoonPixelColor returns the surface color for a pixel at offset (dx, dy) inside a Moon disk of pixel radius pxRadius. Mirrors EarthPixelColor's structure: orthographic (dx,dy) → (lat, lon) projection, then ellipse-table lookup for mare / crater / highland classification. Resolution order: bright crater > mare > highland.

func StellarTint

func StellarTint(tempK float64) lipgloss.Color

StellarTint maps a star's effective temperature (Kelvin) to a rough visible-light color. Used for non-Sol stars that don't have a hand-picked entry in bodyPalette. Banding is coarse — five buckets covering M-dwarf through O-class.

func Style

Style returns a lipgloss.Style with the body's color as the foreground. Convenience wrapper for HUD / body-info text — call Style(b).Render("Earth") to print a colored label.

Types

type BodyTexture added in v0.7.3

type BodyTexture func(dx, dy, pxRadius int) lipgloss.Color

BodyTexture returns the per-pixel surface color for a textured body. Implementations live in body-specific files (earth.go, moon.go, ...) and assume the caller has already gated the pixel to inside the disk; for points within 1 px of the limb the projection clamps cleanly.

func TextureFor added in v0.7.3

func TextureFor(b bodies.CelestialBody, pxRadius int) BodyTexture

TextureFor returns the per-pixel texture function for the given body, or nil if the body should render as a solid disk (small radius, unsupported body). The dispatch hook for body-specific surface rendering — Mars caps, Jupiter banding, Saturn cloud bands plug in via additional cases here.

type LoadWarning added in v0.7.2

type LoadWarning struct {
	Path string
	Err  error
}

LoadWarning is the render-package counterpart to bodies.LoadWarning for theme-overlay parse failures. Defined locally so this package doesn't import bodies just to reuse the type.

func (LoadWarning) Error added in v0.7.2

func (w LoadWarning) Error() string

type Theme added in v0.7.2

type Theme struct {
	UI     map[string]string `json:"ui,omitempty"`
	Bodies map[string]string `json:"bodies,omitempty"`
}

Theme is the on-disk shape of the user's optional theme overlay, loaded from $XDG_CONFIG_HOME/terminal-space-program/theme.json (or ~/.config/... if XDG is unset). Both blocks are optional; missing keys fall through to v0.7.1's per-body Color JSON field and the legacy bodyPalette table.

Keys in UI match the lower-cased name of the corresponding package-level Color* var (without the "Color" prefix). Keys in Bodies match each body's id from systems/*.json.

Jump to

Keyboard shortcuts

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