particled

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package particled implements a new image type that stores each (original) pixel with constant colour at variable location. This enables colour-physics systems to be implemented on top.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GravityCalculation

func GravityCalculation(pix kdtree.Point, pixs *kdtree.KDTree, timestep float64, options map[string]any)

GravityCalculation performs the simple gravity equation to one pixicle. The options parameter contains the keys ..., which map to values ...:

  • "likeness" : func(i,j int) float64 : returns likeness between two colourIndexes.
  • "..."

func SortCalculation

func SortCalculation(pix *Pixicle, pixs []*Pixicle, timestep float64, options map[string]any)

SortCalculation tempts to sort the pixels horizontally options["width"] -> width of the particled image options["k"] -> amount of colours

Types

type Calculation

type Calculation func(pix kdtree.Point, pixs *kdtree.KDTree, timestep float64, options map[string]any)

Calculation is a type alias for a function which calculates the new position and velocity of pix, based on pixs, timestep and options

type Particled

type Particled struct {
	// Particles is a pointer to a slice of all pixicles
	Pixicles *kdtree.KDTree
	// Palette holds the used colourpalette for this image
	Palette color.Palette
	// Calc is a function that calculates the new position and
	// velocity of a pixicle, given the set of all pixicles in the image
	Calc Calculation

	Options  map[string]any
	Timestep float64
	// contains filtered or unexported fields
}

Particled is a type of image that stores pixels at variable locations. Each pixel is represented as a Pixicle.

func FromPaletted

func FromPaletted(paletted *image.Paletted, Calc Calculation, timestep float64, options map[string]any) *Particled

FromPaletted creates a particled image from a paletted image

func (*Particled) Bounds

func (p *Particled) Bounds() image.Rectangle

Bounds returns the domain for which At can return non-zero color.

func (*Particled) ColorModel

func (p *Particled) ColorModel() color.Model

ColorModel returns the Image's color model.

func (*Particled) Iterate

func (p *Particled) Iterate()

Iterate runs through one timestep of the physics loop.

func (Particled) Simulate

func (p Particled) Simulate(length int) []*image.Paletted

Simulate creates a slice of paletted frames using the particled starting point

func (*Particled) ToPaletted

func (p *Particled) ToPaletted() *image.Paletted

ToPaletted converts the Particled image back to a Paletted image.

type Pixicle

type Pixicle struct {
	// Colour, contains the index of some palette
	Colour int
	// Velocity is the 2d speed that the particle currently has
	Velocity geom.Vec
	// Mass is the constant movement inertia value of this Pixicle.
	Mass float64
	// Position stores the high-accuracy location of the Pixicle.
	Position geom.Vec
	// contains filtered or unexported fields
}

Pixicle is a Pixel Particle It has a constant colour, constant mass, and variable speed. The colour is stored as an index of some color.palette

func (*Pixicle) Dimension

func (pix *Pixicle) Dimension(i int) float64

Dimension returns the position at dimension number i

func (*Pixicle) Dimensions

func (pix *Pixicle) Dimensions() int

Dimensions returns the amount of Dimensions for this pixicle

Jump to

Keyboard shortcuts

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