texturing

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMismatchDimensions = errors.New("mismatch texture resolutions")

Functions

func BoxBlur

func BoxBlur(src image.Image) image.Image

func BoxBlurNTimes

func BoxBlurNTimes(src image.Image, iterations int) image.Image

func Convolve

func Convolve[T any](tex Texture[T], f func(x, y int, kernel []T))

func ConvolveArray added in v0.9.0

func ConvolveArray[T any](arr [][]T, f func(x, y int, kernel []T))

func ConvolveImage added in v0.33.0

func ConvolveImage(src image.Image, f func(x, y int, values []color.Color))

[0][1][2] [3][4][5] [6][7][8]

func SimpleEdgeTest added in v0.9.0

func SimpleEdgeTest(kernel []color.Color) bool

Types

type AddColorNode added in v0.33.0

type AddColorNode struct {
	Textures []nodes.Output[Texture[coloring.Color]]
}

func (AddColorNode) Result added in v0.33.0

type AddFloat1Node added in v0.33.0

type AddFloat1Node struct {
	Textures []nodes.Output[Texture[float64]]
}

func (AddFloat1Node) Result added in v0.33.0

func (n AddFloat1Node) Result(out *nodes.StructOutput[Texture[float64]])

type AddFloat2Node added in v0.33.0

type AddFloat2Node struct {
	Textures []nodes.Output[Texture[vector2.Float64]]
}

func (AddFloat2Node) Result added in v0.33.0

type AddFloat3Node added in v0.33.0

type AddFloat3Node struct {
	Textures []nodes.Output[Texture[vector3.Float64]]
}

func (AddFloat3Node) Result added in v0.33.0

type AddFloat4Node added in v0.33.0

type AddFloat4Node struct {
	Textures []nodes.Output[Texture[vector4.Float64]]
}

func (AddFloat4Node) Result added in v0.33.0

type ApplyGradientNode added in v0.33.0

type ApplyGradientNode[T any] struct {
	Time     nodes.Output[Texture[float64]]
	Gradient nodes.Output[coloring.Gradient[T]]
}

func (ApplyGradientNode[T]) Texture added in v0.33.0

func (n ApplyGradientNode[T]) Texture(out *nodes.StructOutput[Texture[T]])

type ApplyMaskNode added in v0.33.0

type ApplyMaskNode[T any] struct {
	Texture nodes.Output[Texture[T]]
	Mask    nodes.Output[Texture[bool]]
	Fill    nodes.Output[T]
}

func (ApplyMaskNode[T]) Kept added in v0.33.0

func (n ApplyMaskNode[T]) Kept(out *nodes.StructOutput[Texture[T]])

func (ApplyMaskNode[T]) Removed added in v0.33.0

func (n ApplyMaskNode[T]) Removed(out *nodes.StructOutput[Texture[T]])

type Artifact added in v0.33.0

type Artifact[T any] struct {
	Texture    Texture[T]
	Conversion func(v T) color.Color
}

func (Artifact[T]) Mime added in v0.33.0

func (a Artifact[T]) Mime() string

func (Artifact[T]) Write added in v0.33.0

func (a Artifact[T]) Write(w io.Writer) error

type ColorToImageNode added in v0.33.0

type ColorToImageNode struct {
	Texture nodes.Output[Texture[coloring.Color]]
}

func (ColorToImageNode) Image added in v0.33.0

type CompareValueNode added in v0.33.0

type CompareValueNode[T vector.Number] struct {
	Texture nodes.Output[Texture[T]]
	Value   nodes.Output[T]
}

func (CompareValueNode[T]) Equal added in v0.33.0

func (n CompareValueNode[T]) Equal(out *nodes.StructOutput[Texture[T]])

func (CompareValueNode[T]) EqualMask added in v0.33.0

func (n CompareValueNode[T]) EqualMask(out *nodes.StructOutput[Texture[bool]])

func (CompareValueNode[T]) GreaterThan added in v0.33.0

func (n CompareValueNode[T]) GreaterThan(out *nodes.StructOutput[Texture[T]])

func (CompareValueNode[T]) GreaterThanMask added in v0.33.0

func (n CompareValueNode[T]) GreaterThanMask(out *nodes.StructOutput[Texture[bool]])

func (CompareValueNode[T]) GreaterThanOrEqualTo added in v0.33.0

func (n CompareValueNode[T]) GreaterThanOrEqualTo(out *nodes.StructOutput[Texture[T]])

