Documentation ¶
Overview ¶
Package texture contains functions that can be combined to create textures.
Three types of texture field are supported, value fields which return a value in the range [-1,1]; vector fields that typically return a triplet of values; and color fields which return a Color from the standard color package.
All fields provide an Eval2(x, y float64) function which takes any x and y and returns either a value, vector or color. If a type doesn't support the entire 2D plane, then it must return 0, {0, ..., 0}, or color.Black for values of x and y not supported.
1D Generators (have a wavelength, center offset, phase, angle):
Flat - produces a flat field NL1 - produces a wave using a NonLinear function (reflected) NL2 - produces a wave using two NonLinear functions, one for up and the other for down Noise1D - produces a wave derived from the Perlin noise function Saw - produces a saw wave Sin - produces a Sine wave Square - produces a square wave Triangle - produces a triangular wave
1D Random/Multiple wavelength versions of the above
2D Generators:
Box - one value if inside box or another if not NonLinear - produces a field filled with circles/elipses using a non-linear function Image - produces a field using an input image (converted to Gray16) Perlin - produces a field using Ken Perlin's improved noise function Triangles - produces a field filled with triangles BlinnField - produces a field filled with metaballs WorleyField - produces a field filled with Worley cells
1D Filters map [-1,1] to [-1,1] (with A, B and C):
Abs Clip Fold Gaussian Pow Quantize - quantizes into C buckets Sine
2D Combiners mix two or more source fields (rescaled to fit):
ColorBlend - uses the value source to blend between to color sources ColorFields - uses four value sources to populate a color field (RGBA or HSLA) ColorSubstitute - switches between two color fields based on the values in a value field Combiner2 Add - sum of two sources Avg - sum of two sources Diff - weighted sum of two sources based on their difference Max - max of two sources Min - min of two sources Mul - product of two sources Sub - difference of two sources (s1 - s2) Combiner3 Substitute - substitute one value for another depending on a third value Displace - source displaced by X and Y scaled sources Window2 - select between two sources based on a region
2D Other:
Distort - similar to Displace only the field itself is used as the displacement source Fractal - combine a source field through an affine transform multiple times IFS - combine a source field through an affine transform multiple times Transform - transforms a value field's X and Y with an Aff3 affine transform TransformCF - transforms a color field's X and Y with an Aff3 affine transform TransformVF - transforms a vector field's X and Y with an Aff3 affine transform UnitNormal - converts a vector field to a unit length vector field Window - window the source field to a region
Converters:
Color - converts a value field to a gray scale color field ColorConv - converts a value field to a color field using a non-linear color map ColorSinCos - converts a value field to a color field using sin and cos ColorVector - converts a vector field to a color field (RGB or HSL) Normal - converts a value field to a vector field using the finite difference method Select - selects one component of a vector field as a value field VectorCombine - combines the components of a vector field into a value field
Generators available from other contributors:
OpenSimplex - github.com/ojrac/opensimplex-go
Index ¶
- Variables
- func ColorRGBABiLerp(u, v float64, colors []color.Color) color.RGBA
- func Cubic(t float64, p []float64) float64
- func Linear(t float64, p []float64) float64
- func MapValueToLambda(v, lambda float64) (int, float64)
- func Nearest(t float64, p []float64) float64
- func NewConicRGBA(w, h int, c []float64, th float64, c1, c2 color.Color, wf *NonLinear) *image.Colorizer
- func NewGray16(width, height int, src ColorField, ox, oy, dx, dy float64) *image.Gray16
- func NewLinearRGBA(w, h int, p1, p2 []float64, c1, c2 color.Color, wf *NonLinear, ...) *image.Colorizer
- func NewRGBA(width, height int, src ColorField, ox, oy, dx, dy float64) *image.RGBA
- func NewRadialRGBA(w, h int, c []float64, r float64, c1, c2 color.Color, wf *NonLinear, ...) *image.Colorizer
- func P3(t float64, p []float64) float64
- func P5(t float64, p []float64) float64
- func SaveJSON(v any, name string) error
- func X3Support(sx, sy float64) [][]float64
- func Z4Support(sx, sy float64) [][]float64
- func Z8Support(sx, sy float64) [][]float64
- type AbsFilter
- type AddCombiner
- type AvgCombiner
- type Binary
- type Blend
- type BlinnField
- type BlockNoise
- type BottomHat
- type Cache
- type ClipFilter
- type Close
- type ColorBlend
- type ColorConv
- type ColorField
- type ColorFields
- type ColorGray
- type ColorSelect
- type ColorSinCos
- type ColorSubstitute
- type ColorToGray
- type ColorVector
- type Component
- type ConicGradient
- type Convolution
- type DiffCombiner
- type Dilate
- type Direction
- type Displace
- type Displace2
- type Distort
- type DrainWF
- type Edge
- type EdgeIn
- type EdgeOut
- type Erode
- type FBM
- type Field
- type FoldFilter
- type Fractal
- type Hexagons
- type IFS
- type IFSCombiner
- type Image
- type Interp
- type InvertFilter
- type JitterBlend
- type LerpType
- type LinearGradient
- type MF
- type Magnitude
- type MaxCombiner
- type MinCombiner
- type MulCombiner
- type NLFilter
- type NLWave
- type NonLinear
- func NewNLCatenary() *NonLinear
- func NewNLCircle1() *NonLinear
- func NewNLCircle2() *NonLinear
- func NewNLCube() *NonLinear
- func NewNLExponential(v float64) *NonLinear
- func NewNLGauss(v float64) *NonLinear
- func NewNLLinear() *NonLinear
- func NewNLLogarithmic(v float64) *NonLinear
- func NewNLLogistic(u, v float64) *NonLinear
- func NewNLP3() *NonLinear
- func NewNLP5() *NonLinear
- func NewNLRand(u, v float64, b bool) *NonLinear
- func NewNLSin() *NonLinear
- func NewNLSin1() *NonLinear
- func NewNLSin2() *NonLinear
- func NewNLSquare() *NonLinear
- type Normal
- type OctaveCombiner
- type OffsScaleFilter
- type Open
- type PatternWave
- type Perlin
- type PinchXWF
- type Pixelate
- type PixelateCF
- type QuantizeFilter
- type RadialGradient
- type RadialNLWF
- type RadialRippleWF
- type RadialWF
- type RadialWiggleWF
- type RandQuantFilter
- type Reflect
- type ReflectCF
- type ReflectVF
- type RippleXWF
- type Select
- type Shape
- type ShapeCombiner
- type ShapeCombinerCF
- type ShapeStyle
- type Squares
- type StochasticBlend
- type StochasticTiler
- type StochasticTilerCF
- type StochasticTilerVF
- type Strip
- type StripCF
- type StripVF
- type SubCombiner
- type SubstituteCombiner
- type SwirlWF
- type TextureGray16
- func NewConicGray16(w, h int, c []float64, th float64, wf *NonLinear) *TextureGray16
- func NewLinearGray16(w, h int, p1, p2 []float64, wf *NonLinear, mirror, once bool) *TextureGray16
- func NewRadialGray16(w, h int, c []float64, r float64, wf *NonLinear, mirror, once bool) *TextureGray16
- func NewTextureGray16(width, height int, src ColorField, ox, oy, dx, dy float64) *TextureGray16
- type TextureRGBA
- type Tiler
- type TilerCF
- type TilerVF
- type TopHat
- type Transform
- type TransformCF
- type TransformVF
- type Triangles
- type Uniform
- type UniformCF
- type UniformVF
- type UnitVector
- type VariableFractal
- type VectorColor
- type VectorField
- type VectorFields
- type Warp
- type WarpCF
- type WarpFunc
- type WarpVF
- type Wave
- type Weighted
- type WeightedCombiner
- type WindowedCombiner
- type WorleyField
Constants ¶
This section is empty.
Variables ¶
var DefaultNormal = &UniformVF{"UniformVF", []float64{0, 0, 1}}
DefaultNormal describes the unit normal point straight up from the XY plane.
Functions ¶
func ColorRGBABiLerp ¶
ColorRGBABiLerp calculates the color value at u, v [0,1] given colors at [0,0], [1,0], [0,1], [1,1] in RGB space.
func Cubic ¶
Cubic calculates the value of f(t) for t in range [0,1] given the values of t at -1, 0, 1, 2 in p[] fitted to a cubic polynomial: f(t) = at^3 + bt^2 + ct + d. Clamped because it over/undershoots. (From graphics2d/util/nlerp.go and https://www.paulinternet.nl/?page=bicubic)
func Linear ¶
Linear calculates the value of f(t) for t in range [0,1] given the values of t at -1, 0, 1, 2 in p[] using linear interpolation.
func MapValueToLambda ¶
Given a value in (-inf, inf) and a wavelength, return number of waves [0,inf) and t [0,lambda) for the value.
func Nearest ¶
Nearest calculates the value of f(t) for t in range [0,1] given the values of t at -1, 0, 1, 2 in p[] using the closest value to t.
func NewConicRGBA ¶
func NewGray16 ¶
func NewGray16(width, height int, src ColorField, ox, oy, dx, dy float64) *image.Gray16
NewGray16 renders the src ColorField into a new Gray16 image.
func NewLinearRGBA ¶
func NewRGBA ¶
func NewRGBA(width, height int, src ColorField, ox, oy, dx, dy float64) *image.RGBA
NewRGBA renders the src ColorField into a new RGBA image.
func NewRadialRGBA ¶
func P3 ¶
P3 calculates the value of f(t) for t in range [0,1] given the values of t at -1, 0, 1, 2 in p[] uses a cubic s-curve
Types ¶
type AddCombiner ¶
AddCombiner is an adding combiner (clamped).
func NewAddCombiner ¶
func NewAddCombiner(src1, src2 Field) *AddCombiner
func (*AddCombiner) Eval2 ¶
func (c *AddCombiner) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type AvgCombiner ¶
AvgCombiner is an averaging combiner.
func NewAvgCombiner ¶
func NewAvgCombiner(src1, src2 Field) *AvgCombiner
func (*AvgCombiner) Eval2 ¶
func (c *AvgCombiner) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type Binary ¶
type BlinnField ¶
type BlinnField struct { Name string Points [][]float64 A []float64 B []float64 D func([]float64, []float64) float64 F func(float64) float64 Scale float64 Offset float64 }
BlinnField implements the ideas from Blinn's 1982 paper, A Generalization of Algebraic Surface Drawing. In Blinn's paper, D() is the distance squared, F() is the exponential function and the values of A and B are determined from the desired metaball radius and blobiness.
func NewBlinnField ¶
func (*BlinnField) Eval2 ¶
func (pf *BlinnField) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type BlockNoise ¶
type BlockNoise struct { Name string Domain []float64 Rows int Cols int Seed int64 Samps int UseMax bool CellW float64 CellH float64 CLen int // contains filtered or unexported fields }
func NewBlockNoise ¶
func NewBlockNoise(w, h float64, r, c int, d float64) *BlockNoise
func (*BlockNoise) Eval2 ¶
func (bn *BlockNoise) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type Cache ¶
type Cache struct { Name string Src Field Resolution float64 Limit int // contains filtered or unexported fields }
Cache provides a simple caching layer for a field which can be used when the expense of recalcuating a source is expensive or for when multiple queries are likely to be made e.g. morphological and convolution operations.
type ClipFilter ¶
Clip limits At+B to [-1,1].
func NewClipFilter ¶
func NewClipFilter(src Field, a, b float64) *ClipFilter
func (*ClipFilter) Eval2 ¶
func (f *ClipFilter) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type ColorBlend ¶
type ColorBlend struct { Name string Src1 ColorField Src2 ColorField Src3 Field Lerp LerpType }
ColorBlend takes colors from the two color field sources and blends them based on the value from the third source using the specified color lerp.
func NewColorBlend ¶
func NewColorBlend(src1, src2 ColorField, src3 Field, lerp LerpType) *ColorBlend
type ColorField ¶
ColorField defines an evaluation method that given an x and y value, returns a Color.
type ColorFields ¶
ColorFields uses the four field sources to form {R, G, B, A} or {H, S, L, A}.
func NewColorFields ¶
func NewColorFields(src1, src2, src3, src4 Field, hsl bool) *ColorFields
type ColorGray ¶
ColorGray contains the field to use in the color evaluation and produces a grayscale color.
func NewColorGray ¶
type ColorSelect ¶
type ColorSelect struct { Name string Src ColorField Chan int }
func NewColorSelect ¶
func NewColorSelect(src ColorField, ch int) *ColorSelect
func (*ColorSelect) Eval2 ¶
func (c *ColorSelect) Eval2(x, y float64) float64
type ColorSinCos ¶
ColorSinCos contains the field used in the color evaluation. The color produced depends on the mode and color space.
func NewColorSinCos ¶
func NewColorSinCos(src Field, mode int, hsl bool) *ColorSinCos
type ColorSubstitute ¶
type ColorSubstitute struct { Name string Src1 ColorField Src2 ColorField Src3 Field A, B float64 }
ColorSubstitute returns a color from either Src1 or Src2 depending on if the value from the third source is between the supplied start and end values.
func NewColorSubstitute ¶
func NewColorSubstitute(src1, src2 ColorField, src3 Field, a, b float64) *ColorSubstitute
type ColorToGray ¶
type ColorToGray struct { Name string Src ColorField }
func NewColorToGray ¶
func NewColorToGray(src ColorField) *ColorToGray
func (*ColorToGray) Eval2 ¶
func (c *ColorToGray) Eval2(x, y float64) float64
type ColorVector ¶
type ColorVector struct { Name string Src VectorField HSL bool }
ColorVector uses the three values from a vector field to populate either R, G, B or H, S, L. Alpha is set to opaque.
func NewColorVector ¶
func NewColorVector(src VectorField, hsl bool) *ColorVector
type Component ¶
type Component struct { Name string Value Field Vector VectorField Color ColorField }
Component composes a value, vector and color field.
func NewComponent ¶
NewComponent takes a source field and returns a component instance. The three colors control the color values at t = 0, 0.5, 1 in the supplied nonlinear color field created from the nonlinear and lerp functions. The vector field is produced by calculating the normals of the source field, scaled by bscale.
type ConicGradient ¶
func NewConicGradient ¶
func NewConicGradient(wf Wave) *ConicGradient
func (*ConicGradient) Eval2 ¶
func (g *ConicGradient) Eval2(x, y float64) float64
type Convolution ¶
func NewConvolution ¶
func NewConvolution(src Field, kern [][]float64, norm bool) *Convolution
kernel {dx, dy, w}
func (*Convolution) Eval2 ¶
func (c *Convolution) Eval2(x, y float64) float64
type DiffCombiner ¶
DiffCombiner combines two values by weighting them in proportion to the difference between them.
func NewDiffCombiner ¶
func NewDiffCombiner(src1, src2 Field) *DiffCombiner
func (*DiffCombiner) Eval2 ¶
func (c *DiffCombiner) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type Direction ¶
type Direction struct { Name string Src VectorField }
Direction converts a VectorField to a Field based on the vector's direction in the XY plane.
func NewDirection ¶
func NewDirection(src VectorField) *Direction
type Displace ¶
type Displace struct { Name string Src, SrcX, SrcY Field Xfm *graphics2d.Aff3 Indep bool }
Displace allows a source field to be evaluated at locations determined by an offset and scaling of the input x, y coordinates taken from other sources. If Indep is true, then the mapped x, y is independent of the original x, y location.
func NewDisplace ¶
NewDisplace creates a new Displace instance using the same transform for both x and y displacements.
type Displace2 ¶
type Displace2 struct { Name string Src, SrcX, SrcY Field XfmX, XfmY *graphics2d.Aff3 Indep bool }
Displace2 allows a source field to be evaluated at locations determined by axis independent transforms of the input x, y coordinates taken from other sources. If Indep is true, then the mapped x, y is independent of the original x, y location.
func NewDisplace2 ¶
func NewDisplace2(in, dx, dy Field, xfmx, xfmy *graphics2d.Aff3) *Displace2
NewDisplace2 creates a new Displace2 instance using the same source for both x and y displacements.
type Distort ¶
type Distort struct { Name string Src Field OffsX, OffsY float64 NOffsX, NOffsY float64 Distortion float64 }
Distort applies a distortion to a source field based on the values it contains.
func NewDistort ¶
NewDistort creates a new Distort instance.
type DrainWF ¶
type DrainWF struct { Name string Center []float64 // Center of warp Scale float64 // Scale factor Effct float64 // Effect radius }
DrainWF performs a drain warp around Center in x for use in the above warp types. The x value is scaled about the central x value by |dy|^alpha*scale
func NewDrainWF ¶
type FBM ¶
FBM holds the precomputed weights for an fBM.
type Field ¶
Field defines an evaluation method that given an x and y value, returns a value in the range [-1,1].
type FoldFilter ¶
Fold wraps values (aX+b) outside of the domain [-1,1] back into it.
func NewFoldFilter ¶
func NewFoldFilter(src Field, a, b float64) *FoldFilter
func (*FoldFilter) Eval2 ¶
func (f *FoldFilter) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type Fractal ¶
type Fractal struct { Name string Src Field Xfm *g2d.Aff3 Comb OctaveCombiner Octaves float64 Weights []float64 }
Fractal holds the pieces necessary for fractal generation. Xfm defines the affine transformation applied successively to the coordinate space and Comb, how the multiple resultant values should be combined. Bands can also be manipulated through the weight values (typically [0, 1]) which allows certain frequencies to be attenuated.
func NewFractal ¶
NewFractal returns a new Fractal instance.
type Hexagons ¶
func NewHexagons ¶
type IFS ¶
type IFS struct { Name string Dom []float64 Xfms []*g2d.Aff3 // Inverses of the IFS contractive affine transformations Itr int }
IFS represents a collection of affine transforms comprising an iterated function system.
type IFSCombiner ¶
type IFSCombiner struct { Name string Src1 Field Src2 Field Dom []float64 Xfms []*g2d.Aff3 // Inverses of the IFS contractive affine transformations Itr int }
IFS represents a collection of affine transforms comprising an iterated function system.
func NewIFSCombiner ¶
NewIFSCombiner returns a new instance of IFS. Note that the number of sub evaluations required is the number of transforms to the power of the number of iterations per evaluation.
func (*IFSCombiner) Eval2 ¶
func (f *IFSCombiner) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type Image ¶
type Image struct { Name string MinX int LastX int MinY int LastY int Func Interp // contains filtered or unexported fields }
Image holds the data to support a continuous bicubic interpolation over an image.
type InvertFilter ¶
InvertFilter flips the sign of v.
func NewInvertFilter ¶
func NewInvertFilter(src Field) *InvertFilter
func (*InvertFilter) Eval2 ¶
func (f *InvertFilter) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type JitterBlend ¶
func NewJitterBlend ¶
func NewJitterBlend(src1, src2, src3 Field, perc float64) *JitterBlend
func (*JitterBlend) Eval2 ¶
func (b *JitterBlend) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type LinearGradient ¶
func NewLinearGradient ¶
func NewLinearGradient(wf Wave) *LinearGradient
func (*LinearGradient) Eval2 ¶
func (g *LinearGradient) Eval2(x, y float64) float64
type MF ¶
MF holds the precomputed weights and offset for an multifractal.
type Magnitude ¶
type Magnitude struct { Name string Src VectorField }
Magnitude converts a VectorField to a Field based on the vector's magnitude.
func NewMagnitude ¶
func NewMagnitude(src VectorField) *Magnitude
type MaxCombiner ¶
MaxCombiner is a maximizing combiner.
func NewMaxCombiner ¶
func NewMaxCombiner(src1, src2 Field) *MaxCombiner
func (*MaxCombiner) Eval2 ¶
func (c *MaxCombiner) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type MinCombiner ¶
MinCombiner is a minimizing combiner.
func NewMinCombiner ¶
func NewMinCombiner(src1, src2 Field) *MinCombiner
func (*MinCombiner) Eval2 ¶
func (c *MinCombiner) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type MulCombiner ¶
MulComnbiner is a multiplying combiner.
func NewMulCombiner ¶
func NewMulCombiner(src1, src2 Field) *MulCombiner
func (*MulCombiner) Eval2 ¶
func (c *MulCombiner) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type NLWave ¶
type NonLinear ¶
func NewNLCatenary ¶
func NewNLCatenary() *NonLinear
func NewNLCircle1 ¶
func NewNLCircle1() *NonLinear
func NewNLCircle2 ¶
func NewNLCircle2() *NonLinear
func NewNLExponential ¶
func NewNLGauss ¶
func NewNLLinear ¶
func NewNLLinear() *NonLinear
func NewNLLogarithmic ¶
func NewNLLogistic ¶
func NewNLSquare ¶
func NewNLSquare() *NonLinear
type Normal ¶
Normal provides a VectorField calculated from a Field using the finite difference method.
type OctaveCombiner ¶
type OffsScaleFilter ¶
OffsScaleFilter limits A(t+B) to [-1,1].
func NewOffsScaleFilter ¶
func NewOffsScaleFilter(src Field, a, b float64) *OffsScaleFilter
func (*OffsScaleFilter) Eval2 ¶
func (f *OffsScaleFilter) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type PatternWave ¶
type PatternWave struct { Name string Lambdas []float64 CumLambda []float64 Patterns [][]float64 Mirrored bool Once bool }
func NewPatternWave ¶
func NewPatternWave(lambdas []float64, patterns [][]float64, mirror, once bool) *PatternWave
func (*PatternWave) Eval ¶
func (g *PatternWave) Eval(v float64) float64
Eval implements the Field interface.
func (*PatternWave) Lambda ¶
func (g *PatternWave) Lambda() float64
type Perlin ¶
Perlin contains the hash structures for generating a noise value between [-1,1). Note noise wraps in 256.
type PinchXWF ¶
type PinchXWF struct { Name string Center []float64 // Center of warp Init float64 // Initial scale Scale float64 // Scale factor Alpha float64 // Power factor }
PinchXWF performs a pinched warp around Center in x for use in the above warp types. The x value is scaled about the central x value by |dy|^alpha*scale
func NewPinchXWF ¶
type Pixelate ¶
Pixelate provides pixelation for a field.
func NewPixelate ¶
NewPixelate creates a new Pixelate with the specified resolution.
type PixelateCF ¶
type PixelateCF struct { Name string Src ColorField Resolution float64 }
PixelateCF provides pixelation for a color field.
func NewPixelateCF ¶
func NewPixelateCF(src ColorField, resolution float64) *PixelateCF
NewPixelateCF creates a new Pixelate with the specified resolution.
type QuantizeFilter ¶
Quantize maps Av+B into one of C buckets.
func NewQuantizeFilter ¶
func NewQuantizeFilter(src Field, a, b float64, c int) *QuantizeFilter
func (*QuantizeFilter) Eval2 ¶
func (f *QuantizeFilter) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type RadialGradient ¶
func NewRadialGradient ¶
func NewRadialGradient(wf Wave) *RadialGradient
func (*RadialGradient) Eval2 ¶
func (g *RadialGradient) Eval2(x, y float64) float64
type RadialNLWF ¶
type RadialNLWF struct { Name string Center []float64 // Center of warp NL *NonLinear // [0,1] => [0,1] Effct float64 // Effect radius }
RadialNLWF performs a radius warp around Center based on an NL
func NewRadialNLWF ¶
func NewRadialNLWF(c []float64, nl *NonLinear, e float64) *RadialNLWF
type RadialRippleWF ¶
type RadialRippleWF struct { Name string Center []float64 Lambda float64 Amplit float64 Offset float64 }
RadialRippleWF performs a sin warp using the r value, lambda and offset and applies it to the r value, scaled by the amplitude.
func NewRadialRippleWF ¶
func NewRadialRippleWF(c []float64, l, a, o float64) *RadialRippleWF
type RadialWF ¶
type RadialWF struct { Name string Center []float64 // Center of warp RScale float64 // Radial scale CScale float64 // Circumference scale }
RadialWF performs a scaled warp around Center for use in the above warp types.
func NewRadialWF ¶
type RadialWiggleWF ¶
type RadialWiggleWF struct { Name string Center []float64 Lambda float64 Amplit float64 Offset float64 }
RadialWiggleWF performs a sin warp using the r value, lambda and offset and applies it to the th value, scaled by the amplitude.
func NewRadialWiggleWF ¶
func NewRadialWiggleWF(c []float64, l, a, o float64) *RadialWiggleWF
type RandQuantFilter ¶
RandQuantFilter supports a randomized quatization filter.
func NewRandQuantFilter ¶
func NewRandQuantFilter(src Field, a, b float64, c int) *RandQuantFilter
NewRandQuantFilter returns a new RandFilter instance for use in quantization.
func (*RandQuantFilter) Eval2 ¶
func (f *RandQuantFilter) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type Reflect ¶
Reflect contains a line along which a reflection is performed. The line defines where the mirror is. Points on the + side of the line remain untransformed, points on the other are reflected through the transformation.
func NewReflect ¶
NewReflect creates a new Reflection placing the mirror along lp1, lp2.
type ReflectCF ¶
type ReflectCF struct { Name string Src ColorField Start []float64 End []float64 Xfm *graphics2d.Aff3 }
ReflectCF contains a line along which a reflection is performed. The line defines where the mirror is. Points on the + side of the line remain untransformed, points on the other are reflected through the transformation.
func NewReflectCF ¶
func NewReflectCF(src ColorField, lp1, lp2 []float64) *ReflectCF
NewReflect creates a new Reflection placing the mirror along lp1, lp2.
type ReflectVF ¶
type ReflectVF struct { Name string Src VectorField Start []float64 End []float64 Xfm *graphics2d.Aff3 }
ReflectVF contains a line along which a reflection is performed. The line defines where the mirror is. Points on the + side of the line remain untransformed, points on the other are reflected through the transformation.
func NewReflectVF ¶
func NewReflectVF(src VectorField, lp1, lp2 []float64) *ReflectVF
NewReflect creates a new Reflection placing the mirror along lp1, lp2.
type RippleXWF ¶
RippleXWF performs a sin warp using the y value, lambda and offset and applies it to the x value, scaled by the amplitude.
func NewRippleXWF ¶
type Select ¶
type Select struct { Name string Src VectorField Chan int }
Select converts a VectorField to a field by selecting one of its components.
func NewSelect ¶
func NewSelect(src VectorField, ch int) *Select
type Shape ¶
type Shape struct { Name string Shape *graphics2d.Shape Style ShapeStyle }
func NewShape ¶
func NewShape(shape *graphics2d.Shape, style ShapeStyle) *Shape
type ShapeCombiner ¶
type ShapeCombiner struct { Name string Src1 Field Src2 Field Shape *graphics2d.Shape }
Could do these with from primitive operations
func NewShapeCombiner ¶
func NewShapeCombiner(src1, src2 Field, shape *graphics2d.Shape) *ShapeCombiner
func (*ShapeCombiner) Eval2 ¶
func (s *ShapeCombiner) Eval2(x, y float64) float64
type ShapeCombinerCF ¶
type ShapeCombinerCF struct { Name string Src1 ColorField Src2 ColorField Shape *graphics2d.Shape }
func NewShapeCombinerCF ¶
func NewShapeCombinerCF(src1, src2 ColorField, shape *graphics2d.Shape) *ShapeCombinerCF
type ShapeStyle ¶
type ShapeStyle int
const ( BinaryStyle ShapeStyle = iota PathSumStyle PathOccStyle )
Constants for shape styles
type Squares ¶
func NewSquares ¶
type StochasticBlend ¶
func NewStochasticBlend ¶
func NewStochasticBlend(src1, src2, src3 Field) *StochasticBlend
func (*StochasticBlend) Eval2 ¶
func (b *StochasticBlend) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type StochasticTiler ¶
type StochasticTiler struct { Name string Srcs []Field Domain []float64 // contains filtered or unexported fields }
func NewStochasticTiler ¶
func NewStochasticTiler(srcs []Field, dom []float64) *StochasticTiler
func (*StochasticTiler) Eval2 ¶
func (t *StochasticTiler) Eval2(x, y float64) float64
type StochasticTilerCF ¶
type StochasticTilerCF struct { Name string Srcs []ColorField Domain []float64 // contains filtered or unexported fields }
func NewStochasticTilerCF ¶
func NewStochasticTilerCF(srcs []ColorField, dom []float64) *StochasticTilerCF
type StochasticTilerVF ¶
type StochasticTilerVF struct { Name string Srcs []VectorField Domain []float64 // contains filtered or unexported fields }
func NewStochasticTilerVF ¶
func NewStochasticTilerVF(srcs []VectorField, dom []float64) *StochasticTilerVF
func (*StochasticTilerVF) Eval2 ¶
func (t *StochasticTilerVF) Eval2(x, y float64) []float64
type StripCF ¶
type StripCF struct { Name string Src ColorField Value float64 }
func NewStripCF ¶
func NewStripCF(src ColorField, y float64) *StripCF
type StripVF ¶
type StripVF struct { Name string Src VectorField Value float64 }
func NewStripVF ¶
func NewStripVF(src VectorField, y float64) *StripVF
type SubCombiner ¶
SubCombiner is a subtracting combiner (clamped).
func NewSubCombiner ¶
func NewSubCombiner(src1, src2 Field) *SubCombiner
func (*SubCombiner) Eval2 ¶
func (c *SubCombiner) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type SubstituteCombiner ¶
SubstituteCombiner combines two fields based on the supplied values.
func NewSubstituteCombiner ¶
func NewSubstituteCombiner(src1, src2, src3 Field, a, b float64) *SubstituteCombiner
func (*SubstituteCombiner) Eval2 ¶
func (c *SubstituteCombiner) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type SwirlWF ¶
type SwirlWF struct { Name string Center []float64 // Center of warp Scale float64 // Scale factor }
SwirlWF performs a swirl warp around Center in x for use in the above warp types. The cordinates are converted to polar (r, th) and th advanced by scale * r.
func NewSwirlWF ¶
type TextureGray16 ¶
type TextureGray16 struct { Src ColorField Rect image.Rectangle Img *image.Gray16 // Evaluated pixels Stride int Ox, Oy float64 Dx, Dy float64 // contains filtered or unexported fields }
TextureGray16 is a lazily evaluated Gray16 image. For expensive textures this allows only the requested pixels to be calculated, and not the entire image.
func NewConicGray16 ¶
func NewConicGray16(w, h int, c []float64, th float64, wf *NonLinear) *TextureGray16
func NewLinearGray16 ¶
func NewLinearGray16(w, h int, p1, p2 []float64, wf *NonLinear, mirror, once bool) *TextureGray16
func NewRadialGray16 ¶
func NewTextureGray16 ¶
func NewTextureGray16(width, height int, src ColorField, ox, oy, dx, dy float64) *TextureGray16
NewTextureGray16 creates a new TextureRGBA from the supplied parameters
func (*TextureGray16) At ¶
func (t *TextureGray16) At(x, y int) color.Color
At implements the At function in the Image interface.
func (*TextureGray16) Bounds ¶
func (t *TextureGray16) Bounds() image.Rectangle
Bounds implements the Bounds function in the Image interface.
func (*TextureGray16) ColorModel ¶
func (t *TextureGray16) ColorModel() color.Model
ColorModel implements the ColorModel function in the Image interface.
type TextureRGBA ¶
type TextureRGBA struct { Src ColorField Rect image.Rectangle Img *image.RGBA // Evaluated pixels Stride int Ox, Oy float64 Dx, Dy float64 // contains filtered or unexported fields }
TextureRGBA is a lazily evaluated RGBA image. For expensive textures this allows only the requested pixels to be calculated, and not the entire image.
func NewTextureRGBA ¶
func NewTextureRGBA(width, height int, src ColorField, ox, oy, dx, dy float64) *TextureRGBA
NewTextureRGBA creates a new TextureRGBA from the supplied parameters
func (*TextureRGBA) At ¶
func (t *TextureRGBA) At(x, y int) color.Color
At implements the At function in the Image interface.
func (*TextureRGBA) Bounds ¶
func (t *TextureRGBA) Bounds() image.Rectangle
Bounds implements the Bounds function in the Image interface.
func (*TextureRGBA) ColorModel ¶
func (t *TextureRGBA) ColorModel() color.Model
ColorModel implements the ColorModel function in the Image interface.
type TilerCF ¶
type TilerCF struct { Name string Src ColorField Domain []float64 }
func NewTilerCF ¶
func NewTilerCF(src ColorField, dom []float64) *TilerCF
type TilerVF ¶
type TilerVF struct { Name string Src VectorField Domain []float64 }
func NewTilerVF ¶
func NewTilerVF(src VectorField, dom []float64) *TilerVF
type Transform ¶
Transform applies an affine transform to the values passed into the Eval2 function.
type TransformCF ¶
type TransformCF struct { Name string Src ColorField Xfm *g2d.Aff3 }
TransformCF applies an affine transform to the values passed into the Eval2 function.
func NewTransformCF ¶
func NewTransformCF(src ColorField, xfm *g2d.Aff3) *TransformCF
type TransformVF ¶
type TransformVF struct { Name string Src VectorField Xfm *g2d.Aff3 }
TransformVF applies an affine transform to the values passed into the Eval2 function.
func NewTransformVF ¶
func NewTransformVF(src VectorField, xfm *g2d.Aff3) *TransformVF
func (*TransformVF) Eval2 ¶
func (t *TransformVF) Eval2(x, y float64) []float64
Eval2 implements the VectorField interface.
type Triangles ¶
func NewTriangles ¶
type Uniform ¶
func NewUniform ¶
type UniformCF ¶
func NewUniformCF ¶
type UniformVF ¶
func NewUniformVF ¶
type UnitVector ¶
type UnitVector struct { Name string Src VectorField }
UnitVector provides a unit vector (i.e. magnitude = 1) version of a VectorField.
func (*UnitVector) Eval2 ¶
func (u *UnitVector) Eval2(x, y float64) []float64
Eval2 implements the VectorField interface.
type VariableFractal ¶
type VariableFractal struct { Name string Src Field Xfm *g2d.Aff3 Comb OctaveCombiner OctSrc Field Scale float64 Weights []float64 }
func NewVariableFractal ¶
func NewVariableFractal(src Field, xfm *g2d.Aff3, comb OctaveCombiner, octsrc Field, scale float64) *VariableFractal
NewFractal returns a new Fractal instance.
func (*VariableFractal) Eval2 ¶
func (f *VariableFractal) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type VectorColor ¶
type VectorColor struct { Name string Src ColorField }
VectorColor uses the three values from a color field to populate it.
func NewVectorColor ¶
func NewVectorColor(src ColorField) *VectorColor
func (*VectorColor) Eval2 ¶
func (v *VectorColor) Eval2(x, y float64) []float64
Eval2 implements the VectorField interface.
type VectorField ¶
VectorField defines an evaluation method that given an x and y value, returns a slice of values in the range [-1,1].
type VectorFields ¶
VectorFields contains the field to use in the color evaluation and produces a grayscale color.
func NewVectorFields ¶
func NewVectorFields(srcs ...Field) *VectorFields
func (*VectorFields) Eval2 ¶
func (v *VectorFields) Eval2(x, y float64) []float64
Eval2 implements the VectorField interface.
type WarpCF ¶
type WarpCF struct { Name string Src ColorField Func WarpFunc }
WarpCF applies a deformation to the values passed into the Eval2 function.
func NewWarpCF ¶
func NewWarpCF(src ColorField, wf WarpFunc) *WarpCF
type WarpVF ¶
type WarpVF struct { Name string Src VectorField Func WarpFunc }
WarpVF applies a deformation to the values passed into the Eval2 function.
func NewWarpVF ¶
func NewWarpVF(src VectorField, wf WarpFunc) *WarpVF
type Weighted ¶
type Weighted struct { Name string Src VectorField Weights []float64 }
Weighted converts a VectorField to a field by selecting one of its components.
func NewWeighted ¶
func NewWeighted(src VectorField, w []float64) *Weighted
type WeightedCombiner ¶
WeightedfCombiner combines two fields based on the supplied values.
func NewWeightedCombiner ¶
func NewWeightedCombiner(src1, src2 Field, a, b float64) *WeightedCombiner
func (*WeightedCombiner) Eval2 ¶
func (c *WeightedCombiner) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type WindowedCombiner ¶
WindowedfCombiner combines two fields based on the window values.
func NewWindowedCombiner ¶
func NewWindowedCombiner(src1, src2 Field, a, b float64) *WindowedCombiner
func (*WindowedCombiner) Eval2 ¶
func (c *WindowedCombiner) Eval2(x, y float64) float64
Eval2 implements the Field interface.
type WorleyField ¶
type WorleyField struct { Name string Points [][]float64 A []float64 B []float64 F func(float64) float64 Scale float64 Offset float64 // contains filtered or unexported fields }
WorleyField implements the ideas from Worley's 1996 paper, A Cellular Texture Basis Function. In Worley's paper, the D() is the Euclidean distance function, F() is the identity function, all A are 1 and B determines the weights based on the distance from the point being queried.
func NewWorleyField ¶
func (*WorleyField) Eval2 ¶
func (pf *WorleyField) Eval2(x, y float64) float64
Eval2 implements the Field interface.
Source Files ¶
- binary.go
- blocks.go
- cache.go
- check.go
- color.go
- combine.go
- component.go
- convolution.go
- displace.go
- distort.go
- doc.go
- field.go
- filter.go
- fractal.go
- gradient.go
- ifs.go
- image.go
- json.go
- morphological.go
- nonlinear.go
- perlin.go
- pixelate.go
- points.go
- reflect.go
- shape.go
- strip.go
- texture.go
- tile.go
- transform.go
- uniform.go
- utils.go
- value.go
- vector.go
- warp.go
- wave.go
Directories ¶
Path | Synopsis |
---|---|
Package color contains types and functions for color management.
|
Package color contains types and functions for color management. |
Package random contains functions, MakeXXX, that can be used to create a random texture tree.
|
Package random contains functions, MakeXXX, that can be used to create a random texture tree. |
Package surface contains functions that populate images with lit textured surfaces.
|
Package surface contains functions that populate images with lit textured surfaces. |