ascii

package
v0.0.0-...-2da4583 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidResolution = errors.New("resolution must be in [0.01, 1.0]")
	ErrInvalidContrast   = errors.New("contrast must be in [0.1, 3.0]")
	ErrInvalidBrightness = errors.New("brightness must be in [0.1, 3.0]")
	ErrImageTooSmall     = errors.New("image too small after scaling")
)

Functions

This section is empty.

Types

type AsciiResult

type AsciiResult struct {
	Width, Height int
	Chars         []rune
	Colors        []color.NRGBA
	Colored       bool
}

func ConvertImage

func ConvertImage(img image.Image, cfg ConvertConfig) (*AsciiResult, error)

func (*AsciiResult) ToANSI

func (r *AsciiResult) ToANSI() string

func (*AsciiResult) ToHTML

func (r *AsciiResult) ToHTML() string

func (*AsciiResult) ToMarkdown

func (r *AsciiResult) ToMarkdown() string

func (*AsciiResult) ToMarkdownColored

func (r *AsciiResult) ToMarkdownColored() string

func (*AsciiResult) ToPlainText

func (r *AsciiResult) ToPlainText() string

type CharSet

type CharSet int
const (
	CharSetClassic CharSet = iota // your original 16-ish level ramp
	CharSetPhoto                  // long, smooth photographic ramp
	CharSetMinimal                // @%#*+=-:. style
	CharSetBlocks                 // " ░▒▓█" block characters
)

type ConvertConfig

type ConvertConfig struct {
	// Scale factor for output (0.01–1.0)
	Resolution float64
	// Contrast adjustment (0.1–3.0)
	Contrast float64
	// Brightness adjustment (0.1–3.0)
	Brightness float64
	// Invert the character mapping
	Inverted bool
	// Use colored output
	Colored bool
	// Dithering algorithm to use
	Dithering DitheringStrategy
	// Character set to use
	Charset CharSet
	// Custom charter ramp (if Charset is Custom)
	CustomRamp string
}

ConvertConfig mirrors your Rust struct

func DefaultConfig

func DefaultConfig() ConvertConfig

func (ConvertConfig) Validate

func (c ConvertConfig) Validate() error

type DitheringStrategy

type DitheringStrategy int
const (
	DitheringNone DitheringStrategy = iota
	DitheringFloydSteinberg
	DitheringAtkinson
	DitheringRiemersma
	DitheringOrdered2x2
	DitheringOrdered4x4
	DitheringThreshold
)

func (DitheringStrategy) Apply

func (d DitheringStrategy) Apply(gray []float64, width, height, levels int)

Jump to

Keyboard shortcuts

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