texture

package module
v0.0.0-...-4982ab1 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

Texture Generation

Go Reference Go Report Card Build Status

A package for the procedural generation of textures. Based on the ideas contained in the Bryce 3D deep texture editor.

example

More examples here, here and here.

The primary interfaces allow for the evaluation of a value, vector or color field at any point in the XY plane.

A subpackage covers the generation of surfaces based on lights illuminating a material.

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

Constants

This section is empty.

Variables

View Source
var DefaultNormal = &UniformVF{"UniformVF", []float64{0, 0, 1}}

DefaultNormal describes the unit normal point straight up from the XY plane.

Functions

func ColorRGBABiLerp

func ColorRGBABiLerp(u, v float64, colors []color.Color) color.RGBA

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

func Cubic(t float64, p []float64) float64

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

func Linear(t float64, p []float64) float64

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

func MapValueToLambda(v, lambda float64) (int, float64)

Given a value in (-inf, inf) and a wavelength, return number of waves [0,inf) and t [0,lambda) for the value.

func Nearest

func Nearest(t float64, p []float64) float64

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 NewConicRGBA(w, h int, c []float64, th float64, c1, c2 color.Color, wf *NonLinear) *image.Colorizer

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 NewLinearRGBA(w, h int, p1, p2 []float64, c1, c2 color.Color, wf *NonLinear, mirror, once bool) *image.Colorizer

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 NewRadialRGBA(w, h int, c []float64, r float64, c1, c2 color.Color, wf *NonLinear, mirror, once bool) *image.Colorizer

func P3

func P3(t float64, p []float64) float64

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

func P5

func P5(t float64, p []float64) float64

P5 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 quintic s-curve

func SaveJSON

func SaveJSON(v any, name string) error

func X3Support

func X3Support(sx, sy float64) [][]float64

func Z4Support

func Z4Support(sx, sy float64) [][]float64

func Z8Support

func Z8Support(sx, sy float64) [][]float64

Types

type AbsFilter

type AbsFilter struct {
	Name string
	Src  Field
	A, B float64
}

Abs returns Abs(At+B) (clamped).

func NewAbsFilter

func NewAbsFilter(src Field, a, b float64) *AbsFilter

func (*AbsFilter) Eval2

func (f *AbsFilter) Eval2(x, y float64) float64

Eval2 implements the Field interface.

type AddCombiner

type AddCombiner struct {
	Name string
	Src1 Field
	Src2 Field
}

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

type AvgCombiner struct {
	Name string
	Src1 Field
	Src2 Field
}

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 Binary struct {
	Name string
	Seed int64
	Perc float64
	// contains filtered or unexported fields
}

func NewBinary

func NewBinary(width, height int, seed int64, perc float64) *Binary

func (*Binary) Eval2

func (b *Binary) Eval2(x, y float64) float64

type Blend

type Blend struct {
	Name string
	Src1 Field
	Src2 Field
	Src3 Field
}

func NewBlend

func NewBlend(src1, src2, src3 Field) *Blend

func (*Blend) Eval2

func (b *Blend) Eval2(x, y float64) float64

Eval2 implements the Field interface.

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 NewBlinnField(points [][]float64, a, b []float64,
	d func([]float64, []float64) float64, f func(float64) float64,
	scale, offset float64) *BlinnField

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 BottomHat

type BottomHat struct {
	Name string
	Src1 Field
	Src2 Field
}

BottomHat - C - orig

func NewBottomHat

func NewBottomHat(src Field, supp [][]float64) *BottomHat

func (*BottomHat) Eval2

func (m *BottomHat) Eval2(x, y float64) float64

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.

func NewCache

func NewCache(src Field, resolution float64, limit int) *Cache

NewCache creates a new Cache with the specified resolution and limit. Once the limit is reached, the cache will be reset. The resolution determines the accuracy of the x,y mapping to previous requests.

func (*Cache) Eval2

func (c *Cache) Eval2(x, y float64) float64

Eval2 implements the Field interface.

type ClipFilter

type ClipFilter struct {
	Name string
	Src  Field
	A, B float64
}

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 Close

type Close struct {
	Name string
	Src  Field
}

Close - D then E

func NewClose

func NewClose(src Field, supp [][]float64) *Close

func (*Close) Eval2

func (m *Close) Eval2(x, y float64) float64

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

func (*ColorBlend) Eval2

func (c *ColorBlend) Eval2(x, y float64) color.Color

