aic_package

package
v0.0.0-...-d5b6f6d Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

README

Note

The font DejaVuSans-Oblique.ttf is used for saving braille art .png images since it supports unicode and gave the best results. Hack-Regular.ttf is used for saving normal ascii art .png images.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(inputBytes []byte, flags Flags) (string, error)

func ConvertJSON

func ConvertJSON(inputBytes []byte, flags Flags) ([][]ColoredChar, error)

func IsInputFromPipe

func IsInputFromPipe() bool

Types

type ColoredChar

type ColoredChar struct {
	Char     string                `json:"char"`
	RGBColor *gookitColor.RGBColor `json:"rgb"`
}

type Flags

type Flags struct {
	// Set dimensions of ascii art. Accepts a slice of 2 integers
	// e.g. []int{60,30}.
	// This overrides Flags.Width and Flags.Height
	Dimensions []int

	// Set width of ascii art while calculating height from aspect ratio.
	// Setting this along with Flags.Height will throw an error
	Width int

	// Set height of ascii art while calculating width from aspect ratio.
	// Setting this along with Flags.Width will throw an error
	Height int

	// Use set of 69 characters instead of the default 10
	Complex bool
	// Invert ascii art character mapping as well as colors
	Negative bool

	// Keep colors from the original image. This uses the True color codes for
	// the terminal and will work on saved .png and .gif files as well.
	// This overrides Flags.Grayscale and Flags.FontColor
	Colored bool

	// If Flags.Colored, Flags.Grayscale or Flags.FontColor is set, use that color
	// on each character's background in the terminal
	CharBackgroundColor bool

	// Keep grayscale colors from the original image. This uses the True color
	// codes for the terminal and will work on saved .png and .gif files as well
	// This overrides Flags.FontColor
	Grayscale bool

	// Pass custom ascii art characters as a string.
	// e.g. " .-=+#@".
	// This overrides Flags.Complex
	CustomMap string

	// Flip ascii art horizontally
	FlipX bool

	// Flip ascii art vertically
	FlipY bool

	// Output ASCII as JSON as opposed to the straight ASCII image.
	// This is for programmatically iterating on the ASCII output where
	// ANSI escape codes are stripped as "ASCII" characters.
	//
	// e.g. "--json"
	// [{ "char": "-", "col": [255, 255, 255] }, { "char": "+", "col": [0, 255, 255] }]
	JsonOutput bool

	// Font RGB color for terminal display.
	FontColor [3]int

	// Use braille characters instead of ascii. Terminal must support UTF-8 encoding.
	// Otherwise, problems may be encountered with colored or even uncolored braille art.
	// This overrides Flags.Complex and Flags.CustomMap
	Braille bool

	// Threshold for braille art if Flags.Braille is set to true. Value provided must
	// be between 0 and 255. Ideal value is 128.
	// This will be ignored if Flags.Braille is not set
	Threshold int

	// Apply FloydSteinberg dithering on an image before ascii conversion. This option
	// is meant for braille art. Therefore, it will be ignored if Flags.Braille is false
	Dither bool

	// The color level (8-bit or 24-bit) that we're targetting
	ColorLevel image_conversions.ColorLevel
}

func DefaultFlags

func DefaultFlags() Flags

Return default configuration for flags. Can be sent directly to Convert() for default ascii art

type GifFrame

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

Jump to

Keyboard shortcuts

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