Documentation
¶
Index ¶
- Constants
- func Render(img image.Image, opts Options) (string, error)
- func RenderFile(path string, opts Options) (string, error)
- type AsciiCharSet
- type CharacterMode
- type ClusteredDotMatrix
- type DitherMatrix
- type DitherMode
- type Frame
- type Options
- type SamplingFunction
- type SelectionMode
- type SizeMode
- type UnicodeCharSet
Constants ¶
View Source
const ( // AlphaPlaceholder marks transparent pixels in the output. AlphaPlaceholder string = " " )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AsciiCharSet ¶
type AsciiCharSet int
AsciiCharSet selects which ASCII characters to use.
const ( AsciiAZ AsciiCharSet = iota // Letters only AsciiNums // Numbers only AsciiSpec // Special characters only AsciiAll // All ASCII characters )
type CharacterMode ¶
type CharacterMode int
CharacterMode selects the character set family.
const ( Ascii CharacterMode = iota // ASCII characters mapped by brightness Unicode // Unicode block characters Custom // User-defined characters )
type ClusteredDotMatrix ¶ added in v0.1.3
type ClusteredDotMatrix int
ClusteredDotMatrix selects the ordered dither matrix for clustered dot dithering.
const ( ClusteredDot4x4 ClusteredDotMatrix = iota ClusteredDot6x6 ClusteredDot6x6_2 ClusteredDot6x6_3 ClusteredDot8x8 ClusteredDotDiagonal6x6 ClusteredDotDiagonal8x8 ClusteredDotDiagonal8x8_2 ClusteredDotDiagonal8x8_3 ClusteredDotDiagonal16x16 ClusteredDotHorizontalLine ClusteredDotVerticalLine ClusteredDotSpiral5x5 )
type DitherMatrix ¶
type DitherMatrix int
DitherMatrix selects the error diffusion matrix for dithering.
const ( FloydSteinberg DitherMatrix = iota Atkinson Burkes FalseFloydSteinberg JarvisJudiceNinke Sierra Sierra2 Sierra3 SierraLite TwoRowSierra Sierra2_4A Simple2D Stucki StevenPigeon )
type DitherMode ¶ added in v0.1.3
type DitherMode int
DitherMode selects the dithering algorithm family.
const ( DitherModeMatrix DitherMode = iota // Error diffusion matrix DitherModeBayer // Bayer ordered dithering DitherModeClusteredDot // Clustered dot ordered dithering )
type Options ¶
type Options struct {
// Size
SizeMode SizeMode
Width int
Height int
CharRatio float64 // terminal character width-to-height ratio
// Characters
CharacterMode CharacterMode
AsciiCharSet AsciiCharSet // used when CharacterMode == Ascii
UnicodeCharSet UnicodeCharSet // used when CharacterMode == Unicode
CustomChars []rune // used when CharacterMode == Custom
ColorBg bool // true = use foreground and background; false = foreground only
SelectionMode SelectionMode // used when CharacterMode == Custom
// Color
TrueColor bool // true = 24-bit RGB; false = use Palette
Palette color.Palette // used when TrueColor == false
AdaptToPalette bool // remap image color range to palette color range before matching
// Adjustments
Brightness int // -100..100
Contrast int // -100..100
// Advanced
Sampling SamplingFunction
Dithering bool
Serpentine bool
DitherMode DitherMode
DitherMatrix DitherMatrix // used when DitherMode == DitherModeMatrix
BayerSize uint // used when DitherMode == DitherModeBayer (must be power of 2)
DitherStrength float32 // strength for Bayer/ClusteredDot (default 1.0)
ClusteredDotMatrix ClusteredDotMatrix // used when DitherMode == DitherModeClusteredDot
// Alpha
OutputAlpha bool
TrimAlpha bool
}
Options configures how an image is rendered to ANSI art.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns sensible defaults matching the ansizalizer TUI defaults.
type SamplingFunction ¶
type SamplingFunction int
SamplingFunction selects the image resize interpolation method.
const ( NearestNeighbor SamplingFunction = iota Bicubic Bilinear Lanczos2 Lanczos3 MitchellNetravali )
type SelectionMode ¶
type SelectionMode int
SelectionMode controls how custom characters are assigned to pixels.
const ( DarkToLight SelectionMode = iota // Map by brightness (darkest char first) Repeat // Cycle through chars sequentially Random // Pick chars at random )
type UnicodeCharSet ¶
type UnicodeCharSet int
UnicodeCharSet selects which Unicode block characters to use.
const ( UnicodeFull UnicodeCharSet = iota // Full block █ UnicodeHalf // Half blocks ▀▄ UnicodeQuarter // Quarter blocks ▞▟ UnicodeShadeLight // Light shade ░ UnicodeShadeMed // Medium shade ▒ UnicodeShadeHeavy // Heavy shade ▓ )
Click to show internal directories.
Click to hide internal directories.