toascii

package module
v0.0.0-...-c689e12 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 4 Imported by: 0

README

to-ascii

Small go package to turn images to text

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImageToText

func ImageToText(img image.Image, pixPerCharX, pixPerCharY int, invert bool) []rune

ImageToText takes an image.Image and returns that image represented by characters of differing "brightness". pixPerCharX/Y represent how many pixels each character covers. Given 0 or less these paramters default to 1, meaning one character to represent each pixel. Invert is a flag that will invert the level of "brightness" of each character.

Types

type Converter

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

Converter is a helper struct for those who like chaining function calls

func NewConverter

func NewConverter(img image.Image) *Converter

NewConverter returns a Converter for a given image with default values

func (*Converter) Convert

func (c *Converter) Convert() []rune

Convert returns the text for the given Converter struct create to this point.

func (*Converter) Invert

func (c *Converter) Invert() *Converter

Invert will invert the brightness characters presetn in the converted text. Calling Invert an even number of times does nothing. There's no reason to do that as that'd be silly.

func (*Converter) PixelsPerCharacterHeight

func (c *Converter) PixelsPerCharacterHeight(y int) *Converter

PixelsPerCharacterHeight sets the number of pixels covered by each character from top to bottom

func (*Converter) PixelsPerCharacterWidth

func (c *Converter) PixelsPerCharacterWidth(x int) *Converter

PixelsPerCharacterWidth sets the number of pixels covered by each character across

Jump to

Keyboard shortcuts

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