mosaic

package module
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2023 License: BSD-3-Clause Imports: 20 Imported by: 0

README

Mosaic

Generates images from many small tiles.

This is still in an early stage of development, but it is currently functional. Here's an example, click to enlarge:

Go Gopher

This was generated with:

./mosaic -image gopher.png -tiles gophers/ -tile-width 50 -tile-height 70 -blend

Usage

  • Ensure a recent version of Go is installed.
  • Clone this repo
  • Inside this project's directory run: go build ./cmd/mosaic
./mosaic -image source.jpg -out output.jpg -tiles path/to/tile/images

Credit

For the example image:

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoImagesFound = errors.New("no images found")

ErrNoImagesFound is returned when no images are found in the given path.

Functions

func Generate

func Generate(ctx context.Context, src image.Image, tileImages *Index, config Config) image.Image

Generate generates a mosaic image from the source image and the tile images.

Types

type Config

type Config struct {
	Workers int
	Blend   bool

	Scale float64

	TileWidth  int
	TileHeight int

	// ResizeTiles indicates whether the tile images should be resized before
	// determining their primary color.
	ResizeTiles bool
}

Config contains options for mosaic generation.

type Index added in v0.9.1

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

Index is a list of images that can be accessed by color.

func NewIndex added in v0.9.1

func NewIndex(config Config) *Index

NewIndex creates a new, empty, image index.

func (*Index) AddPath added in v0.9.1

func (idx *Index) AddPath(ctx context.Context, path string) error

AddPath finds and indexes images from the given path.

func (*Index) FindNearest added in v0.9.1

func (idx *Index) FindNearest(color uint32) (uint32, []string)

FindNearest returns the nearest color and the images associated with it.

func (*Index) Len added in v0.9.1

func (idx *Index) Len() int

Len returns the number of items in the list.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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