spatial

package
v0.0.0-...-344c1e1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Colors

func Colors(src image.Image, k int) ([]byte, error)

Colors returns a 500x100 PNG swatch of the k most dominant colors in src. Colors are quantized to 5 bits per channel, so visually-similar shades are grouped together before counting.

func Flip

func Flip(src image.Image) ([]byte, error)

Flip returns src flipped vertically (upside-down) as PNG bytes.

func Magik

func Magik(src image.Image) ([]byte, error)

Magik applies a wavy "liquid" distortion to src by displacing each pixel according to two superimposed sinusoidal fields. Cheap approximation of content-aware liquid rescaling.

func Mirror

func Mirror(src image.Image) ([]byte, error)

Mirror returns src flipped horizontally (left-right) as PNG bytes.

func Mosaic

func Mosaic(src image.Image) ([]byte, error)

Mosaic replaces each mosaicTileSize×mosaicTileSize block of src with the block's average color, separated by a dark grout line on the right/bottom edge.

func Pixelate

func Pixelate(src image.Image, factor int) ([]byte, error)

Pixelate returns src pixelated by factor (e.g. 8 for an 8x8 mosaic) as PNG bytes.

func Stringify

func Stringify(src image.Image) ([]byte, error)

Stringify approximates src as classic string art: nail points on a circle inscribed in the image, then a greedy loop adds the line whose path most reduces the residual "darkness needed" field.

Per-line sums and a pixel→line reverse index are cached so each iteration only updates the lines that share pixels with the selected line instead of rescanning every candidate. This keeps the inner loop O(line_length × avg lines-per-pixel) rather than O(numLines × line_length).

func Swirl

func Swirl(src image.Image) ([]byte, error)

Swirl applies a polar swirl distortion centered on the image. Pixels near the center rotate up to ±swirlStrength*π radians; the edge stays in place.

func Triangle

func Triangle(src image.Image) ([]byte, error)

Triangle reduces src to a low-poly mosaic: each cell is split along one of its diagonals (alternating per cell in a herringbone pattern) into two triangles, each filled with the average color of the source pixels inside.

Types

This section is empty.

Jump to

Keyboard shortcuts

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