Eval2 implements the ColorField interface.

type ColorConv

type ColorConv struct {
	Name   string
	Src    Field
	Colors []color.Color
	TVals  []float64
	Lerp   LerpType
}

ColorConv combines the field with a color interpolator.

func NewColorConv

func NewColorConv(src Field, start, end color.Color, cols []color.Color, tvals []float64, lerp LerpType) *ColorConv

func (*ColorConv) Eval2

func (c *ColorConv) Eval2(x, y float64) color.Color

Eval2 implements the ColorField interface.

type ColorField

type ColorField interface {
	Eval2(x, y float64) color.Color
}

ColorField defines an evaluation method that given an x and y value, returns a Color.

type ColorFields

type ColorFields struct {
	Name string
	Src1 Field
	Src2 Field
	Src3 Field
	Src4 Field
	HSL  bool
}

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

func (*ColorFields) Eval2

func (c *ColorFields) Eval2(x, y float64) color.Color

Eval2 implements the ColorField interface.

type ColorGray

type ColorGray struct {
	Name string
	Src  Field
}

ColorGray contains the field to use in the color evaluation and produces a grayscale color.

func NewColorGray

func NewColorGray(src Field) *ColorGray

func (*ColorGray) Eval2

func (c *ColorGray) Eval2(x, y float64) color.Color

Eval2 implements the ColorField interface.

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

type ColorSinCos struct {
	Name string
	Src  Field
	Mode int
	HSL  bool
}

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

func (*ColorSinCos) Eval2

func (c *ColorSinCos) Eval2(x, y float64) color.Color

Eval2 implements the ColorField interface.

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

func (*ColorSubstitute) Eval2

func (c *ColorSubstitute) Eval2(x, y float64) color.Color

Eval2 implements the ColorField interface.

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

func (*ColorVector) Eval2

func (c *ColorVector) Eval2(x, y float64) color.Color

Eval2 implements the ColorField interface.

type Component

type Component struct {
	Name   string
	Value  Field
	Vector VectorField
	Color  ColorField
}

Component composes a value, vector and color field.

func NewComponent

func NewComponent(src Field,
	c1, c2, c3 color.Color,
	lerp LerpType,
	bscale float64) *Component

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

type ConicGradient struct {
	Name string
	WF   Wave
}

func NewConicGradient

func NewConicGradient(wf Wave) *ConicGradient

func (*ConicGradient) Eval2

func (g *ConicGradient) Eval2(x, y float64) float64

type Convolution

type Convolution struct {
	Name string
	Src  Field
	Kern [][]float64
}

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

type DiffCombiner struct {
	Name string
	Src1 Field
	Src2 Field
}

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 Dilate

type Dilate struct {
	Name string
	Src  Field
	Supp [][]float64
}

func NewDilate

func NewDilate(src Field, supp [][]float64) *Dilate

func (*Dilate) Eval2

func (m *Dilate) Eval2(x, y float64) float64

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

func (*Direction) Eval2

func (d *Direction) Eval2(x, y float64) float64

Eval2 implements the Field interface.

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

func NewDisplace(in, dx, dy Field, scale float64) *Displace

NewDisplace creates a new Displace instance using the same transform for both x and y displacements.

func (*Displace) Eval2

func (d *Displace) Eval2(x, y float64) float64

Eval2 implements the Field interface.

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.

func (*Displace2) Eval2

func (d *Displace2) Eval2(x, y float64) float64

Eval2 implements the Field interface.

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

func NewDistort(src Field, dist float64) *Distort

NewDistort creates a new Distort instance.

func (*Distort) Eval2

func (d *Distort) Eval2(x, y float64) float64

Eval2 implements the Field interface.

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

func NewDrainWF(c []float64, s, e float64) *DrainWF

func (*DrainWF) Eval

func (wf *DrainWF) Eval(x, y float64) (float64, float64)

Eval implements the WarpFunc interface

type Edge

type Edge struct {
	Name string
	Src1 Field
	Src2 Field
}

Edge - D - E

func NewEdge

func NewEdge(src Field, supp [][]float64) *Edge

func (*Edge) Eval2

func (m *Edge) Eval2(x, y float64) float64

type EdgeIn

type EdgeIn struct {
	Name string
	Src1 Field
	Src2 Field
}

EdgeIn - orig - E

func NewEdgeIn

func NewEdgeIn(src Field, supp [][]float64) *EdgeIn

func (*EdgeIn) Eval2

