graphics

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2025 License: BSD-2-Clause, Unlicense Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset  string = "\033[0m"
	Red    string = "\033[31m"
	Green  string = "\033[32m"
	Yellow string = "\033[33m"
	Blue   string = "\033[34m"
	Purple string = "\033[35m"
	Cyan   string = "\033[36m"
	Gray   string = "\033[37m"
	White  string = "\033[97m"
)
View Source
const (
	SplashScreen = iota
	AgentView
	MapView
)

Variables

This section is empty.

Functions

func ColorWrap

func ColorWrap(name string, str string) string

ColorWrap retrieves the color of a core component from a color table and returns it if it exists.

func CoreSplash

func CoreSplash() string

func CoreSplash2

func CoreSplash2() string

func CoreSplash3

func CoreSplash3() string

func CoreSplash4

func CoreSplash4() string

func CoreSplashOverTheTop

func CoreSplashOverTheTop() string

func DoSplash

func DoSplash()

DoSplash prints a splash to stdout.

func GetNextColor

func GetNextColor() string

GetNextColor iterates on supported colors and returns the next one.

func HexSplash

func HexSplash() string

func HexSplash2

func HexSplash2() string

func JawharSplash

func JawharSplash() string

jawhar

func KaneruSplash

func KaneruSplash() string

Kaneru

func L2Norm

func L2Norm(v vec2f) float64

L2Norm calculates the L2 norm of a two-component vector.

func MD5HashSplash

func MD5HashSplash() string

func MD5HashSplash2

func MD5HashSplash2() string

func NewNode

func NewNode(name string) *node

NewNode creates a new node.

func NewStreamingApplication

func NewStreamingApplication(ctx context.Context, cancel_func context.CancelFunc, names []string, rdrs []io.Reader, bb_addr string) error

NewStreaminingApplication launches a core process visualizer in the console.

func Plus

func Plus(v1, v2 vec2f) vec2f

Plus calculates the element-wise sum of two vectors.

func RandomSplash

func RandomSplash() string

RandomSplash returns a splash function at random.

func RandomVec2f

func RandomVec2f() vec2f

RandomVec2f returns a random two-component unit vector.

func ScalarMult

func ScalarMult(c float64, v vec2f) vec2f

ScalarMult calculates the product between a scalar and a vector.

func ShinzuiSplash

func ShinzuiSplash() string

Shinzui

func Sub

func Sub(v1, v2 vec2f) vec2f

Sub calculates the element-wise difference of two vectors.

func TcellFriendlyRandomSplash

func TcellFriendlyRandomSplash() string

TcellFriendlyRandomSplash returns a splash function at random that is compatible with tcell.

func Unit

func Unit(v vec2f) vec2f

Unit normalizes a vector to a unit vector.

func YadroSplash

func YadroSplash() string

Pronounced Yee dro (yadro)

Types

type Animation

type Animation interface {
	Update(elapsed float64)
	Draw(scr *MultiAgentMonitor)
	Done() <-chan struct{}
}

Animation bundles basic core animation functionality.

type Arranger

type Arranger interface {
	Arrange(agents []*node, screen_w int, screen_h int)
}

Arranger represents something that can position agents based on the screen.

type Artist

type Artist interface {
	Draw(scr *MultiAgentMonitor, agents []*node)
}

Artist represents somethat that can draw agents into the scene.

type BeamAnimation

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

BeamAnimation represents the source and destination vectors of a beam for node and data visualization in the map view.

type BusArranger

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

BusArranger defines the width and padding of a visualization bus. A bus allows users to visualize data flow in the core system.

func NewBusArranger

func NewBusArranger() *BusArranger

NewBusArranger creates a default BusArranger.

func (*BusArranger) Arrange

func (b *BusArranger) Arrange(nodes []*node, screen_w, screen_h int)

Arrange organizes and arranges nodes (representing agents) on the screen in a multiagent monitor.

type BusArtist

type BusArtist struct{}

BusArtist generates the graphics representing agent nodes on the bus.

func (*BusArtist) Draw

func (b *BusArtist) Draw(scr *MultiAgentMonitor, nodes []*node)

Draw generates the graphics representing agent nodes on the bus. This breaks any convenient reuse of the draw interface

type Drawable

type Drawable interface {
	Draw(tcell.Screen)
}

Drawable represents something that can draw itself into a scene.

type MultiAgentMonitor