func (CompareValueNode[T]) GreaterThanOrEqualToMask added in v0.33.0

func (n CompareValueNode[T]) GreaterThanOrEqualToMask(out *nodes.StructOutput[Texture[bool]])

func (CompareValueNode[T]) LessThan added in v0.33.0

func (n CompareValueNode[T]) LessThan(out *nodes.StructOutput[Texture[T]])

func (CompareValueNode[T]) LessThanMask added in v0.33.0

func (n CompareValueNode[T]) LessThanMask(out *nodes.StructOutput[Texture[bool]])

func (CompareValueNode[T]) LessThanOrEqualTo added in v0.33.0

func (n CompareValueNode[T]) LessThanOrEqualTo(out *nodes.StructOutput[Texture[T]])

func (CompareValueNode[T]) LessThanOrEqualToMask added in v0.33.0

func (n CompareValueNode[T]) LessThanOrEqualToMask(out *nodes.StructOutput[Texture[bool]])

type DebugUV added in v0.33.0

type DebugUV struct {
	ImageResolution int
	BoardResolution int

	PositiveCheckerColor color.Color
	NegativeCheckerColor color.Color

	XColorScale color.Color
	YColorScale color.Color
}

func (DebugUV) Image added in v0.33.0

func (duvt DebugUV) Image() image.Image

type DebugUVNode added in v0.33.0

type DebugUVNode struct {
	ImageResolution      nodes.Output[int]
	BoardResolution      nodes.Output[int]
	PositiveCheckerColor nodes.Output[coloring.Color]
	NegativeCheckerColor nodes.Output[coloring.Color]
	XColorScale          nodes.Output[coloring.Color]
	YColorScale          nodes.Output[coloring.Color]
}

func (DebugUVNode) Result added in v0.33.0

func (n DebugUVNode) Result(out *nodes.StructOutput[image.Image])

type DotProductNode added in v0.33.0

type DotProductNode struct {
	Texture nodes.Output[Texture[vector3.Float64]]
	Vector  nodes.Output[vector3.Float64]
}

func (DotProductNode) DotProduct added in v0.33.0

func (n DotProductNode) DotProduct(out *nodes.StructOutput[Texture[float64]])

type FloatToImageNode added in v0.33.0

func (FloatToImageNode) Image added in v0.33.0

func (FloatToImageNode) Texture added in v0.33.0

type FromArrayNode added in v0.33.0

type FromArrayNode[T any] struct {
	Array  nodes.Output[[]T]
	Width  nodes.Output[int]
	Height nodes.Output[int]
}

func (FromArrayNode[T]) Texture added in v0.33.0

func (n FromArrayNode[T]) Texture(out *nodes.StructOutput[Texture[T]])

type FromImageNode added in v0.37.0

type FromImageNode struct {
	Image nodes.Output[image.Image]
}

func (FromImageNode) Texture added in v0.37.0

type GaussianBlurColorNode added in v0.34.0

type GaussianBlurColorNode struct {
	Texture nodes.Output[Texture[coloring.Color]] `description:"Texture to blur"`
	Radius  nodes.Output[int]                     `description:"Size of the kernel in pixels"`
	Signma  nodes.Output[float64]                 `description:"standard deviation of the gaussian"`
}

func (GaussianBlurColorNode) Value added in v0.34.0

type GaussianBlurFloat2Node added in v0.34.0

type GaussianBlurFloat2Node struct {
	Texture nodes.Output[Texture[vector2.Float64]] `description:"Texture to blur"`
	Radius  nodes.Output[int]                      `description:"Size of the kernel in pixels"`
	Signma  nodes.Output[float64]                  `description:"standard deviation of the gaussian"`
}

func (GaussianBlurFloat2Node) Value added in v0.34.0

type GaussianBlurFloat3Node added in v0.34.0

type GaussianBlurFloat3Node struct {
	Texture nodes.Output[Texture[vector3.Float64]] `description:"Texture to blur"`
	Radius  nodes.Output[int]                      `description:"Size of the kernel in pixels"`
	Signma  nodes.Output[float64]                  `description:"standard deviation of the gaussian"`
}

func (GaussianBlurFloat3Node) Value added in v0.34.0

type GaussianBlurFloatNode added in v0.34.0

type GaussianBlurFloatNode struct {
	Texture nodes.Output[Texture[float64]] `description:"Texture to blur"`
	Radius  nodes.Output[int]              `description:"Size of the kernel in pixels"`
	Signma  nodes.Output[float64]          `description:"standard deviation of the gaussian"`
}

