Documentation ¶
Index ¶
- Constants
- Variables
- func Clamp(a float64, b float64, c float64) float64
- func Deg2Rad(f float64) float64
- func Distance(p Point, q Point) float64
- func Equalf(a, b float64) bool
- func FloatString(f float64, prec int) string
- func Gcd(a int, b int) int
- func GetTimestampString() string
- func Lerp(a float64, b float64, i float64) float64
- func Linspace(i float64, j float64, n int, b bool) []float64
- func Map(a float64, b float64, c float64, d float64, i float64) float64
- func NamedColor(name string) color.Color
- func NoTinyVals(a float64) float64
- func Rad2Deg(f float64) float64
- func Shuffle(p *[]Point)
- func Smoothstep(t float64) float64
- func SquaredDistance(p Point, q Point) float64
- func StringToColor(colorString string) color.Color
- type Affine2D
- func Add(p, q *Affine2D) *Affine2D
- func Mult(p, q *Affine2D) *Affine2D
- func NewAffine2D() *Affine2D
- func NewAffine2DWithRotation(angle float64) *Affine2D
- func NewAffine2DWithScale(sx, sy float64) *Affine2D
- func NewAffine2DWithShear(sx, sy float64) *Affine2D
- func NewAffine2DWithTranslation(tx, ty float64) *Affine2D
- func (a *Affine2D) MultVec(v Vec2) Vec2
- func (a *Affine2D) RotateAboutPoint(vec Vec2, angle float64, point Point) Vec2
- func (a *Affine2D) RotateCurveAboutPoint(curve Curve, angle float64, rotationPoint Point) Curve
- func (a *Affine2D) RotateLineAboutPoint(line Line, angle float64, rotationPoint Point) Line
- func (a *Affine2D) RotatePointAboutPoint(point Point, angle float64, rotationPoint Point) Point
- func (a *Affine2D) SetRotation(angle float64)
- func (a *Affine2D) SetRotationDegrees(angle float64)
- func (a *Affine2D) SetScale(sx, sy float64)
- func (a *Affine2D) SetShearAngle(ax, ay float64)
- func (a *Affine2D) SetShearAngleDegrees(ax, ay float64)
- func (a *Affine2D) SetShearFactor(sx, sy float64)
- func (a *Affine2D) SetTranslation(tx, ty float64)
- func (a *Affine2D) Transform(v Vec2) Vec2
- func (a *Affine2D) TransformCurve(c Curve) Curve
- func (a *Affine2D) TransformLine(l Line) Line
- func (a *Affine2D) TransformPoint(p Point) Point
- type Circle
- type ColorConfig
- type ColorType
- type CubicSpline
- type Curve
- func Chaikin(c Curve, q float64, n int) Curve
- func CubicBezier(p, q, c1, c2 Point) Curve
- func CubicBezierWithResolution(p, q, c1, c2 Point, resolution int) Curve
- func GenLissajous(l Lissajous, n int, offset Point, s float64) Curve
- func PulsarPlot(curves []Curve) []Curve
- func QuadBezier(p, q, c Point) Curve
- func QuadBezierWithResolution(p, q, c Point, resolution int) Curve
- func QuarticBezier(p, q, c1, c2, c3 Point) Curve
- func QuarticBezierWithResolution(p, q, c1, c2, c3 Point, resolution int) Curve
- func QuarticBezierWithTriangleControl(p, q Point, tri Triangle) Curve
- func (c *Curve) AddPoint(x, y float64)
- func (c *Curve) Boundary() Rect
- func (c *Curve) Centroid() Point
- func (c *Curve) Copy() Curve
- func (c *Curve) Draw(ctx *canvas.Context)
- func (c *Curve) Last() Point
- func (c *Curve) LastLine() Line
- func (c *Curve) Length() float64
- func (c *Curve) Lerp(percentage float64) Point
- func (c *Curve) LineAt(percentage float64) (Line, float64)
- func (c *Curve) PerpendicularAt(percentage float64, length float64) Line
- func (c *Curve) Reverse()
- func (c *Curve) Rotate(a float64)
- func (c *Curve) Scale(x, y float64)
- func (c *Curve) Shear(x, y float64)
- func (c *Curve) Stitch(d *Curve)
- func (c *Curve) Translate(x, y float64)
- type Gradient
- type IndexPoint
- type InteriorAngle
- type KDTree
- func (k *KDTree) Clear()
- func (k *KDTree) Draw(ctx *canvas.Context)
- func (k *KDTree) DrawWithPoints(s float64, ctx *canvas.Context)
- func (k *KDTree) Insert(p IndexPoint)
- func (k *KDTree) IsLeaf() bool
- func (k *KDTree) NearestNeighbors(point IndexPoint, s int) []IndexPoint
- func (k *KDTree) Query(r Rect) []Point
- func (k *KDTree) Search(p IndexPoint) *IndexPoint
- func (k *KDTree) Size() int
- func (k *KDTree) UpdateIndex(p IndexPoint, index int) *IndexPoint
- type LFSRLarge
- type LFSRMedium
- type LFSRSmall
- type Line
- func (l Line) Angle() float64
- func (l Line) Boundary() Rect
- func (l Line) Copy() Line
- func (l Line) Draw(ctx *canvas.Context)
- func (l Line) Intersects(k Line) bool
- func (l Line) InvertedSlope() float64
- func (l Line) IsEqual(k Line) bool
- func (l Line) Length() float64
- func (l Line) Lerp(i float64) Point
- func (l Line) Midpoint() Point
- func (l Line) ParallelTo(k Line) bool
- func (l Line) PerpendicularAt(percentage float64, length float64) Line
- func (l Line) PerpendicularBisector(length float64) Line
- func (l Line) Rotate(a float64) Line
- func (l Line) Scale(x, y float64) Line
- func (l Line) Shear(x, y float64) Line
- func (l Line) Slope() float64
- func (l Line) String() string
- func (l Line) Translate(x, y float64) Line
- type Lissajous
- type MetricPoint
- type Point
- func (p Point) Copy() Point
- func (p Point) Draw(s float64, ctx *canvas.Context)
- func (p Point) IsEqual(q Point) bool
- func (p Point) Lerp(a Point, i float64) Point
- func (p Point) Reflect() Point
- func (p Point) ReflectX() Point
- func (p Point) ReflectY() Point
- func (p Point) Rotate(a float64) Point
- func (p Point) Scale(x, y float64) Point
- func (p Point) ScaleX(x float64) Point
- func (p Point) ScaleY(y float64) Point
- func (p Point) Shear(x, y float64) Point
- func (p Point) ShearX(a float64) Point
- func (p Point) ShearY(a float64) Point
- func (p Point) String() string
- func (p Point) ToIndexPoint(index int) IndexPoint
- func (p Point) ToMetricPoint(index int, metric float64) MetricPoint
- func (p Point) ToVec2() Vec2
- func (p Point) Translate(x, y float64) Point
- func (p Point) TranslateX(x float64) Point
- func (p Point) TranslateY(y float64) Point
- type PointHeap
- type QuadTree
- func (q *QuadTree) Clear()
- func (q *QuadTree) Draw(ctx *canvas.Context)
- func (q *QuadTree) DrawWithPoints(s float64, ctx *canvas.Context)
- func (q *QuadTree) Insert(p IndexPoint) bool
- func (q *QuadTree) NearestNeighbors(point IndexPoint, k int) []IndexPoint
- func (q *QuadTree) Query(r Rect) []Point
- func (q *QuadTree) QueryCircle(center Point, radius float64) []Point
- func (q *QuadTree) QueryCircleExcludeIndex(center Point, radius float64, index int) []Point
- func (q *QuadTree) QueryExcludeIndex(r Rect, index int) []Point
- func (q *QuadTree) Search(p IndexPoint) *IndexPoint
- func (q *QuadTree) Size() int
- func (q *QuadTree) UpdateIndex(p IndexPoint, index int) *IndexPoint
- type Rect
- func (r Rect) Center() Point
- func (r Rect) Contains(rect Rect) bool
- func (r Rect) ContainsPoint(p Point) bool
- func (r Rect) Copy() Rect
- func (r Rect) Draw(ctx *canvas.Context)
- func (r Rect) GoldenSubdivision() (Rect, Rect)
- func (r Rect) Intersects(rect Rect) bool
- func (r Rect) IsDisjoint(rect Rect) bool
- func (r Rect) Overlaps(rect Rect) bool
- func (r Rect) Subdivide(perc float64) (Rect, Rect)
- func (r Rect) ToCurve() Curve
- type RegularPolygon
- func (p RegularPolygon) Apothem() float64
- func (p RegularPolygon) Area() float64
- func (p RegularPolygon) Draw(ctx *canvas.Context)
- func (p RegularPolygon) Edges() []Line
- func (p RegularPolygon) Lerp(t float64) Point
- func (p RegularPolygon) Perimeter() float64
- func (p RegularPolygon) Points() []Point
- func (p RegularPolygon) SideLength() float64
- func (p RegularPolygon) ToCurve() Curve
- type Rng
- func (r *Rng) Gaussian(mean float64, stdev float64) float64
- func (r *Rng) Noise1D(x float64) float64
- func (r *Rng) Noise2D(x float64, y float64) float64
- func (r *Rng) Noise3D(x float64, y float64, z float64) float64
- func (r *Rng) NoisyRandomPoints(num int, threshold float64, rect Rect) []Point
- func (r *Rng) SetNoiseLacunarity(l float64)
- func (r *Rng) SetNoiseOctaves(i int)
- func (r *Rng) SetNoiseOffsetX(offset float64)
- func (r *Rng) SetNoiseOffsetY(offset float64)
- func (r *Rng) SetNoiseOffsetZ(offset float64)
- func (r *Rng) SetNoisePersistence(p float64)
- func (r *Rng) SetNoiseScaleX(scale float64)
- func (r *Rng) SetNoiseScaleY(scale float64)
- func (r *Rng) SetNoiseScaleZ(scale float64)
- func (r *Rng) SetSeed(seed int64)
- func (r *Rng) SignedNoise1D(x float64) float64
- func (r *Rng) SignedNoise2D(x float64, y float64) float64
- func (r *Rng) SignedNoise3D(x float64, y float64, z float64) float64
- func (r *Rng) UniformRandomPoints(num int, rect Rect) []Point
- type SimpleGradient
- type SinePalette
- type Triangle
- func (t Triangle) AB() float64
- func (t Triangle) AC() float64
- func (t Triangle) Angles() (float64, float64, float64)
- func (t Triangle) Area() float64
- func (t Triangle) BC() float64
- func (t Triangle) BarycentricSubdivision() []Triangle
- func (t Triangle) BisectSubdivision(angle InteriorAngle, percent float64) []Triangle
- func (t Triangle) Boundary() Rect
- func (t Triangle) Centroid() Point
- func (t Triangle) Circumcenter() Point
- func (t Triangle) CircumcenterSubdivision() []Triangle
- func (t Triangle) Circumcircle() Circle
- func (t Triangle) CircumcircleRadius() float64
- func (t Triangle) Copy() Triangle
- func (t Triangle) Draw(ctx *canvas.Context)
- func (t Triangle) Incenter() Point
- func (t Triangle) IncenterSubdivision() []Triangle
- func (t Triangle) Incircle() Circle
- func (t Triangle) IncircleRadius() float64
- func (t Triangle) MidAndThirdsSubdivision(angle InteriorAngle) []Triangle
- func (t Triangle) MidpointSubdivision() []Triangle
- func (t Triangle) NinePointCenter() Point
- func (t Triangle) NinePointCircle() Circle
- func (t Triangle) NinePointRadius() float64
- func (t Triangle) Orthocenter() Point
- func (t Triangle) OrthocenterSubdivision() []Triangle
- func (t Triangle) Perimeter() float64
- func (t Triangle) Reverse() Triangle
- func (t Triangle) ToCurve() Curve
- type TrigLUT
- type Vec2
- type Vec3
Constants ¶
const ( BackgroundColorType = iota OutlineColorType TextColorType FillColorType )
const ( LUTSize = 1 << 16 LUTMask = LUTSize - 1 LUTFactor = LUTSize / Tau )
Variables ¶
var (
ErrInvalidSides = errors.New("invalid number of sides")
)
Functions ¶
func FloatString ¶
func GetTimestampString ¶
func GetTimestampString() string
GetTimestampString creates a string based on the current time for use in filenames
func NamedColor ¶
func NoTinyVals ¶
NoTinyVals sets values very close to zero to zero
func Smoothstep ¶
func SquaredDistance ¶
SquaredDistance is the square of the distance between two points
func StringToColor ¶
Types ¶
type Affine2D ¶
type Affine2D struct {
// contains filtered or unexported fields
}
Affine2D is a type for dealing with affine transformations in 2D using homogeneous coordinates
func NewAffine2D ¶
func NewAffine2D() *Affine2D
NewAffine2D returns an identity affine transformation (no rotation, scaling, shearing, or translation)
func NewAffine2DWithRotation ¶
NewAffine2DWithRotation returns an affine transformation with rotation configured
func NewAffine2DWithScale ¶
NewAffine2DWithScale returns an affine transformation with scaling configured
func NewAffine2DWithShear ¶
NewAffine2DWithShear returns an affine transformation with shearing configured
func NewAffine2DWithTranslation ¶
NewAffine2DWithTranslation returns an affine transformation with translation configured
func (*Affine2D) MultVec ¶
MultVec returns a new vector which is the result of applying the affine transformation
func (*Affine2D) RotateAboutPoint ¶
RotateAboutPoint rotates a vector around a point instead of the origin
func (*Affine2D) RotateCurveAboutPoint ¶
RotateCurveAboutPoint rotates a curve around a point instead of the origin
func (*Affine2D) RotateLineAboutPoint ¶
RotateLineAboutPoint rotates a line around a point instead of the origin
func (*Affine2D) RotatePointAboutPoint ¶
RotatePointAboutPoint rotates a point around a point instead of the origin
func (*Affine2D) SetRotation ¶
SetRotation sets the rotation for the transformation
func (*Affine2D) SetRotationDegrees ¶
SetRotationDegrees sets the rotation of the transformation
func (*Affine2D) SetShearAngle ¶
SetShearAngle sets the shear factor in the x and y directions
func (*Affine2D) SetShearAngleDegrees ¶
SetShearAngleDegrees sets the shear factor in the x and y directions
func (*Affine2D) SetShearFactor ¶
SetShearFactor sets the shear factor in the x and y directions
func (*Affine2D) SetTranslation ¶
SetTranslation sets the translation for the x and y directions
func (*Affine2D) TransformCurve ¶
TransformCurve applies the affine transformation to a curve
func (*Affine2D) TransformLine ¶
TransformLine applies the affine transformation to a line
func (*Affine2D) TransformPoint ¶
TransformPoint applies the affine transformation to a point
type Circle ¶
A Circle represented by a center point and radius
func (Circle) ContainsPoint ¶
ContainsPoint determines if a point lies inside the circle, including the boundary
func (Circle) PointOnEdge ¶
PointOnEdge determines if a point lies on the boundary of a circle
type ColorConfig ¶
type CubicSpline ¶
type CubicSpline struct {
// contains filtered or unexported fields
}
CubicSpline represents a cubic spline
func NewCubicSpline ¶
func NewCubicSpline(points []Point) CubicSpline
NewCubicSpline creates a cubic spline from a set of points
func NewCubicSplineWithResolution ¶
func NewCubicSplineWithResolution(points []Point, res int) CubicSpline
NewCubicSplineWithResolution creates a cubic spline from a set of points with a specific resolution
func NewRegularCubicSpline ¶
func NewRegularCubicSpline(points []Point) CubicSpline
func (CubicSpline) At ¶
func (cs CubicSpline) At(x float64) float64
At evaluates the spline at a given x value
func (CubicSpline) ToCurve ¶
func (cs CubicSpline) ToCurve() Curve
ToCurve converts the spline to a curve
type Curve ¶
Curve A curve is a list of points, may be closed
func Chaikin ¶
Chaikin senerates a Chaikin curve given a set of control points, a cutoff ratio, and the number of steps to use in the calculation.
func CubicBezier ¶
CubicBezier generates a cubic Bézier curve between two points given two control points
func CubicBezierWithResolution ¶
CubicBezierWithResolution generates a cubic Bézier curve with a specific resolution
func GenLissajous ¶
GenLissajous generates a Lissajous curve given parameters, a number of points to use (i.e. resolution), and an offset and scale (typically to convert to screen coordinates)
func PulsarPlot ¶
PulsarPlot transforms a slice of curves into a slice of curves representing the segments that make up a pulsar plot
func QuadBezier ¶
QuadBezier generates a quadratic Bézier curve between two points given a control point
func QuadBezierWithResolution ¶
QuadBezierWithResolution generates a quadratic Bézier curve with a specific resolution
func QuarticBezier ¶
QuarticBezier generates a quartic Bézier curve between two points given three control points
func QuarticBezierWithResolution ¶
QuarticBezierWithResolution generates a quartic Bézier curve with a specific resolution
func (*Curve) Boundary ¶
Boundary returns the smallest rect that contains all the points in the curve
func (*Curve) LineAt ¶
LineAt returns the line segment in a curve that is closest to the given percentage along the curve's length
func (*Curve) PerpendicularAt ¶
PerpendicularAt calculates a line that is perpendicular to the curve at a given percentage along the curve's length
func (*Curve) Rotate ¶
Rotate calculates a new curve for which each point is rotated by the given angle
func (*Curve) Scale ¶
Scale calculates a new curve for which each point is scaled by the give amount
type Gradient ¶
type Gradient struct {
// contains filtered or unexported fields
}
func NewGradientFromNamed ¶
func (*Gradient) LinearPaletteStrings ¶
type IndexPoint ¶
An IndexPoint is a wrapper around a point with an extra int identifier, useful when used with trees and heaps
func (IndexPoint) ToPoint ¶
func (p IndexPoint) ToPoint() Point
type KDTree ¶
type KDTree struct {
// contains filtered or unexported fields
}
func NewKDTreeWithPoint ¶
func NewKDTreeWithPoint(p IndexPoint, r Rect) *KDTree
func (*KDTree) Insert ¶
func (k *KDTree) Insert(p IndexPoint)
func (*KDTree) NearestNeighbors ¶
func (k *KDTree) NearestNeighbors(point IndexPoint, s int) []IndexPoint
func (*KDTree) Search ¶
func (k *KDTree) Search(p IndexPoint) *IndexPoint
func (*KDTree) UpdateIndex ¶
func (k *KDTree) UpdateIndex(p IndexPoint, index int) *IndexPoint
type LFSRLarge ¶
type LFSRLarge struct {
// contains filtered or unexported fields
}
LFSRLarge is a 64-bit Xorshift PRNG Benchmarks show this is faster than LFSRMedium and LFSRSmall, so you might as well use this one. Benchmarks also show this is 6-7x faster than the standard math/rand PRNG
func NewLFSRLarge ¶
func NewLFSRLarge() LFSRLarge
func NewLFSRLargeWithSeed ¶
type LFSRMedium ¶
type LFSRMedium struct {
// contains filtered or unexported fields
}
func NewLFSRMedium ¶
func NewLFSRMedium() LFSRMedium
func NewLFSRMediumWithSeed ¶
func NewLFSRMediumWithSeed(seed uint32) LFSRMedium
func (*LFSRMedium) Next ¶
func (l *LFSRMedium) Next() uint32
type LFSRSmall ¶
type LFSRSmall struct {
// contains filtered or unexported fields
}
func NewLFSRSmall ¶
func NewLFSRSmall() LFSRSmall
func NewLFSRSmallWithSeed ¶
type Line ¶
Line is two points that form a line
func (Line) Intersects ¶
Intersects determines if two lines intersect each other
func (Line) InvertedSlope ¶
InvertedSlope calculates one over the slope of the line
func (Line) ParallelTo ¶
ParallelTo determines if two lines are parallel
func (Line) PerpendicularAt ¶
PerpendicularAt calculates a line at a given percentage along the line with a given length that is perpendicular to the original line
func (Line) PerpendicularBisector ¶
PerpendicularBisector calculates a line with a given length at the midpoint of the original line that is also perpendicular to the line
func (Line) Rotate ¶
Rotate calculates a new line for which both points are rotated by the given angle
func (Line) Scale ¶
Scale calculates a new line for which both points are scaled by the given amount
func (Line) Shear ¶
Shear calculates a new line for which both points are sheared by the given amount
type MetricPoint ¶
A MetricPoint is a wrapper around a point with to extra identifiers, useful when used with trees and heaps
func (MetricPoint) ToIndexPoint ¶
func (p MetricPoint) ToIndexPoint() IndexPoint
func (MetricPoint) ToPoint ¶
func (p MetricPoint) ToPoint() Point
type Point ¶
Point is a simple point in 2D space
func PaduaPoints ¶
PaduaPoints calculates Padua points for a certain class of Lissajous curves, where Nx = Ny +/- 1. The correspond to intersection points and some of the outside points on the curve See https://en.wikipedia.org/wiki/Padua_points for more details.
func (Point) ToIndexPoint ¶
func (p Point) ToIndexPoint(index int) IndexPoint
func (Point) ToMetricPoint ¶
func (p Point) ToMetricPoint(index int, metric float64) MetricPoint
func (Point) Translate ¶
Translate calculates a new point with coordinates translated by the given amounts
func (Point) TranslateX ¶
TranslateX calculates a new point with the x coordinated translated by the given amount
func (Point) TranslateY ¶
TranslateY calculates a new point with the y coordinated translated by the given amount
type PointHeap ¶
type PointHeap struct {
// contains filtered or unexported fields
}
PointHeap is a min/max heap for Points using inter-point distance as the metric
func NewMaxPointHeap ¶
func NewMaxPointHeap() *PointHeap
func NewMinPointHeap ¶
func NewMinPointHeap() *PointHeap
func (*PointHeap) Peek ¶
func (m *PointHeap) Peek() MetricPoint
func (*PointHeap) Pop ¶
func (m *PointHeap) Pop() MetricPoint
func (*PointHeap) Push ¶
func (m *PointHeap) Push(p MetricPoint)
func (*PointHeap) Report ¶
func (m *PointHeap) Report() []MetricPoint
func (*PointHeap) ReportReversed ¶
func (m *PointHeap) ReportReversed() []MetricPoint
type QuadTree ¶
type QuadTree struct {
// contains filtered or unexported fields
}
func NewQuadTree ¶
func NewQuadTreeWithCapacity ¶
func (*QuadTree) Insert ¶
func (q *QuadTree) Insert(p IndexPoint) bool
func (*QuadTree) NearestNeighbors ¶
func (q *QuadTree) NearestNeighbors(point IndexPoint, k int) []IndexPoint
func (*QuadTree) QueryCircleExcludeIndex ¶
func (*QuadTree) QueryExcludeIndex ¶
func (*QuadTree) Search ¶
func (q *QuadTree) Search(p IndexPoint) *IndexPoint
func (*QuadTree) UpdateIndex ¶
func (q *QuadTree) UpdateIndex(p IndexPoint, index int) *IndexPoint
type Rect ¶
Rect is a simple rectangle
func (Rect) ContainsPoint ¶
ContainsPoint determines if a point lies within a rectangle
func (Rect) GoldenSubdivision ¶
GoldenSubdivision returns two rectangles using the golden ratio to calculate where to split the rectangle
func (Rect) Intersects ¶
Intersects determines if the rectangle intersects the given rectangle
func (Rect) IsDisjoint ¶
IsDisjoint determines if the rectangle is disjoint (no overlap) from a given rectangle
type RegularPolygon ¶
func NewRegularPolygon ¶
func NewRegularPolygon(sides int, radius float64, center Point) (RegularPolygon, error)
func NewRegularPolygonWithSideLength ¶
func NewRegularPolygonWithSideLength(sides int, sideLength float64, center Point) (RegularPolygon, error)
func (RegularPolygon) Apothem ¶
func (p RegularPolygon) Apothem() float64
func (RegularPolygon) Area ¶
func (p RegularPolygon) Area() float64
func (RegularPolygon) Draw ¶
func (p RegularPolygon) Draw(ctx *canvas.Context)
func (RegularPolygon) Edges ¶
func (p RegularPolygon) Edges() []Line
func (RegularPolygon) Lerp ¶
func (p RegularPolygon) Lerp(t float64) Point
func (RegularPolygon) Perimeter ¶
func (p RegularPolygon) Perimeter() float64
func (RegularPolygon) Points ¶
func (p RegularPolygon) Points() []Point
func (RegularPolygon) SideLength ¶
func (p RegularPolygon) SideLength() float64
func (RegularPolygon) ToCurve ¶
func (p RegularPolygon) ToCurve() Curve
type Rng ¶
type Rng struct { Prng LFSRLarge Noise opensimplex.Noise // contains filtered or unexported fields }
Rng is a random number generator with a system PRNG and simplex noise
func (*Rng) NoisyRandomPoints ¶
func (*Rng) SetNoiseLacunarity ¶
SetNoiseLacunarity sets how frequency scales with octaves
func (*Rng) SetNoiseOctaves ¶
SetNoiseOctaves sets the number of steps when calculating fractal Noise
func (*Rng) SetNoiseOffsetX ¶
SetNoiseOffsetX offsets the x position in Noise calculations
func (*Rng) SetNoiseOffsetY ¶
SetNoiseOffsetY offsets the y position in Noise calculations
func (*Rng) SetNoiseOffsetZ ¶
SetNoiseOffsetZ offsets the z position in Noise calculations
func (*Rng) SetNoisePersistence ¶
SetNoisePersistence sets how amplitude scales with octaves
func (*Rng) SetNoiseScaleX ¶
SetNoiseScaleX scales the x position in Noise calculations
func (*Rng) SetNoiseScaleY ¶
SetNoiseScaleY scales the y position in Noise calculations
func (*Rng) SetNoiseScaleZ ¶
SetNoiseScaleZ scales the z position in Noise calculations
func (*Rng) SignedNoise1D ¶
SignedNoise1D generates 1D Noise values in the range of [-1, 1]
func (*Rng) SignedNoise2D ¶
SignedNoise2D generates 2D Noise values in the range of [-1, 1]
func (*Rng) SignedNoise3D ¶
SignedNoise3D generates 3D Noise values in the range of [-1, 1]
type SimpleGradient ¶
type SimpleGradient struct {
// contains filtered or unexported fields
}
func NewSimpleGradientFromNamed ¶
func NewSimpleGradientFromNamed(c1, c2 string) SimpleGradient
type SinePalette ¶
func NewSinePalette ¶
func NewSinePalette(c, d Vec3) SinePalette
func (*SinePalette) ToPng ¶
func (sp *SinePalette) ToPng() (string, error)
type Triangle ¶
A Triangle specified by vertices as points
func (Triangle) AB ¶
AB returns the length of the side defined by vertices A and B also known as side "c" in typical notation
func (Triangle) AC ¶
AC returns the length of the side defined by vertices A and C also known as side "b" in typical notation
func (Triangle) BC ¶
BC returns the length of the side defined by vertices B and C also known as side "a" in typical notation
func (Triangle) BarycentricSubdivision ¶
BarycentricSubdivision returns a slice of triangles that are the result of subdividing the triangle into three smaller triangles using the centroid and each vertex as the new vertices
func (Triangle) BisectSubdivision ¶
func (t Triangle) BisectSubdivision(angle InteriorAngle, percent float64) []Triangle
BisectSubdivision returns a slice of triangles that are the result of subdividing the triangle into two smaller triangles by bisecting one angle with a variable percent offset along the opposite side
func (Triangle) Circumcenter ¶
Circumcenter calculates the circumcenter of the triangle
func (Triangle) CircumcenterSubdivision ¶
CircumcenterSubdivision returns a slice of triangles that are the result of subdividing the triangle into three smaller triangles using the circumcenter and each vertex as the new vertices
func (Triangle) Circumcircle ¶
Circumcircle returns the circumcircle of the triangle
func (Triangle) CircumcircleRadius ¶
CircumcircleRadius calculates the radius of the circumcircle
func (Triangle) IncenterSubdivision ¶
IncenterSubdivision returns a slice of triangles that are the result of subdividing the triangle into three smaller triangles using the incenter and each vertex as the new vertices
func (Triangle) IncircleRadius ¶
IncircleRadius calculates the radius of the incircle
func (Triangle) MidAndThirdsSubdivision ¶
func (t Triangle) MidAndThirdsSubdivision(angle InteriorAngle) []Triangle
func (Triangle) MidpointSubdivision ¶
MidpointSubdivision returns a slice of triangles that are the result of subdividing the triangle into four smaller triangles using the midpoints of each side as the set of new vertices
func (Triangle) NinePointCenter ¶
NinePointCenter calculates the center point of the nine-point circle
func (Triangle) NinePointCircle ¶
NinePointCircle returns the nine-point circle of the triangle
func (Triangle) NinePointRadius ¶
NinePointRadius calculates the radius of the nine-point circle
func (Triangle) Orthocenter ¶
Orthocenter calculates the orthocenter of the triangle
func (Triangle) OrthocenterSubdivision ¶
OrthocenterSubdivision returns a slice of triangles that are the result of subdividing the triangle into three smaller triangles using the orthocenter and each vertex as the new vertices
type TrigLUT ¶
type TrigLUT struct {
// contains filtered or unexported fields
}
TrigLUT is a lookup table for sine and cosine. In my tests, it is about 9x faster than math.Sin and math.Cos. The margin of error is < 0.005%. This LUT is not suitable for tangents, however.
func NewTrigLUT ¶
func NewTrigLUT() *TrigLUT
type Vec2 ¶
func Vec2FromLine ¶
func Vec2FromPoint ¶
Vec2FromPoint returns a vector from the origin to p
func Vec2FromPoints ¶
Vec2FromPoints returns a vector from p to q