type MultiAgentMonitor struct {
	tcell.Screen

	Windows   []*Window
	Active    int // Current agent being controlled
	ScreenIdx int // Currently shown screen
	// contains filtered or unexported fields
}

MultiAgentMonitor is the primary on-screen visualization structure for core.

func NewMultiAgentMonitor

func NewMultiAgentMonitor() *MultiAgentMonitor

NewMultiAgentMonitor creates a new MultiAgentMonitor for the current core run.

func (*MultiAgentMonitor) AddWindow

func (s *MultiAgentMonitor) AddWindow(name string, stdin io.Reader) *Window

AddWindow adds a window to the MultiAgentMonitor.

func (*MultiAgentMonitor) Draw

func (s *MultiAgentMonitor) Draw(elapsed float64)

Draw is a convenience function that calls on different draw functions based on the screen index (i.e. currently shown screen).

func (*MultiAgentMonitor) DrawAgentView

func (s *MultiAgentMonitor) DrawAgentView()

DrawAgentView generates a single agent view on the monitor screen.

func (*MultiAgentMonitor) DrawBorder

func (s *MultiAgentMonitor) DrawBorder(idx int, style tcell.Style)

DrawBorder creates a rectangular border on the view window.

func (*MultiAgentMonitor) DrawHeader

func (s *MultiAgentMonitor) DrawHeader(idx int, style tcell.Style)

DrawHeader creates a header bar on the MultiAgentMonitor.

func (*MultiAgentMonitor) DrawMapView

func (s *MultiAgentMonitor) DrawMapView(elapsed float64)

DrawMapView draws a map view on the MultiAgentMonitor screen.

func (*MultiAgentMonitor) DrawRectangle

func (s *MultiAgentMonitor) DrawRectangle(x, y, w, h int, char rune, style tcell.Style)

DrawRectangle draws a rectangle on the MultiAgentMonitor.

func (*MultiAgentMonitor) DrawSplash

func (s *MultiAgentMonitor) DrawSplash()

DrawSplash displays the MultiAgentMonitor's core splash on the screen.

func (*MultiAgentMonitor) DrawStatusLine

func (s *MultiAgentMonitor) DrawStatusLine(idx int, style tcell.Style)

DrawStatusLine draws a status line on the window.

func (*MultiAgentMonitor) GetNames

func (s *MultiAgentMonitor) GetNames() []string

GetNames retrieves the names of the windows in the MultiAgentMonitor.

func (*MultiAgentMonitor) GetWindowWidth

func (s *MultiAgentMonitor) GetWindowWidth() int

GetWindowWidth calculates and returns the width of the window.

func (*MultiAgentMonitor) InitializeMapView

func (s *MultiAgentMonitor) InitializeMapView(names []string)

InitializeMapView creates an initialized map view from a slice of node names.

Map views perform actions:

  1. arrange agents (sets state of graph)
  2. connect agents (draw any background dependent on agent position)
  3. draw "sends" (illustrate or update any "pew pew" information)

func (*MultiAgentMonitor) PutString

func (s *MultiAgentMonitor) PutString(x, y, w int, text string, style tcell.Style)

PutString generates center-justified text.

type PhysicsParticle

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

PhysicsParticle represents a physics-based particle for animation.

func NewPhysicsParticle

func NewPhysicsParticle(dst, src vec2f, vel vec2f) *PhysicsParticle

NewPhysicsParticle creates a new PhysicsParticle with initialized vectors.

func (*PhysicsParticle) Done

func (b *PhysicsParticle) Done() <-chan struct{}

Done signals that the PhysicsParticle process is done.

func (*PhysicsParticle) Draw

func (b *PhysicsParticle) Draw(scr *MultiAgentMonitor)

Draw visualizes the PhysicsParticle on the screen in the MultiAgentMonitor.

func (*PhysicsParticle) Update

func (b *PhysicsParticle) Update(elapsed float64)

Update updates the vectors of the PhysicsParticle.

type SplashFunc

type SplashFunc func() string

SplashFunc is an alias type for func() string for splashes.

type Window

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

Window represents the visualizer window.

func (*Window) Complete

func (w *Window) Complete()

Complete marks the process in the window as completed (freezes the spinner).

func (*Window) GetBuffer

func (w *Window) GetBuffer(h int) []string

GetBuffer extracts currently visualized strings based on the current position in the window's string buffer.

func (*Window) GetStatusString

func (w *Window) GetStatusString() string

GetStatusString returns a string describing the current Window.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