cliw

package module
v0.0.0-...-73e1d9f Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2021 License: BSD-3-Clause Imports: 15 Imported by: 0

README

cliw

Cliw is a canvas library for go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Animate

func Animate(num1 *int, num2, duration int)

Animates an int. Still doesnt work when duration is smaller, than the difference between the two input numbers

func ApplyChanges

func ApplyChanges(w [][]Tile, changes []Ve2, centered bool)

Applies changes using termbox

func Clear

func Clear()

Clears the screen

func ColumnMargin

func ColumnMargin(w [][]Tile, c, cPos int) [][]Tile

Sets a world column to be drawn at specific terminal column

func CompareWorlds

func CompareWorlds(world1, world2 [][]Tile) bool

func CutPix

func CutPix(pix [][]string, from Ve2, to Ve2) ([][]string, error)

Makes a cut from a pixmap.

func CutWorld

func CutWorld(world [][]Tile, from Ve2, to Ve2) ([][]Tile, error)

makes cut from the world

func DrawCentered

func DrawCentered(w [][]Tile, additionalRow bool)

Draws world on the center of the screen can get additional blank margin for user input in ui

func DrawWorld

func DrawWorld(w [][]Tile)

func DrawWorldOld

func DrawWorldOld(world [][]Tile)

prints out the world to terminal

func DuplicatePix

func DuplicatePix(p1 [][]string) [][]string

func DuplicateWorld

func DuplicateWorld(w [][]Tile) [][]Tile

func EditTile

func EditTile(world [][]Tile, pos Ve2, t Tile) ([][]Tile, error)

Changes one specific tile in the world. Can append tiles, if the world is too small.

func EditWorld

func EditWorld(world [][]Tile, from, to Ve2, tile Tile) ([][]Tile, error)

Changes all tiles in a rectangular shape. Fills the inside of the rectangle.

func FlipPixMapV

func FlipPixMapV(pm [][]string) (tr [][]string)

func GetColor

func GetColor(in string, bg bool) string

func LoadFont

func LoadFont(path string) map[string]interface{}

func LoadPixMap

func LoadPixMap(path string) [][]string

func LoadWorld

func LoadWorld(path string) [][]Tile

Loads world from file. This shouldn't be used anymore, but if you have old worlds, you can use this to convert them. Doesn't support background color!

func LoadWorldJSON

func LoadWorldJSON(path string) [][]Tile

func PNGToPixMap

func PNGToPixMap(filename string) (tr [][]string, err error)

func ParsePixMap

func ParsePixMap(pix [][]string) [][]Tile

func ReturnWithLayers

func ReturnWithLayers(world [][]Tile, layers []Layer) ([][]Tile, error)

Adds world to a world as another layer. Will append tiles if needed.

func ReturnWithPixLayers

func ReturnWithPixLayers(pixmap [][]string, layers []PixLayer) [][]string

func SavePixMap

func SavePixMap(pm [][]string, path string)

func SaveWorld

func SaveWorld(world [][]Tile, path string)

Saves world to a text file. Don't use this! Doesn't support background color!

func SaveWorldJSON

func SaveWorldJSON(w [][]Tile, path string)

func SetCursor

func SetCursor(pos Ve2)

Moves cursor to specified location

func TermboxPalette

func TermboxPalette() map[string]termbox.Attribute

func TextToPixMap

func TextToPixMap(font map[string]interface{}, color, bgcolor, text string, size Ve2) [][]string

func WorldToPixMap

func WorldToPixMap(w [][]Tile) [][]string

func WriteToTermbox

func WriteToTermbox(w [][]Tile)

Writes a world to Termbox buffer. You have to Init and Sync termbox yourself. If tile is longer than one character, cliw can deal with it.

Types

type Layer

type Layer struct {
	World [][]Tile
	Pos   Ve2
}

type PixLayer

type PixLayer struct {
	PixMap [][]string
	Pos    Ve2
}

type Tile

type Tile struct {
	Name    string
	Tile    string
	Damage  int
	Color   string
	BgColor string
}

Tile is a part of a world. It holds all important info. Name can be used for storing data about it in files.

type Ve2

type Ve2 struct {
	X int
	Y int
}

Vector2 but shorter, so you don't have to type :]

func GetSize

func GetSize() Ve2

Gets size of terminal window

func V2

func V2(x, y int) Ve2

returns new Ve2

func (*Ve2) Add

func (v1 *Ve2) Add(v2 Ve2)

Adds on Ve2 to another

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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