crt

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: MIT Imports: 18 Imported by: 1

README

crt

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFace

func LoadFace(file string, dpi float64, size float64) (font.Face, error)

LoadFace loads a font face from a file. The dpi and size are used to generate the font face.

Example: LoadFace("./fonts/Mono-Regular.ttf", 72.0, 16.0)

Types

type ChangeScrollingRegionSeq

type ChangeScrollingRegionSeq struct {
	Top    int
	Bottom int
}

type ConcurrentRW

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

func NewConcurrentRW

func NewConcurrentRW() *ConcurrentRW

func (*ConcurrentRW) Read

func (rw *ConcurrentRW) Read(p []byte) (n int, err error)

func (*ConcurrentRW) Run

func (rw *ConcurrentRW) Run()

func (*ConcurrentRW) Write

func (rw *ConcurrentRW) Write(p []byte) (n int, err error)

type CursorBackSeq

type CursorBackSeq struct {
	Count int
}

type CursorDownSeq

type CursorDownSeq struct {
	Count int
}

type CursorForwardSeq

type CursorForwardSeq struct {
	Count int
}

type CursorHorizontalSeq

type CursorHorizontalSeq struct {
	Count int
}

type CursorNextLineSeq

type CursorNextLineSeq struct {
	Count int
}

type CursorPositionSeq

type CursorPositionSeq struct {
	Row int
	Col int
}

type CursorPreviousLineSeq

type CursorPreviousLineSeq struct {
	Count int
}

type CursorUpSeq

type CursorUpSeq struct {
	Count int
}

type DeleteLineSeq

type DeleteLineSeq struct {
	Count int
}

type EmptyAdapter

type EmptyAdapter struct{}

func NewEmptyAdapter

func NewEmptyAdapter() *EmptyAdapter

func (*EmptyAdapter) HandleKeyPress

func (e *EmptyAdapter) HandleKeyPress()

func (*EmptyAdapter) HandleMouseButton

func (e *EmptyAdapter) HandleMouseButton(button MouseButton)

func (*EmptyAdapter) HandleMouseMotion

func (e *EmptyAdapter) HandleMouseMotion(motion MouseMotion)

func (*EmptyAdapter) HandleMouseWheel

func (e *EmptyAdapter) HandleMouseWheel(wheel MouseWheel)

func (*EmptyAdapter) HandleWindowSize

func (e *EmptyAdapter) HandleWindowSize(size WindowSize)

type EraseDisplaySeq

type EraseDisplaySeq struct {
	Type int
}

type EraseLineSeq

type EraseLineSeq struct {
	Type int
}

type FontWeight

type FontWeight byte

FontWeight is the weight of a font at a certain terminal cell.

const (
	// FontWeightNormal is the default font weight.
	FontWeightNormal FontWeight = iota

	// FontWeightBold is a bold font weight.
	FontWeightBold

	// FontWeightItalic is an italic font weight.
	FontWeightItalic
)

type Fonts

type Fonts struct {
	Normal font.Face
	Bold   font.Face
	Italic font.Face
}

func LoadFaces

func LoadFaces(normal string, bold string, italic string, dpi float64, size float64) (Fonts, error)

LoadFaces loads a set of fonts from files. The normal, bold, and italic files must be provided. The dpi and size are used to generate the font faces.

type GridCell

type GridCell struct {
	Char   rune
	Fg     color.Color
	Bg     color.Color
	Weight FontWeight
}

GridCell is a single cell in the terminal grid.

type InputAdapter

type InputAdapter interface {
	HandleMouseButton(button MouseButton)
	HandleMouseMotion(motion MouseMotion)
	HandleMouseWheel(wheel MouseWheel)
	HandleKeyPress()
	HandleWindowSize(size WindowSize)
}

type InsertLineSeq

type InsertLineSeq struct {
	Count int
}

type KeyPress

type KeyPress struct {
	Key   ebiten.Key
	Runes []rune
	Shift bool
	Alt   bool
	Ctrl  bool
}

type MouseButton

type MouseButton struct {
	Button       ebiten.MouseButton
	X            int
	Y            int
	Shift        bool
	Alt          bool
	Ctrl         bool
	JustPressed  bool
	JustReleased bool
}

type MouseMotion

type MouseMotion struct {
	X int
	Y int
}

type MouseWheel

type MouseWheel struct {
	X     int
	Y     int
	DX    float64
	DY    float64
	Shift bool
	Alt   bool
	Ctrl  bool
}

type RestoreCursorPositionSeq

type RestoreCursorPositionSeq struct{}

type SGRBgTrueColor

type SGRBgTrueColor struct {
	R, G, B byte
}

type SGRBold

type SGRBold struct{}

type SGRFgTrueColor

type SGRFgTrueColor struct {
	R, G, B byte
}

type SGRItalic

type SGRItalic struct{}

type SGRReset

type SGRReset struct{}

type SGRUnsetBold

type SGRUnsetBold struct{}

type SGRUnsetItalic

type SGRUnsetItalic struct{}

type SaveCursorPositionSeq

type SaveCursorPositionSeq struct{}

type ScrollDownSeq

type ScrollDownSeq struct {
	Count int
}

type ScrollUpSeq

type ScrollUpSeq struct {
	Count int
}

type Window

type Window struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewGame

func NewGame(width int, height int, fonts Fonts, tty io.Reader, adapter InputAdapter, defaultBg color.Color) (*Window, error)

NewGame creates a new terminal game with the given dimensions and font faces.

func (*Window) CRTShader

func (g *Window) CRTShader(val bool)

CRTShader enables or disables the CRT shader. This is just a visual effect.

func (*Window) Draw

func (g *Window) Draw(screen *ebiten.Image)

func (*Window) Kill

func (g *Window) Kill()

func (*Window) Layout

func (g *Window) Layout(outsideWidth, outsideHeight int) (int, int)

func (*Window) PrintChar

func (g *Window) PrintChar(r rune, fg, bg color.Color, weight FontWeight)

PrintChar prints a character to the screen.

func (*Window) RecalculateBackgrounds

func (g *Window) RecalculateBackgrounds()

func (*Window) ResetSGR

func (g *Window) ResetSGR()

ResetSGR resets the SGR attributes to their default values.

func (*Window) Run

func (g *Window) Run(title string) error

func (*Window) SetBgPixels

func (g *Window) SetBgPixels(x, y int, c color.Color)

SetBgPixels sets a chunk of background pixels in the size of the cell.

func (*Window) ShowTPS

func (g *Window) ShowTPS(val bool)

ShowTPS enables or disables the TPS counter on the top left.

func (*Window) Update

func (g *Window) Update() error

type WindowSize

type WindowSize struct {
	Width  int
	Height int
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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