aic_package

package
v0.0.0-...-b7d497b Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 26 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(filePath string, flags Flags) (string, error)

Convert() takes an image or gif path/url as its first argument and a aic_package.Flags literal as the second argument, with which it alters the returned ascii art string.

Types

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

	// Path to save ascii art .txt file
	SaveTxtPath string

	// Path to save ascii art .png file
	SaveImagePath string

	// Path to save ascii art .gif file, if gif is passed
	SaveGifPath string

	// 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

	// Use terminal width to calculate ascii art size while keeping aspect ratio.
	// This overrides Flags.Dimensions, Flags.Width and Flags.Height
	Full bool

	// File path to a font .ttf file to use when saving ascii art gif or png file.
	// This will be ignored if Flags.SaveImagePath or Flags.SaveGifPath are not set
	FontFilePath string

	// Font RGB color for terminal display and saved png or gif files.
	FontColor [3]int

	// Background RGB color in saved png or gif files.
	// This will be ignored if Flags.SaveImagePath or Flags.SaveGifPath are not set
	SaveBackgroundColor [4]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

	// If Flags.SaveImagePath, Flags.SaveTxtPath or Flags.SaveGifPath are set, then don't
	// print on terminal
	OnlySave bool
}

func DefaultFlags

func DefaultFlags() Flags

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

type GifFrame

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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