ansitoimage

package module
v0.0.0-...-7a32ac9 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 9 Imported by: 0

README

go-ansi-to-image

Go library converting ANSI colored text to the image.

Source ANSI example

ansi-mc.txt

Result PNG image

The San Juan Mountains are beautiful!

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{

	CharWidth:  10,
	LineHeight: 19,
	LineShift:  4,
	LineBreak:  "\n",

	PageCols: 80,
	PageRows: 24,
	Padding:  10,

	MonoRegularFontBytes:      monoRegularFontData,
	MonoRegularFontPoints:     16.0,
	MonoBoldFontBytes:         monoBoldFontData,
	MonoBoldFontPoints:        16.0,
	MonoObliqueFontBytes:      monoObliqueFontData,
	MonoObliqueFontPoints:     16.0,
	MonoObliqueBoldFontBytes:  monoBoldObliqueFontData,
	MonoObliqueBoldFontPoints: 16.0,
}

DefaultConfig represents default configuration for converter.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Text settings.
	CharWidth  int
	LineHeight int
	LineShift  int
	LineBreak  string

	// Page settings.
	PageCols int
	PageRows int
	Padding  int

	// Font settings.
	MonoRegularFontBytes      []byte
	MonoRegularFontPoints     float64
	MonoBoldFontBytes         []byte
	MonoBoldFontPoints        float64
	MonoObliqueFontBytes      []byte
	MonoObliqueFontPoints     float64
	MonoObliqueBoldFontBytes  []byte
	MonoObliqueBoldFontPoints float64
}

Config represents converter configuration.

type Converter

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

Converter converts ANSI texts to image.

func NewConverter

func NewConverter(config Config) (*Converter, error)

NewConverter creates new ANSI-to-Image converter.

func (*Converter) Parse

func (c *Converter) Parse(text string) error

Parse parses ANSI texts to image.

func (*Converter) ToPNG

func (c *Converter) ToPNG() ([]byte, error)

ToPNG encodes parsed text to PNG image.

Jump to

Keyboard shortcuts

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