mosaic

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package mosaic provides a unicode image renderer. Copied from https://github.com/charmbracelet/x/tree/main/mosaic and adapted for Runal usage. RenderCells method has been added to retrieve blocks instead of rendering them directly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(img image.Image, width int, height int) string

Render mosaic with default values.

Types

type Cell

type Cell struct {
	Char       rune
	Foreground color.Color
	Background color.Color
}

Cell represents a single terminal cell.

type Mosaic

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

Mosaic represents a Unicode image renderer.

Example:

```go
art := mosaic.New().Width(100). // Limit to 100 cells
    Scale(mosaic.Fit).          // Fit to width
    Render()
```

func New

func New() Mosaic

New creates and returns a [Renderer].

func (Mosaic) Dither

func (m Mosaic) Dither(dither bool) Mosaic

Dither sets the dither level on Mosaic.

func (Mosaic) Height

func (m Mosaic) Height(height int) Mosaic

Height sets the maximum height the image can have. Defaults to the image height.

func (Mosaic) IgnoreBlockSymbols

func (m Mosaic) IgnoreBlockSymbols(fgOnly bool) Mosaic

IgnoreBlockSymbols set UseFgBgOnly on Mosaic.

func (Mosaic) InvertColors

func (m Mosaic) InvertColors(invertColors bool) Mosaic

InvertColors whether to invert the colors of the mosaic image.

func (*Mosaic) Render

func (m *Mosaic) Render(img image.Image) string

Render renders the image to a string.

func (*Mosaic) RenderCells

func (m *Mosaic) RenderCells(img image.Image) [][]Cell

RenderCells renders the image to [][]Cell.

func (Mosaic) Scale

func (m Mosaic) Scale(scale int) Mosaic

Scale sets the [ScaleMode] on Mosaic.

func (Mosaic) Symbol

func (m Mosaic) Symbol(symbol Symbol) Mosaic

Symbol sets the mosaic symbol type.

func (Mosaic) Threshold

func (m Mosaic) Threshold(threshold int) Mosaic

Threshold sets the threshold level on Mosaic. It expects a value between 0-255, anything else will be ignored.

func (Mosaic) Width

func (m Mosaic) Width(width int) Mosaic

Width sets the maximum width the image can have. Defaults to the image width.

type Symbol

type Symbol uint8

Symbol represents the symbol type to use when rendering the image.

const (
	All Symbol = iota
	Half
	Quarter
)

Symbol types.

Jump to

Keyboard shortcuts

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