func (m *EdgeIn) Eval2(x, y float64) float64

type EdgeOut

type EdgeOut struct {
	Name string
	Src1 Field
	Src2 Field
}

EdgeOut - D - orig

func NewEdgeOut

func NewEdgeOut(src Field, supp [][]float64) *EdgeOut

func (*EdgeOut) Eval2

func (m *EdgeOut) Eval2(x, y float64) float64

type Erode

type Erode struct {
	Name string
	Src  Field
	Supp [][]float64
}

func NewErode

func NewErode(src Field, supp [][]float64) *Erode

func (*Erode) Eval2

func (m *Erode) Eval2(x, y float64) float64

type FBM

type FBM struct {
	Name    string
	Weights []float64
}

FBM holds the precomputed weights for an fBM.

func NewFBM

func NewFBM(hurst, lacunarity float64, maxoct int) *FBM

NewFBM returns a new FBM instance based on the Hurst and Lacunarity parameters.

func (*FBM) Combine

func (f *FBM) Combine(values ...float64) float64

Combine takes the values from the successive applications of the affine transform and combines them using the precomputed weights.

type Field

type Field interface {
	Eval2(x, y float64) float64
}

Field defines an evaluation method that given an x and y value, returns a value in the range [-1,1].

type FoldFilter

type FoldFilter struct {
	Name string
	Src  Field
	A, B float64
}

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

func NewFractal(src Field, xfm *g2d.Aff3, comb OctaveCombiner, octaves float64) *Fractal

NewFractal returns a new Fractal instance.

func (*Fractal) Eval2

func (f *Fractal) Eval2(x, y float64) float64

Eval2 implements the Field interface.

type Hexagons

type Hexagons struct {
	Name  string
	Scale float64
}

func NewHexagons

func NewHexagons(s float64) *Hexagons

func (*Hexagons) Eval2

func (h *Hexagons) Eval2(x, y float64) float64

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.

func NewIFS

func NewIFS(dom []float64, xfms []*g2d.Aff3, itr int) *IFS

NewIFS 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 (*IFS) Eval2

func (f *IFS) Eval2(x, y float64) float64

Eval2 implements the Field interface.

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

func NewIFSCombiner(src1, src2 Field, dom []float64, xfms []*g2d.Aff3, itr int) *IFSCombiner

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.

func NewImage

func NewImage(img image.Image, interp Interp) *Image

NewImage sets up a new field with the supplied image. The image is converted to a {0, 0} offset NRGBA image.

func (*Image) Eval2

func (f *Image) Eval2(x, y float64) color.Color

Eval2 implements the ColorField interface.

type Interp

type Interp int
const (
	NearestInterp Interp = iota
	LinearInterp
	CubicInterp
	P3Interp
	P5Interp
)

type InvertFilter

type InvertFilter struct {
	Name string
	Src  Field
}

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

type JitterBlend struct {
	Name string
	Src1 Field
	Src2 Field
	Src3 Field
	Perc float64
}

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 LerpType

type LerpType int

LerpType defines the type of lerp -

const (
	LerpRGBA LerpType = iota
	LerpHSL
	LerpHSLs
)

Constants for lerp types.

type LinearGradient

type LinearGradient struct {
	Name string
	WF   Wave
}

func NewLinearGradient

func NewLinearGradient(wf Wave) *LinearGradient

func (*LinearGradient) Eval2

func (g *LinearGradient) Eval2(x, y float64) float64

type MF

type MF struct {
	Name    string
	Weights []float64
	Offset  float64
}

MF holds the precomputed weights and offset for an multifractal.

func NewMF

func NewMF(hurst, lacunarity, offset float64, maxoct int) *MF

NewMF returns a new MF instance based on the Hurst and Lacunarity parameters.

func (*MF) Combine

func (f *MF) Combine(values ...float64) float64

Combine takes the values from the successive applications of the affine transform and combines them using the precomputed weights and offset.

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

func (*Magnitude) Eval2

func (m *Magnitude) Eval2(x, y float64) float64

Eval2 implements the Field interface. Always >= 0

type MaxCombiner

type MaxCombiner struct {
	Name string
	Src1 Field
	Src2 Field
}

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

type MinCombiner struct {
	Name string
	Src1 Field
	Src2 Field
}

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

type MulCombiner struct {
	Name string
	Src1 Field
	Src2 Field
}

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 NLFilter