func (GaussianBlurFloatNode) Value added in v0.34.0

type InvalidDimension added in v0.35.0

type InvalidDimension vector2.Vector[int]

func (InvalidDimension) Error added in v0.35.0

func (id InvalidDimension) Error() string

type LinearGradient added in v0.33.0

type LinearGradient[T any] struct {
	Repetitions float64
	Rotation    float64
	Width       int
	Height      int
	Gradient    coloring.Gradient[T]
}

func (LinearGradient[T]) Texture added in v0.33.0

func (lg LinearGradient[T]) Texture() Texture[T]

type LinearGradientNode added in v0.33.0

type LinearGradientNode[T any] struct {
	Repetitions nodes.Output[float64]
	Rotation    nodes.Output[float64]
	Width       nodes.Output[int]
	Height      nodes.Output[int]
	Gradient    nodes.Output[coloring.Gradient[T]]
}

func (LinearGradientNode[T]) LinearGradient added in v0.33.0

func (n LinearGradientNode[T]) LinearGradient(out *nodes.StructOutput[Texture[T]])

type MaskToSDFNode added in v0.37.0

type MaskToSDFNode struct {
	Mask nodes.Output[Texture[bool]]
}

func (MaskToSDFNode) NormalizedSDF added in v0.37.0

func (n MaskToSDFNode) NormalizedSDF(out *nodes.StructOutput[Texture[float64]])

func (MaskToSDFNode) SDF added in v0.37.0

type MultiplyFloat1Node added in v0.33.0

type MultiplyFloat1Node struct {
	Textures []nodes.Output[Texture[float64]]
}

func (MultiplyFloat1Node) Result added in v0.33.0

type NoiseNode added in v0.33.0

type NoiseNode struct {
	Width       nodes.Output[int]             `description:"number of pixels in the x direction of the texture"`
	Height      nodes.Output[int]             `description:"number of pixels in the y direction of the texture"`
	Scale       nodes.Output[vector2.Float64] `description:"the X and Y scale of the first octave noise"`
	Folds       nodes.Output[int]             `description:"the number of folds (offsetting the noise negatively and taking the absolute value)"`
	Octaves     nodes.Output[int]             `description:"the number of iterations"`
	Persistence nodes.Output[float64]         `description:"the strength of each subsequent iteration"`
	Offset      nodes.Output[float64]         `description:"the offset of the points, can be used to animate the noise"`
	Seed        nodes.Output[float64]         `description:"RNG seed"`
	Polar       nodes.Output[bool]            `description:"Whether or not to use polar coordinates to sample the random function"`
}

func (NoiseNode) Cellular added in v0.33.0

func (n NoiseNode) Cellular(out *nodes.StructOutput[Texture[float64]])

func (NoiseNode) Cellular2 added in v0.33.0

func (n NoiseNode) Cellular2(out *nodes.StructOutput[Texture[float64]])

func (NoiseNode) Cellular3 added in v0.33.0

func (n NoiseNode) Cellular3(out *nodes.StructOutput[Texture[float64]])

func (NoiseNode) Cellular4 added in v0.33.0

func (n NoiseNode) Cellular4(out *nodes.StructOutput[Texture[float64]])

func (NoiseNode) Cellular5 added in v0.33.0

func (n NoiseNode) Cellular5(out *nodes.StructOutput[Texture[float64]])

func (NoiseNode) Cellular6 added in v0.33.0

func (n NoiseNode) Cellular6(out *nodes.StructOutput[Texture[float64]])

func (NoiseNode) Perlin added in v0.33.0

func (n NoiseNode) Perlin(out *nodes.StructOutput[Texture[float64]])

func (NoiseNode) Simplex added in v0.33.0

func (n NoiseNode) Simplex(out *nodes.StructOutput[Texture[float64]])

func (NoiseNode) Value added in v0.33.0

func (n NoiseNode) Value(out *nodes.StructOutput[Texture[float64]])

func (NoiseNode) ValueDescription added in v0.33.0

func (n NoiseNode) ValueDescription() string

func (NoiseNode) Voronoise added in v0.33.0

func (n NoiseNode) Voronoise(out *nodes.StructOutput[Texture[float64]])

type OneMinusNode added in v0.33.0

type OneMinusNode struct {
	Texture nodes.Output[Texture[float64]]
}

func (OneMinusNode) Result added in v0.33.0

func (n OneMinusNode) Result(out *nodes.StructOutput[Texture[float64]])

type PerlinNode added in v0.33.0

