Documentation
¶
Index ¶
Constants ¶
View Source
const ( CornerStateTopLeft = CornerStates(1 << iota) CornerStateTopRight CornerStateBottomLeft CornerStateBottomRight )
View Source
const ( DirectionUp = Direction(iota) DirectionRight DirectionDown DirectionLeft DirectionInvalid )
View Source
const CornerStateAll = CornerStateTopLeft | CornerStateTopRight | CornerStateBottomLeft | CornerStateBottomRight
View Source
const CornerStateNone = CornerStates(0)
Variables ¶
View Source
var Redirections [16][4]Direction
Lookup table for the marching squares
View Source
var SaddleCornerStates = [2]CornerStates{ CornerStateTopLeft | CornerStateBottomRight, CornerStateTopRight | CornerStateBottomLeft, }
Functions ¶
func SignedAreaOfPolygon ¶
func TraceImage ¶
func TraceImage(img image.Image, isColorFilledFunc IsColorFilledFunc) [][]Point
Types ¶
type CornerStates ¶
type CornerStates uint8
Whether each corner of the square is set in the original bitmap
func CornerStateForOffset ¶
func CornerStateForOffset(x, y int) CornerStates
func (CornerStates) IsSaddle ¶
func (cs CornerStates) IsSaddle() bool
type IPoint ¶
func (IPoint) ApplyDirection ¶
type IsColorFilledFunc ¶
Callback for determining if a pixel is filled
var DarkColorFilledFunc IsColorFilledFunc = func(c color.Color) bool { if !OpacityColorFilledFunc(c) { return false } y := yValueFromColor(c) return y < 0x80 }
Convert to bitmap by 50% lightness threshold, where black is filled
var LightColorFilledFunc IsColorFilledFunc = func(c color.Color) bool { if !OpacityColorFilledFunc(c) { return false } y := yValueFromColor(c) return y > 0x80 }
Convert to a bitmap by 50% lightness threshold, where white is filled
var OpacityColorFilledFunc IsColorFilledFunc = func(c color.Color) bool {
_, _, _, alpha := c.RGBA()
return alpha > 0xffff/2
}
Convert to bitmap by 50% alpha threshold
type RotationMatrix ¶
type RotationMatrix [4][4]float64
type Square ¶
type Square struct { Point IPoint Corners CornerStates }
A single square for the marching squares algorithm.
func (Square) CornerPointsInDirection ¶
func (Square) DirectionFor ¶
func (Square) DirectionForNeighbor ¶
func (*Square) RemovePathForOutgoingDirection ¶
For an outgoing direction, remove the path by updating the corner states. This allows saddle points to be handled correctly, since they have two paths. If a square loses all its paths, it gets garbage collected
Click to show internal directories.
Click to hide internal directories.