pix

package module
v0.0.0-...-4ae4433 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2021 License: MIT Imports: 11 Imported by: 0

README

Pix

Turn photos into abstract art.

Road in the Winter Forest by Olga Malamud Pavlovich

Install the command-line tool with go get:

go get -u github.com/yurivish/pix/cmd/pix

Run it like so:

pix -in picture.jpg

Generate multiple outputs by sweeping the parameter space:

pix -in picture.jpg -sweep

Pix is capable of generating 8,000×8,000 outputs in around a minute.

The pixel-placement process is inherently serial and performs one nearest-neighbor search per output pixel, so the time taken depends significantly on the placement order and color distribution since those affect the size of the dynamic search tree and the shape of the frontier.

When the -sweep or -variations flags are used, variations are generated in parallel.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNeighbors

func NewNeighbors(w, h int) neighbors

func Place

func Place(colors []SampledColor, opts Options) error

func SortBySimilarity

func SortBySimilarity(colors []SampledColor, opts SortOptions)

Types

type Canvas

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

A canvas represents a specific pixel-placed drawing

func NewCanvas

func NewCanvas(w, h int, seed int64) *Canvas

func (*Canvas) ImageData

func (c *Canvas) ImageData() []uint8

func (*Canvas) Place

func (c *Canvas) Place(x SampledColor)

func (*Canvas) PlaceAt

func (c *Canvas) PlaceAt(code MortonCode, pos Pos)

func (*Canvas) PlaceSeed

func (c *Canvas) PlaceSeed(color SampledColor, x, y int)

func (*Canvas) PlaceSeeds

func (c *Canvas) PlaceSeeds(colors []SampledColor, xys ...int) ([]SampledColor, error)

func (*Canvas) Reset

func (c *Canvas) Reset()

func (*Canvas) SaveImage

func (c *Canvas) SaveImage(path string, compressionLevel png.CompressionLevel) error

type Color

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

Color represents a color in linear RGB or OkLab

type Handle

type Handle uint32

type ImageColor

type ImageColor struct {
	X, Y    int
	R, G, B uint8
}

func LoadImage

func LoadImage(path string) ([]ImageColor, error)

Returns `ImageColor`s from the source in row major order.

type MortonCode

type MortonCode uint32

type Options

type Options struct {
	Width, Height    int
	RandomSeed       int64
	Sort             SortOptions
	Seeds            []int
	Output           string
	CompressionLevel png.CompressionLevel
}

type Pos

type Pos int32

Pos represents an (x, y index) pair as a single uint32 index into a (padded) array.

type SampledColor

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

Represents a color sample in the RGB and OkLab color spaces, along with its Morton and Hilbert codes.

func SampleColors

func SampleColors(src []ImageColor, nPixels int) []SampledColor

type SortOptions

type SortOptions struct {
	Image, Color, Random float64
	Reverse              bool
}

Directories

Path Synopsis
cmd
pix

Jump to

Keyboard shortcuts

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