Documentation
¶
Overview ¶
Package sdf provides primitives for creating and manipulating Signed-Distance-Fields and Displacement-Fields with conversion utilities to and from images.
Index ¶
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func DrawStencil ¶
DrawStencil renders a Stencil into a 2-color image. Using color c for pixels within the stencil and color bg for pixels outside.
Types ¶
type DisplacementField ¶
type DisplacementField struct { *SDF // contains filtered or unexported fields }
DisplacementField is a vectorized Signed-Distance-Field where each field value is associated with its nearest boundary point.
func Calculate ¶
func Calculate(s Stencil) *DisplacementField
Calculate a new DisplacementField from the given Stencil
func (*DisplacementField) NearestBoundaryAt ¶
func (df *DisplacementField) NearestBoundaryAt(x, y int) (int, int)
NearestBoundaryAt returns X,Y coordinate of the nearest boundary point from the given point
type ImageAlphaStencil ¶
ImageAlphaStencil implements a Stencil where the alpha channel of an image is thresholded against the Alpha value
func (ImageAlphaStencil) Size ¶
func (s ImageAlphaStencil) Size() (int, int)
Size returns the width and height of the ImageAlphaStencil
func (ImageAlphaStencil) Within ¶
func (s ImageAlphaStencil) Within(x, y int) bool
Within predicates whether the given coordinate is inside or outside of the stencil surface
type ImplicitSurfaceStencil ¶
ImplicitSurfaceStencil implements a Stencil where a Signed-Distance-Field is thresholded against the Threshold value to define an implicit surface.
func (ImplicitSurfaceStencil) Size ¶
func (s ImplicitSurfaceStencil) Size() (int, int)
Size returns the width and height of the ImplicitSurfaceStencil
func (ImplicitSurfaceStencil) Within ¶
func (s ImplicitSurfaceStencil) Within(x, y int) bool
Within predicates whether the given coordinate is inside or outside of the stencil surface
type SDF ¶
SDF models a rectangular & discretized Signed Distance Field
type Stencil ¶
type Stencil interface { // Within predicates whether the given coordinate is inside or outside of the stencil surface Within(x, y int) bool // Size returns the width and height of the Stencil Size() (int, int) }
Stencil defines a binary surface where pixels are either inside or outside the stencil