charpix

package
Version: v0.0.0-...-d3fb95e Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2018 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const EmptyPixel = "  "

Variables

View Source
var ColoredRuneModel = color.ModelFunc(colorRuneModel)

ColoredRuneModel is needed to construct images.

Functions

func FormatColor

func FormatColor(bg bool, c color.Color) string

FormatColor converts from an image.Color to an ANSI escape code setting the terminal to that color.

Types

type Charpix

type Charpix struct {
	Pix    []ColoredRune
	Stride int
	Rect   image.Rectangle
}

Charpix is an Image with the ColoredRuneModel.

func New

func New(rect image.Rectangle) *Charpix

New creates a new instance of Charpix given a rectangle specifying dimensions

func (*Charpix) At

func (p *Charpix) At(x, y int) color.Color

At implements image.Image.At by returning the color at the given location.

func (*Charpix) Bounds

func (p *Charpix) Bounds() image.Rectangle

Bounds implements image.Image.Bounds by directly returning the Rect.

func (*Charpix) ColorModel

func (p *Charpix) ColorModel() color.Model

ColorModel returns the model for the Charpix, which is always ColoredRuneModel.

func (*Charpix) PixOffset

func (p *Charpix) PixOffset(x, y int) int

PixOffset returns the index of the first element of Pix that corresponds to the pixel at (x, y).

func (*Charpix) RowToLine

func (p *Charpix) RowToLine(y int) string

RowToLine converts a row of pixel runes into a styled string.

func (*Charpix) SetRune

func (p *Charpix) SetRune(x, y int, c ColoredRune)

SetRune sets a pixel.

type ColoredRune

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

ColoredRune represents a string of characters with a 24bit true-color foreground and background.

func (ColoredRune) RGBA

func (c ColoredRune) RGBA() (r, g, b, a uint32)

RGBA converts a ColoredRune to an RGBA color.

Source Files

Jump to

Keyboard shortcuts

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