GREEDYTILE(1)

NAME

greedytileRandom greedy pixel pattern generation algorithm

SYNOPSIS

$cargo install greedytile

INFO

24 stars
0 views

DESCRIPTION

Random greedy pixel pattern generation algorithm

README

GreedyTile

Crates.io CI Rust unsafe forbidden MIT licensed codecov

Fast pattern synthesis preserving local tile constraints. Safe Rust implementation with CLI and library interfaces.

Examples

SourceGeneratedVisualized
Source AResult AVis A
Source BResult BVis B
Source CResult CVis C
Source DResult DVis D
Source EResult EVis E
Source FResult FVis F
Source GResult GVis G

Installation and usage

# Install with Rust 1.88.0 or later
cargo install greedytile

Generate pattern from source image

greedytile input.png

Process directory of images including rotation, mirroring, and animation

greedytile ./patterns/ -r -m -v

Options

OptionDescriptionDefaultWithout OptionWith Option
--seedSeed reproducible generation42Default SeedCustom Seed
--iterationsMaximum iterations1000Default IterationsMore Iterations
--prefillUse content of <input>_pre.pngdisabledNo PrefillPrefill Enabled
--visualizeGenerate placement animationdisabledTile Placement Animation
--widthMaximum pixel widthunboundedUnboundedBounded
--heightMaximum pixel heightunbounded
--rotateEnable 90°/180°/270° tile rotationsdisabledNo RotationRotation Enabled
--mirrorEnable tile reflectiondisabledNo MirrorMirror Enabled
--quietSuppress progress outputverbose
--no-skipProcess overwriting existing outputskip existing

Details

GreedyTile generates patterns by placing 3×3 tiles extracted from a source image. Weights for randomly selecting placement are influenced by several factors:

  1. Entropy weighting: Prioritizes positions where fewer tile options are valid (similar to WFC)
  2. Global balance correction: If pixels are under-represented then selection is biased towards the source balance
  3. Distance-based probabilities: Pixel distance patterns in the source are replicated in the output
  4. Deadlock recovery: If no choices exist which respect tiles, pixels in a local area are removed before continuing

Commentary

For efficiency, the global balance correction uses a normal distribution to approximate what should technically be a binomial distribution. The approximation becomes accurate at large counts where it matters most.

The distance probability weighting has more impact on easily tiled patterns than complex ones. Restrictive patterns often have less valid tile choices, making the probabilistic selection less relevant.

Limitations

  • Fixed tile size: Currently hardcoded to sample 3×3 pixel tiles from the source
  • Extensibility: Would be improved by a plugin interface for adding new probability rules

SEE ALSO

clihub3/4/2026GREEDYTILE(1)