diff options
Diffstat (limited to 'svgbasic.go')
-rw-r--r-- | svgbasic.go | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/svgbasic.go b/svgbasic.go index 526f4eb..749933e 100644 --- a/svgbasic.go +++ b/svgbasic.go @@ -34,15 +34,15 @@ func init() { "M", " M ", "m", " m ") } -// SvgBasicSegmentType describes a single curve or position segment -type SvgBasicSegmentType struct { +// SVGBasicSegmentType describes a single curve or position segment +type SVGBasicSegmentType struct { Cmd byte // See http://www.w3.org/TR/SVG/paths.html for path command structure Arg [6]float64 } -func absolutizePath(segs []SvgBasicSegmentType) { +func absolutizePath(segs []SVGBasicSegmentType) { var x, y float64 - var segPtr *SvgBasicSegmentType + var segPtr *SVGBasicSegmentType adjust := func(pos int, adjX, adjY float64) { segPtr.Arg[pos] += adjX segPtr.Arg[pos+1] += adjY @@ -83,8 +83,8 @@ func absolutizePath(segs []SvgBasicSegmentType) { } } -func pathParse(pathStr string) (segs []SvgBasicSegmentType, err error) { - var seg SvgBasicSegmentType +func pathParse(pathStr string) (segs []SVGBasicSegmentType, err error) { + var seg SVGBasicSegmentType var j, argJ, argCount, prevArgCount int setup := func(n int) { // It is not strictly necessary to clear arguments, but result may be clearer @@ -154,20 +154,20 @@ func pathParse(pathStr string) (segs []SvgBasicSegmentType, err error) { return } -// SvgBasicType aggregates the information needed to describe a multi-segment +// SVGBasicType aggregates the information needed to describe a multi-segment // basic vector image -type SvgBasicType struct { +type SVGBasicType struct { Wd, Ht float64 - Segments [][]SvgBasicSegmentType + Segments [][]SVGBasicSegmentType } -// SvgBasicParse parses a simple scalable vector graphics (SVG) buffer into a +// SVGBasicParse parses a simple scalable vector graphics (SVG) buffer into a // descriptor. Only a small subset of the SVG standard, in particular the path // information generated by jSignature, is supported. The returned path data // includes only the commands 'M' (absolute moveto: x, y), 'L' (absolute // lineto: x, y), and 'C' (absolute cubic Bézier curve: cx0, cy0, cx1, cy1, // x1,y1). -func SvgBasicParse(buf []byte) (sig SvgBasicType, err error) { +func SVGBasicParse(buf []byte) (sig SVGBasicType, err error) { type pathType struct { D string `xml:"d,attr"` } @@ -181,7 +181,7 @@ func SvgBasicParse(buf []byte) (sig SvgBasicType, err error) { if err == nil { if src.Wd > 0 && src.Ht > 0 { sig.Wd, sig.Ht = src.Wd, src.Ht - var segs []SvgBasicSegmentType + var segs []SVGBasicSegmentType for _, path := range src.Paths { if err == nil { segs, err = pathParse(path.D) @@ -198,14 +198,14 @@ func SvgBasicParse(buf []byte) (sig SvgBasicType, err error) { return } -// SvgBasicFileParse parses a simple scalable vector graphics (SVG) file into a -// basic descriptor. See SvgBasicParse for additional comments and tutorial 20 +// SVGBasicFileParse parses a simple scalable vector graphics (SVG) file into a +// basic descriptor. See SVGBasicParse for additional comments and tutorial 20 // for an example of this function. -func SvgBasicFileParse(svgFileStr string) (sig SvgBasicType, err error) { +func SVGBasicFileParse(svgFileStr string) (sig SVGBasicType, err error) { var buf []byte buf, err = ioutil.ReadFile(svgFileStr) if err == nil { - sig, err = SvgBasicParse(buf) + sig, err = SVGBasicParse(buf) } return } |