bonsai

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package bonsai grows procedural ASCII bonsai trees in the terminal.

It is a tcell-based port of cbonsai (https://gitlab.com/jallbrit/cbonsai). The public surface is intentionally small: build an Options value and call Run. The package owns the screen lifetime; on return the terminal is restored.

Index

Constants

View Source
const (
	PotBig   = 1
	PotSmall = 2
)

Pot kinds accepted by Options.Pot.

View Source
const (
	AlignCenter = int(center)
	AlignLeft   = int(left)
	AlignRight  = int(right)
)

Alignment values accepted by Options.Align.

Variables

This section is empty.

Functions

func Run

func Run(o Options) error

Run grows a tree according to o. It blocks until the user quits (Esc / Ctrl-C / Ctrl-D) or, in non-infinite non-print mode, until any keypress after the first tree finishes drawing. On return, the terminal is restored.

Types

type Options

type Options struct {
	Seed         int64         // 0 -> time.Now().UnixNano()
	Life         int           // 0 -> 32, clamped to [1,127]
	Multiplier   int           // 0 -> 5, clamped to [0,20]
	Pot          int           // 0 -> PotBig
	Align        int           // 0 -> AlignCenter
	Leaves       []string      // nil -> []string{"&"}
	Message      string        // optional message box
	MsgX, MsgY   int           // upper-left of message; defaults 4,2
	BaseX, BaseY int           // overrides for pot position; 0 = auto-center
	Print        bool          // dump tree to stdout and exit
	Live         bool          // animate growth step-by-step
	Step         time.Duration // delay between live steps; 0 -> 33ms
	Infinite     bool          // keep regrowing until quit
	Wait         time.Duration // delay between trees in infinite mode; 0 -> 4s
	Screensaver  bool          // implies Live + Infinite, exits on any keypress
}

Options configures a single Run. Zero values pick cbonsai-compatible defaults inside Run, so callers can pass an empty Options{} for "just grow a tree".

type Pot

type Pot struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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