type NLFilter struct {
	Name   string
	Src    Field
	NLFunc *NonLinear
	A, B   float64
}

NLFilter holds the parameters for a symmetric non-linear filter mapping.

func NewNLFilter

func NewNLFilter(src Field, nlf *NonLinear, a, b float64) *NLFilter

func (*NLFilter) Eval2

func (f *NLFilter) Eval2(x, y float64) float64

Eval2 implements the Field interface.

type NLWave

type NLWave struct {
	Name      string
	Lambdas   []float64
	CumLambda []float64
	NLFs      []*NonLinear
	Mirrored  bool
	Once      bool
}

func NewNLWave

func NewNLWave(lambdas []float64, nlfs []*NonLinear, mirror, once bool) *NLWave

func (*NLWave) Eval

func (g *NLWave) Eval(v float64) float64

func (*NLWave) Lambda

func (g *NLWave) Lambda() float64

type NonLinear

type NonLinear struct {
	Name string
	NLF  util.NonLinear
}

func NewNLCatenary

func NewNLCatenary() *NonLinear

func NewNLCircle1

func NewNLCircle1() *NonLinear

func NewNLCircle2

func NewNLCircle2() *NonLinear

func NewNLCube

func NewNLCube() *NonLinear

func NewNLExponential

func NewNLExponential(v float64) *NonLinear

func NewNLGauss

func NewNLGauss(v float64) *NonLinear

func NewNLLinear

func NewNLLinear() *NonLinear

func NewNLLogarithmic

func NewNLLogarithmic(v float64) *NonLinear

func NewNLLogistic

func NewNLLogistic(u, v float64) *NonLinear

func NewNLP3

func NewNLP3() *NonLinear

func NewNLP5

func NewNLP5() *NonLinear

func NewNLRand

func NewNLRand(u, v float64, b bool) *NonLinear

func NewNLSin

func NewNLSin() *NonLinear

func NewNLSin1

func NewNLSin1() *NonLinear

func NewNLSin2

func NewNLSin2() *NonLinear

func NewNLSquare

func NewNLSquare() *NonLinear

func (*NonLinear) Eval

func (nl *NonLinear) Eval(t float64) float64

type Normal

type Normal struct {
	Name     string
	Src      Field
	SDx, SDy float64
	Dx, Dy   float64
}

Normal provides a VectorField calculated from a Field using the finite difference method.

func NewNormal

func NewNormal(src Field, sx, sy, dx, dy float64) *Normal

NewNormal returns a new instance of Normal.

func (*Normal) Eval2

func (n *Normal) Eval2(x, y float64) []float64

Eval2 implements the VectorField interface.

type OctaveCombiner

type OctaveCombiner interface {
	Combine(...float64) float64
}

type OffsScaleFilter

type OffsScaleFilter struct {
	Name string
	Src  Field
	A, B float64
}

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 Open

type Open struct {
	Name string
	Src  Field
}

Open - E then D

func NewOpen

func NewOpen(src Field, supp [][]float64) *Open

func (*Open) Eval2

func (m *Open) Eval2(x, y float64) float64

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

type Perlin struct {
	Name string
	Seed int64
	// contains filtered or unexported fields
}

Perlin contains the hash structures for generating a noise value between [-1,1). Note noise wraps in 256.

func NewPerlin

func NewPerlin(seed int64) *Perlin

NewPerlin initializes a new Perlin hash structure.

func (*Perlin) Eval2

func (p *Perlin) Eval2(x, y float64) float64

Eval2 calculates the value at x,y based on the interpolated gradients of the four corners of the square which x,y resides in. It implements the Field interface.

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

func NewPinchXWF(c []float64, i, s, a float64) *PinchXWF

func (*PinchXWF) Eval

func (wf *PinchXWF) Eval(x, y float64) (float64, float64)

Eval implements the WarpFunc interface

type Pixelate

type Pixelate struct {
	Name       string
	Src        Field
	Resolution float64
}

Pixelate provides pixelation for a field.

func NewPixelate

func NewPixelate(src Field, resolution float64) *Pixelate

NewPixelate creates a new Pixelate with the specified resolution.

func (*Pixelate) Eval2

func (p *Pixelate) Eval2(x, y float64) float64

Eval2 implements the Field interface.

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.

func (*PixelateCF) Eval2

func (p *PixelateCF) Eval2(x, y float64) color.Color

Eval2 implements the Field interface.

type QuantizeFilter

