physarum

package
v0.0.0-...-7c9dec4 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Palettes = []Palette{

	Palette{
		HexColor(0xFFFFFF),
		HexColor(0xFA1A1A),
		HexColor(0xFF00FF),
		HexColor(0x33FFFF),
		HexColor(0xFF9900),
	},
}

Functions

func Degrees

func Degrees(radians float32) float32

func HexColor

func HexColor(x int) color.RGBA

func Image

func Image(w, h int, grids [][]float32, palette Palette, min, max, gamma float32) image.Image

func IsPowerOfTwo

func IsPowerOfTwo(x int) bool

func PrintConfigs

func PrintConfigs(configs []Config, table [][]float32)

func Radians

func Radians(degrees float32) float32

func RandomAttractionTable

func RandomAttractionTable(n int) [][]float32

func Run

func Run()

func SavePNG

func SavePNG(path string, im image.Image, level png.CompressionLevel) error

func Shift

func Shift(x, size float32) float32

func SummarizeConfigs

func SummarizeConfigs(configs []Config)

Types

type Config

type Config struct {
	SensorAngle      float32
	SensorDistance   float32
	RotationAngle    float32
	StepDistance     float32
	DepositionAmount float32
	DecayFactor      float32
}

func RandomConfig

func RandomConfig() Config

func RandomConfigs

func RandomConfigs(n int) []Config

type Grid

type Grid struct {
	W    int
	H    int
	Data []float32
	Temp []float32
}

func NewGrid

func NewGrid(w, h int) *Grid

func (*Grid) Add

func (g *Grid) Add(x, y, a float32)

func (*Grid) BoxBlur

func (g *Grid) BoxBlur(radius, iterations int, decayFactor float32)

func (*Grid) Get

func (g *Grid) Get(x, y float32) float32

func (*Grid) GetTemp

func (g *Grid) GetTemp(x, y float32) float32

func (*Grid) Index

func (g *Grid) Index(x, y float32) int

type Model

type Model struct {
	W int
	H int

	BlurRadius int
	BlurPasses int

	ZoomFactor float32

	Configs         []Config
	AttractionTable [][]float32

	Grids     []*Grid
	Particles []Particle

	Iteration int
}

func NewModel

func NewModel(
	w, h, numParticles, blurRadius, blurPasses int, zoomFactor float32,
	configs []Config, attractionTable [][]float32) *Model

func (*Model) Data

func (m *Model) Data() [][]float32

func (*Model) StartOver

func (m *Model) StartOver()

func (*Model) Step

func (m *Model) Step()

type Palette

type Palette []color.RGBA

func BlackPalette

func BlackPalette() Palette

func RandomPalette

func RandomPalette() Palette

func ShuffledPalette

func ShuffledPalette(palette Palette) Palette

func (Palette) Print

func (p Palette) Print()

type Particle

type Particle struct {
	X float32
	Y float32
	A float32
	C uint32
}

Jump to

Keyboard shortcuts

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