type PerlinNode struct {
	Width     nodes.Output[int]
	Height    nodes.Output[int]
	Positive  nodes.Output[float64]
	Negative  nodes.Output[float64]
	Frequency nodes.Output[vector2.Float64]
}

func (PerlinNode) Out added in v0.33.0

type RadialGradient added in v0.33.0

type RadialGradient[T any] struct {
	Repetitions float64
	Width       int
	Height      int
	Gradient    coloring.Gradient[T]
}

func (RadialGradient[T]) Texture added in v0.33.0

func (rg RadialGradient[T]) Texture() Texture[T]

type RadialGradientNode added in v0.33.0

type RadialGradientNode[T any] struct {
	Repetitions nodes.Output[float64]
	Width       nodes.Output[int]
	Height      nodes.Output[int]
	Gradient    nodes.Output[coloring.Gradient[T]]
}

func (RadialGradientNode[T]) LinearGradient added in v0.33.0

func (n RadialGradientNode[T]) LinearGradient(out *nodes.StructOutput[Texture[T]])

type SampleSDFNode added in v0.37.0

type SampleSDFNode struct {
	Texture nodes.Output[Texture[float64]]
	Size    nodes.Output[vector3.Float64]
}

func (SampleSDFNode) SDF added in v0.37.0

type ScaleColorNode added in v0.33.0

type ScaleColorNode struct {
	Texture nodes.Output[Texture[coloring.Color]]
	Scale   nodes.Output[Texture[float64]]
}

func (ScaleColorNode) Result added in v0.33.0

type ScaleColorUniformNode added in v0.33.0

type ScaleColorUniformNode struct {
	Texture nodes.Output[Texture[coloring.Color]]
	Scale   nodes.Output[float64]
}

func (ScaleColorUniformNode) Result added in v0.33.0

type ScaleFloat1UniformNode added in v0.33.0

type ScaleFloat1UniformNode struct {
	Texture nodes.Output[Texture[float64]]
	Scale   nodes.Output[float64]
}

func (ScaleFloat1UniformNode) Result added in v0.33.0

type ScaleFloat2UniformNode added in v0.33.0

type ScaleFloat2UniformNode struct {
	Texture nodes.Output[Texture[vector2.Float64]]
	Scale   nodes.Output[float64]
}

func (ScaleFloat2UniformNode) Result added in v0.33.0

type ScaleFloat3UniformNode added in v0.33.0

type ScaleFloat3UniformNode struct {
	Texture nodes.Output[Texture[vector3.Float64]]
	Scale   nodes.Output[float64]
}

func (ScaleFloat3UniformNode) Result added in v0.33.0

type ScaleFloat4UniformNode added in v0.33.0

type ScaleFloat4UniformNode struct {
	Texture nodes.Output[Texture[vector4.Float64]]
	Scale   nodes.Output[float64]
}

func (ScaleFloat4UniformNode) Result added in v0.33.0

type SeamlessPerlinNode added in v0.17.0

type SeamlessPerlinNode struct {
	Dimensions nodes.Output[int]
	Positive   nodes.Output[float64]
	Negative   nodes.Output[float64]
	Octaves    nodes.Output[int]
	Frequency  nodes.Output[float64]
}

func (SeamlessPerlinNode) Out added in v0.33.0

type SelectColorNode added in v0.37.0

type SelectColorNode struct {
	Texture nodes.Output[Texture[coloring.Color]]
}

func (SelectColorNode) A added in v0.37.0

func (SelectColorNode) Array added in v0.37.0

func (n SelectColorNode) Array(out *nodes.StructOutput[[]coloring.Color])

func (SelectColorNode) B added in v0.37.0

func (SelectColorNode) G added in v0.37.0

func (SelectColorNode) Height added in v0.37.0

func (n SelectColorNode) Height(out *nodes.StructOutput[int])

func (SelectColorNode) R added in v0.37.0

func (SelectColorNode) Width added in v0.37.0

func (n SelectColorNode) Width(out *nodes.StructOutput[int])

type SelectNode added in v0.33.0

type SelectNode[T any] struct{ Texture nodes.Output[Texture[T]] }

func (SelectNode[T]) Array added in v0.33.0

func (n SelectNode[T]) Array(out *nodes.StructOutput[[]T])

func (SelectNode[T]) Height added in v0.33.0

func (n SelectNode[T]) Height(out *nodes.StructOutput[int])

func (SelectNode[T]) Width added in v0.33.0

