Documentation ¶
Overview ¶
Package layout provides voronoi generation, the layout mechanic behind murum's images. Each region is defined as the set of points closest to a reference point. It exposes the Generate function, which creates a set of sets of image.Point s.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type L ¶
type Placer ¶
A Placer takes an image.Rectangle and calculates where best to place xCount* yCount nearestCenter points. If xCount <= 0 or yCount <= 0, the following expression should resolve to true:
len(Place(rect, xCount, yCount)) == 0
A Placer should support rectangles with negative regions
func EvenPlacer ¶
func EvenPlacer() Placer
EvenPlacer returns a Placer that places xCount*yCount points evenly across a rectangle. If xCount or yCount <= 0, nil is returned.
func RandomPlacer ¶
RandomPlacer returns a Placer that uses a rand.Source to randomly Place points on the passed rectangle.
func TriangularPlacer ¶
func TriangularPlacer() Placer
TriangularPlacer creates and returns a Placer that evenly distributes points across a rectangle in a triangular pattern. When rendered with Generate, the resulting L will have hexagon-shaped sections TODO: Triangular (to create hexagonal voronoi cells)
func VariedPlacer ¶
VariedPlacer generates a new Placer. It's based on EvenPlacer, but then moves the centered point a random amount within the varyRect (with the rectangle overlaid such that vr(0, 0) is aligned to the centered point).
varyRect.Min.X <= randomXVariance < varyRect.Max.X varyRect.Min.Y <= randomYVariance < varyRect.Max.Y
func WeightedPlacer ¶
WeightedPlacer creates and returns a Placer that pushes/pulls points to/from a given center point. It is based on the EvenPlacer, and then moves points to create the gravitational effect.
center : Where to apply the gravity from. gravity: How strong the effect is. +ve: Points are pulled towards center; -ve: Points are pushed away from center
TODO: Weighted (place more points closer to a given point, and fewer further away. Or vice versa)