type QuantizeFilter struct {
	Name string
	Src  Field
	A, B float64
	C    int
}

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

type RadialGradient struct {
	Name string
	WF   Wave
}

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

func (*RadialNLWF) Eval

func (wf *RadialNLWF) Eval(x, y float64) (float64, float64)

Eval implements the WarpFunc interface

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

func (*RadialRippleWF) Eval

func (wf *RadialRippleWF) Eval(x, y float64) (float64, float64)

Eval implements the WarpFunc interface

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

func NewRadialWF(c []float64, rs, cs float64) *RadialWF

func (*RadialWF) Eval

func (wf *RadialWF) Eval(x, y float64) (float64, float64)

Eval implements the WarpFunc interface

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

func (*RadialWiggleWF) Eval

func (wf *RadialWiggleWF) Eval(x, y float64) (float64, float64)

Eval implements the WarpFunc interface

type RandQuantFilter

type RandQuantFilter struct {
	Src  Field
	A, B float64
	C    int
	M    []float64
}

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

type Reflect struct {
	Name  string
	Src   Field
	Start []float64
	End   []float64
	Xfm   *graphics2d.Aff3
}

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

func NewReflect(src Field, lp1, lp2 []float64) *Reflect

NewReflect creates a new Reflection placing the mirror along lp1, lp2.

func (*Reflect) Eval2

func (r *Reflect) Eval2(x, y float64) float64

Eval2 implements the Field interface.

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.

func (*ReflectCF) Eval2

func (r *ReflectCF) Eval2(x, y float64) color.Color

Eval2 implements the Field interface.

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.

func (*ReflectVF) Eval2

func (r *ReflectVF) Eval2(x, y float64) []float64

Eval2 implements the Field interface.

type RippleXWF

type RippleXWF struct {
	Name   string
	Lambda float64
	Amplit float64
	Offset float64
}

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

func NewRippleXWF(l, a, o float64) *RippleXWF

func (*RippleXWF) Eval

func (wf *RippleXWF) Eval(x, y float64) (float64, float64)

Eval implements the WarpFunc interface

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

func (*Select) Eval2

func (s *Select) Eval2(x, y float64) float64

Eval2 implements the Field interface.

type Shape

type Shape struct {
	Name  string
	Shape *graphics2d.Shape
	Style ShapeStyle
}

func NewShape

func NewShape(shape *graphics2d.Shape, style ShapeStyle) *Shape

func (*Shape) Eval2

func (s *Shape) Eval2(x, y float64) float64

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

func (*ShapeCombinerCF) Eval2

func (s *ShapeCombinerCF) Eval2(x, y float64) color.Color

type ShapeStyle

type ShapeStyle int
const (
	BinaryStyle ShapeStyle = iota
	PathSumStyle
	PathOccStyle
)

Constants for shape styles

type Squares

type Squares struct {
	Name  string
	Scale float64
}

func NewSquares

func NewSquares(s float64) *Squares

func (*Squares) Eval2

func (s *Squares) Eval2(x, y float64) float64

type StochasticBlend

type StochasticBlend struct {
	Name string
	Src1 Field
	Src2 Field
	Src3 Field
}

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

func (*StochasticTilerCF) Eval2

func (t *StochasticTilerCF) Eval2(x, y float64) color.Color

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 Strip

type Strip struct {
	Name  string
	Src   Field
	Value float64
}

func NewStrip

func NewStrip(src Field, y float64) *Strip

func (*Strip) Eval2

func (s *Strip) 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

func (*StripCF) Eval2

func (s *StripCF) Eval2(x, y float64) color.Color

type StripVF

type StripVF struct {
	Name  string
	Src   VectorField
	Value float64
}

func NewStripVF

func NewStripVF(src VectorField, y float64) *StripVF

func (*StripVF) Eval2

func (s *StripVF) Eval2(x, y float64) []float64

type SubCombiner

type SubCombiner struct {
	Name string
	Src1 Field
	Src2 Field
}

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

type SubstituteCombiner struct {
	Name string
	Src1 Field
	Src2 Field
	Src3 Field
	A, B float64
}

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

func NewSwirlWF(c []float64, s float64) *SwirlWF

func (*SwirlWF) Eval

func (wf *SwirlWF) Eval(x, y float64) (float64, float64)

Eval implements the WarpFunc interface

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 NewRadialGray16(w, h int, c []float64, r float64, wf *NonLinear, mirror, once bool) *TextureGray16

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 Tiler

