Documentation
¶
Index ¶
- Constants
- Variables
- func Clamp(inNum float64, inMin float64, inMax float64) float64
- func DrawQuadTree(dc *gg.Context, tree *QuadTree)
- func DrawSeedBarCode1(dc *gg.Context, data uint64, x float64, y float64, w float64, h float64, ...)
- func Float64ToBytes(f float64) []byte
- func Hash64(s string) uint64
- func ImageToRGBA(src image.Image) *image.RGBA
- func ImgFastSaveToPNG(img image.Image, path string) error
- func ImgGet(img image.Image, x, y int) float64
- func ImgGetRGBA(img image.Image, x, y int) (r, g, b, a int)
- func IntToBytes(i int) []byte
- func MixF(val1 float64, val2 float64, ratio2 float64) float64
- func MixI(val1 int, val2 int, ratio2 float64) int
- func RGBMix(color1 color.RGBA, color2 color.RGBA, ratio2 float64, maxAlpha bool) color.RGBA
- func ScaleF2F(inNum float64, inMin float64, inMax float64, outMin float64, outMax float64) float64
- func ScaleF2I(inNum float64, inMin float64, inMax float64, outMin int, outMax int) int
- func ScaleI2F(inNum int, inMin int, inMax int, outMin float64, outMax float64) float64
- func ScaleI2I(inNum int, inMin int, inMax int, outMin int, outMax int) int
- type CoherentNoise
- func (cnoise *CoherentNoise) Eval1(x float64) float64
- func (cnoise *CoherentNoise) Eval2(x, y float64) float64
- func (cnoise *CoherentNoise) Eval3(x, y, z float64) float64
- func (cnoise *CoherentNoise) Eval4(x, y, z, w float64) float64
- func (cnoise *CoherentNoise) GetEvalRange() (outMin float64, outMax float64)
- func (cnoise *CoherentNoise) GetParamSignature() (signature []byte)
- type ColorRamp
- type ColorStop
- type QuadTree
- func (qt *QuadTree) Contains(p Vec2f) (bool, quadTreeQuadrant)
- func (qt *QuadTree) GetPoints() (results []Vec2f)
- func (qt *QuadTree) InsertPoint(p Vec2f)
- func (qt *QuadTree) InsertPoints(p []Vec2f)
- func (qt *QuadTree) Intersects(x float64, y float64, w float64, h float64) bool
- func (qt *QuadTree) QueryKNN(p Vec2f, k int) []Vec2f
- func (qt *QuadTree) QueryRange(x float64, y float64, w float64, h float64) (results []Vec2f)
- func (qt *QuadTree) SignedDistanceToPoint(p Vec2f) float64
- type TextureCachable
- type TextureCache
- type Vec2f
- type Vec2i
- type VoronoiDiagram2D
Constants ¶
const QuadTreeLeafThreshold = 10
QuadTreeLeafThreshold defines the maximum amount of points allowed in a QuadTree leafnode before it is split
Variables ¶
var ( // MB64E provides a modified encoding of base64 that should work even in urls and filenames MB64E = base64.NewEncoding("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-") )
Functions ¶
func DrawSeedBarCode1 ¶
func DrawSeedBarCode1(dc *gg.Context, data uint64, x float64, y float64, w float64, h float64, ax float64, ay float64)
DrawSeedBarCode1 draws a SBC1 in the RM4SCC style at the desired location calculated as following:
anchor point is `x - w * ax`, `y - h * ay`
use `ax=0.5`, `ay=0.5` to center to a point and both at zero so the code is drawn to the bottom right of the anchor
for best resolution use w in multiples of 112 and h in multiples of 3
func Float64ToBytes ¶
Float64ToBytes returns a byte slice representing the input
func ImageToRGBA ¶
ImageToRGBA converts an image to an RGBA image, hopefully using a lower level go construct for better performance ripped straight from fogleman/gg
func ImgFastSaveToPNG ¶
ImgFastSaveToPNG skips png compression for much faster saving speed at the cost of more memory
func ImgGet ¶
ImgGet returns a [0, 1] grayscale value representing the color on the given image at the given coordinates
func ImgGetRGBA ¶
ImgGetRGBA returns the rgba components of the color on the given image at the given coordinates
func IntToBytes ¶
IntToBytes returns a byte slice representing the input
func RGBMix ¶
RGBMix linearly interpolates between the two given colors, alpha may be maxed to 0xFF to prevent decay
func ScaleF2F ¶
ScaleF2F returns a number in the interval [outMin, outMax] that is percentage-wise as much removed from each end of the interval as inNum in [inMin, inMax]
func ScaleF2I ¶
ScaleF2I returns a number in the interval [outMin, outMax] that is percentage-wise as much removed from each end of the interval as inNum in [inMin, inMax]
Types ¶
type CoherentNoise ¶
type CoherentNoise struct { Noise opensimplex.Noise // open simplex noise generator Scale float64 // number that determines at what distance to view the noisemap, smaller is closer Octaves int // the number of levels of detail you want you perlin noise to have, higher gives more possible detail Lacunarity float64 // number that determines how much detail is added or removed at each octave (adjusts frequency), higher gives less blending of octaves Persistence float64 // number that determines how much each octave contributes to the overall shape (adjusts amplitude), higher makes rougher }
CoherentNoise provides automatic layering of opensimplex noise using parameters
func NewCoherentNoise ¶
func NewCoherentNoise(seed int64, scale float64, octaves int, lacunarity float64, persistence float64) *CoherentNoise
NewCoherentNoise returns a CoherentNoise structure with the given parameters
func (*CoherentNoise) Eval1 ¶
func (cnoise *CoherentNoise) Eval1(x float64) float64
eval1 works as Eval1 does on opensimplex.noise but applies layering through the CoherentNoise parameters
func (*CoherentNoise) Eval2 ¶
func (cnoise *CoherentNoise) Eval2(x, y float64) float64
eval2 works as Eval2 does on opensimplex.noise but applies layering through the CoherentNoise parameters
func (*CoherentNoise) Eval3 ¶
func (cnoise *CoherentNoise) Eval3(x, y, z float64) float64
eval3 works as Eval3 does on opensimplex.noise but applies layering through the CoherentNoise parameters
func (*CoherentNoise) Eval4 ¶
func (cnoise *CoherentNoise) Eval4(x, y, z, w float64) float64
eval4 works as Eval4 does on opensimplex.noise but applies layering through the CoherentNoise parameters
func (*CoherentNoise) GetEvalRange ¶
func (cnoise *CoherentNoise) GetEvalRange() (outMin float64, outMax float64)
GetEvalRange returns the min and max values that can be expected from the Eval2
func (*CoherentNoise) GetParamSignature ¶
func (cnoise *CoherentNoise) GetParamSignature() (signature []byte)
GetParamSignature returns a byte slice containing all relevant unique parameters
type ColorRamp ¶
type ColorRamp struct {
GradientStops []ColorStop // must be sorted
}
ColorRamp holds multiple colorstops between which can be interpolated use Sort to order them by their position
type QuadTree ¶
type QuadTree struct {
// contains filtered or unexported fields
}
QuadTree is a typical 2D QuadTree containing points
func NewQuadTree ¶
NewQuadTree creates a new QuadTree with the given dimensions
func (*QuadTree) InsertPoint ¶
InsertPoint inserts the given point into the QuadTree, branching the tree where necessary TODO make this iterative
func (*QuadTree) InsertPoints ¶
InsertPoints inserts the given points into the QuadTree, branching the tree where necessary
func (*QuadTree) Intersects ¶
func (*QuadTree) QueryKNN ¶
QueryKNN returns the k nearest neighbors to the given point p TODO make this iterative
func (*QuadTree) QueryRange ¶
QueryRange returns all leaf points of QuadTree inside the given region TODO make this iterative
func (*QuadTree) SignedDistanceToPoint ¶
SignedDistanceToPoint returns a relative distance value from p to the QuadTrees bounding box returns >0 if outside the box, <0 if inside, and 0 when exactly on the line
type TextureCachable ¶
type TextureCachable interface { GetParamSignature() (signature []byte) GetEvalRange() (outMin float64, outMax float64) Eval2(x float64, y float64) float64 }
TextureCachable signifies a texture that can be precomputed and cached for later use
type TextureCache ¶
type TextureCache struct {
// contains filtered or unexported fields
}
TextureCache represents a cached texture
func NewTextureCache ¶
func NewTextureCache(provider TextureCachable, x int, y int, w int, h int, path string) *TextureCache
NewTextureCache returns a new cached texture provider, path should only be a directory specification (including the trailing '/') this method will block and pre-generate the whole texture
type VoronoiDiagram2D ¶
type VoronoiDiagram2D struct { Seed uint64 X, Y, W, H float64 Points []Vec2f Scale float64 K int PdsTrys int }
VoronoiDiagram2D represents a 2D voronoi diagram
func NewVoronoiDiagram2D ¶
func NewVoronoiDiagram2D(seed uint64, x float64, y float64, w float64, h float64, scale float64, k int, pdsTrys int) *VoronoiDiagram2D
NewVoronoiDiagram2D creates a new voronoi diagram, with points spaced to have a minimum distance given by the scale if k is -1 then crackle will be used instead of k nearest neighbor, i.e. return distance to nearest edge
func (*VoronoiDiagram2D) Eval2 ¶
func (vd *VoronoiDiagram2D) Eval2(x, y float64) float64
Eval2 returns the distance to the k nearest neighbor returns within range [0, 1]; or 0 for out of bounds; 1 is closest to a point
func (*VoronoiDiagram2D) GetEvalRange ¶
func (vd *VoronoiDiagram2D) GetEvalRange() (outMin float64, outMax float64)
GetEvalRange returns the min and max values that can be expected from the Eval2
func (*VoronoiDiagram2D) GetParamSignature ¶
func (vd *VoronoiDiagram2D) GetParamSignature() (signature []byte)
GetParamSignature returns a byte slice containing all relevant unique parameters