func (n SelectNode[T]) Width(out *nodes.StructOutput[int])

type Texture added in v0.25.0

type Texture[T any] struct {
	// contains filtered or unexported fields
}

func ApplyGradient added in v0.33.0

func ApplyGradient[T any](time Texture[float64], gradient coloring.Gradient[T]) Texture[T]

func ClampColor added in v0.34.0

func ClampColor(a Texture[coloring.Color], minimum, maximum float64) Texture[coloring.Color]

func Convert added in v0.25.0

func Convert[T, G any](in Texture[T], cb func(x int, y int, v T) G) Texture[G]

func DivideColor added in v0.34.0

func DivideColor(a, b Texture[coloring.Color]) (*Texture[coloring.Color], error)

func DotProduct added in v0.33.0

func DotProduct(texture Texture[vector3.Float64], v vector3.Float64) Texture[float64]

func Empty added in v0.35.0

func Empty[T any](width, height int) Texture[T]

func FromArray added in v0.35.0

func FromArray[T any](arr []T, width, height int) Texture[T]

func FromImage added in v0.34.0

func FromImage(img image.Image) Texture[coloring.Color]

func MaxColor added in v0.34.0

func MaxColor(a Texture[coloring.Color], other float64) Texture[coloring.Color]

func OneMinus added in v0.34.0

func OneMinus(in Texture[float64]) Texture[float64]

func RadialGaussianBlur added in v0.34.0

func RadialGaussianBlur[T any](space vector.Space[T], src Texture[T], radius int, sigma float64) Texture[T]

GaussianBlur applies a Gaussian blur to the texture

func ScaleUniform added in v0.34.0

func ScaleUniform[T any](tex Texture[T], amount float64, space vector.Space[T]) Texture[T]

func ToSDF added in v0.37.0

func ToSDF(tex Texture[bool]) Texture[float64]

Implementation of:

Distance Transforms of Sampled Functions
by Pedro F. Felzenszwalb and Daniel P. Huttenlocher
https://cs.brown.edu/people/pfelzens/papers/dt-final.pdf

func (Texture[T]) Copy added in v0.25.0

func (t Texture[T]) Copy() Texture[T]

func (Texture[T]) Fill added in v0.25.0

func (t Texture[T]) Fill(v T)

func (Texture[T]) Get added in v0.25.0

func (t Texture[T]) Get(x, y int) T

func (Texture[T]) Height added in v0.25.0

func (t Texture[T]) Height() int

func (Texture[T]) Mutate added in v0.34.0

func (t Texture[T]) Mutate(cb func(x int, y int, v T) T)

func (Texture[T]) MutateParallel added in v0.34.0

func (t Texture[T]) MutateParallel(cb func(x int, y int, v T) T)

func (Texture[T]) MutateParallelAcross added in v0.34.0

func (t Texture[T]) MutateParallelAcross(workers int, cb func(x int, y int, v T) T)

func (Texture[T]) Pixels added in v0.33.0

func (t Texture[T]) Pixels() int

func (Texture[T]) SaveImage added in v0.25.0

func (t Texture[T]) SaveImage(fp string, conv func(T) color.Color) error

func (Texture[T]) Scan added in v0.25.0

func (t Texture[T]) Scan(cb func(x int, y int, v T))

func (Texture[T]) ScanParallel added in v0.34.0

func (t Texture[T]) ScanParallel(cb func(x int, y int, v T))

func (Texture[T]) ScanParallelAcross added in v0.34.0

func (t Texture[T]) ScanParallelAcross(workers int, cb func(x int, y int, v T))

func (Texture[T]) SearchNeighborhood added in v0.25.0

func (t Texture[T]) SearchNeighborhood(start vector2.Int, size int, cb func(x int, y int, v T))

func (Texture[T]) Set added in v0.25.0

func (t Texture[T]) Set(x, y int, v T)

func (Texture[T]) ToImage added in v0.25.0

func (t Texture[T]) ToImage(f func(T) color.Color) *image.RGBA

func (Texture[T]) UV added in v0.33.0

func (t Texture[T]) UV(x, y float64) T

func (Texture[T]) Width added in v0.25.0

func (t Texture[T]) Width() int

type UniformNode added in v0.33.0

type UniformNode[T any] struct {
	Fill   nodes.Output[T]
	Width  nodes.Output[int]
	Height nodes.Output[int]
}

func (UniformNode[T]) Texture added in v0.33.0

func (n UniformNode[T]) Texture(out *nodes.StructOutput[Texture[T]])

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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