type Tiler struct {
	Name   string
	Src    Field
	Domain []float64
}

func NewTiler

func NewTiler(src Field, dom []float64) *Tiler

func (*Tiler) Eval2

func (t *Tiler) Eval2(x, y float64) float64

type TilerCF

type TilerCF struct {
	Name   string
	Src    ColorField
	Domain []float64
}

func NewTilerCF

func NewTilerCF(src ColorField, dom []float64) *TilerCF

func (*TilerCF) Eval2

func (t *TilerCF) Eval2(x, y float64) color.Color

type TilerVF

type TilerVF struct {
	Name   string
	Src    VectorField
	Domain []float64
}

func NewTilerVF

func NewTilerVF(src VectorField, dom []float64) *TilerVF

func (*TilerVF) Eval2

func (t *TilerVF) Eval2(x, y float64) []float64

type TopHat

type TopHat struct {
	Name string
	Src1 Field
	Src2 Field
}

TopHat - orig - O

func NewTopHat

func NewTopHat(src Field, supp [][]float64) *TopHat

func (*TopHat) Eval2

func (m *TopHat) Eval2(x, y float64) float64

type Transform

type Transform struct {
	Name string
	Src  Field
	Xfm  *g2d.Aff3
}

Transform applies an affine transform to the values passed into the Eval2 function.

func NewTransform

func NewTransform(src Field, xfm *g2d.Aff3) *Transform

func (*Transform) Eval2

func (t *Transform) Eval2(x, y float64) float64

Eval2 implements the Field interface.

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

func (*TransformCF) Eval2

func (t *TransformCF) Eval2(x, y float64) color.Color

Eval2 implements the ColorField interface.

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

type Triangles struct {
	Name  string
	Scale float64
}

func NewTriangles

func NewTriangles(s float64) *Triangles

func (*Triangles) Eval2

func (t *Triangles) Eval2(x, y float64) float64

type Uniform

type Uniform struct {
	Name  string
	Value float64
}

func NewUniform

func NewUniform(v float64) *Uniform

func (*Uniform) Eval2

func (f *Uniform) Eval2(x, y float64) float64

type UniformCF

type UniformCF struct {
	Name  string
	Value color.Color
}

func NewUniformCF

func NewUniformCF(v color.Color) *UniformCF

func (*UniformCF) Eval2

func (f *UniformCF) Eval2(x, y float64) color.Color

type UniformVF

type UniformVF struct {
	Name  string
	Value []float64
}

func NewUniformVF

func NewUniformVF(v []float64) *UniformVF

func (*UniformVF) Eval2

func (f *UniformVF) Eval2(x, y float64) []float64

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

type VectorField interface {
	Eval2(x, y float64) []float64
}

VectorField defines an evaluation method that given an x and y value, returns a slice of values in the range [-1,1].

type VectorFields

type VectorFields struct {
	Name string
	Srcs []Field
}

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 Warp

type Warp struct {
	Name string
	Src  Field
	Func WarpFunc
}

Warp applies a deformation to the values passed into the Eval2 function.

func NewWarp

func NewWarp(src Field, wf WarpFunc) *Warp

func (*Warp) Eval2

func (w *Warp) Eval2(x, y float64) float64

Eval2 implements the Field 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

func (*WarpCF) Eval2

func (w *WarpCF) Eval2(x, y float64) color.Color

Eval2 implements the ColorField interface.

type WarpFunc

type WarpFunc interface {
	Eval(x, y float64) (float64, float64)
}

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

func (*WarpVF) Eval2

func (w *WarpVF) Eval2(x, y float64) []float64

Eval2 implements the VectorField interface.

type Wave

type Wave interface {
	Eval(v float64) float64
	Lambda() float64
}

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

func (*Weighted) Eval2

func (w *Weighted) Eval2(x, y float64) float64

Eval2 implements the Field interface.

type WeightedCombiner

type WeightedCombiner struct {
	Name string
	Src1 Field
	Src2 Field
	A, B float64
}

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

type WindowedCombiner struct {
	Name string
	Src1 Field
	Src2 Field
	A, B float64
}

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 NewWorleyField(points [][]float64, a, b []float64,
	d func([]float64, []float64) float64, f func(float64) float64,
	scale, offset float64) *WorleyField

func (*WorleyField) Eval2

func (pf *WorleyField) Eval2(x, y float64) float64

Eval2 implements the Field interface.

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.

Jump to

Keyboard shortcuts

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