Documentation ¶
Overview ¶
Package gotrace is a pure Go implementation of potrace vectorization library. More info at http://potrace.sourceforge.net/potracelib.pdf
Index ¶
Constants ¶
const ( // TypeBezier represents Bezier curve segment. TypeBezier = SegmType(1) // TypeCorner represents a corner segment. TypeCorner = SegmType(2) )
const ( TurnBlack = TurnPolicy(0) TurnWhite = TurnPolicy(1) TurnLeft = TurnPolicy(2) TurnRight = TurnPolicy(3) TurnMinority = TurnPolicy(4) TurnMajority = TurnPolicy(5) TurnRandom = TurnPolicy(6) )
Supported turn policies.
Variables ¶
var Defaults = Params{ TurdSize: 2, TurnPolicy: TurnMinority, AlphaMax: 1.0, OptiCurve: true, OptTolerance: 0.2, }
Defaults cores default parameters for tracing.
Functions ¶
func ThresholdAlpha ¶
ThresholdAlpha is a threshold function that cuts fully transparent parts from the image.
Types ¶
type Bitmap ¶
type Bitmap struct {
W, H int // width and height, in pixels
Dy int // words per scanline (not bytes)
Map []Word // raw data, dy*h words
}
Bitmap is an internal bitmap format. The n-th scanline starts at scanline(n) = (map + n*dy). Raster data is stored as a sequence of potrace_words (NOT bytes). The leftmost bit of scanline n is the most significant bit of scanline(n)[0].
func NewBitmapFromImage ¶
func NewBitmapFromImage(img image.Image, threshold ThresholdFunc) *Bitmap
NewBitmapFromImage converts an image to a bitmap using a threshold function. If function is not specified, an Alpha channel will be used for the threshold.
type Params ¶
type Params struct { TurdSize int TurnPolicy TurnPolicy AlphaMax float64 OptiCurve bool OptTolerance float64 }
Params is a set of tracing parameters.
type Path ¶
type Path struct { Area int Sign int Curve []Segment Childs []Path // contains filtered or unexported fields }
Path represents a curve path.
type ThresholdFunc ¶
ThresholdFunc is a function that converts a color to a a single bit value.