svgdata

package
v0.0.0-...-5926790 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2018 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

View Source
const FLOAT_EQUAL_THRESH = 0.00000001

Comparing floating point sucks. This is probably wrong in the general case but is good enough for this application. Don't assume I know what I'm doing here. I'm pulling stuff out of my butt.

Variables

This section is empty.

Functions

func AlmostEqualsCoord

func AlmostEqualsCoord(a, b geom.Coord) bool

func AlmostEqualsPathCircArc

func AlmostEqualsPathCircArc(a, b *PathCircArc) bool

func AlmostEqualsPathLines

func AlmostEqualsPathLines(a, b *PathLine) bool

func FloatAlmostEqual

func FloatAlmostEqual(a, b float64) bool

Types

type Circle

type Circle struct {
	Center geom.Coord
	Radius float64
}

func (*Circle) Draw

func (me *Circle) Draw(svg *SVGWriter, s ...string)

type Element

type Element interface {
	Draw(w *SVGWriter, s ...string)
}

type OptimizedPathCollection

type OptimizedPathCollection struct {
	Paths []*Path
}

OptimizedPathCollection takes a set of Paths and PathSegments and constructs continuous paths. This is sometimes referred to as "chains". After adding all of the Paths and PathSegments, call Optimize.

func (*OptimizedPathCollection) AddPath

func (opc *OptimizedPathCollection) AddPath(np *Path)

func (*OptimizedPathCollection) AddSegment

func (opc *OptimizedPathCollection) AddSegment(p PathSegment)

func (*OptimizedPathCollection) Draw

func (opc *OptimizedPathCollection) Draw(svg *SVGWriter, s ...string)

func (*OptimizedPathCollection) NumPaths

func (opc *OptimizedPathCollection) NumPaths() int

func (*OptimizedPathCollection) Optimize

func (opc *OptimizedPathCollection) Optimize()

type Path

type Path struct {
	Closed bool
	// contains filtered or unexported fields
}

func (*Path) Back

func (me *Path) Back() PathSegment

func (*Path) BackPoint

func (me *Path) BackPoint() *geom.Coord

func (*Path) Draw

func (me *Path) Draw(svg *SVGWriter, s ...string)

func (*Path) Front

func (me *Path) Front() PathSegment

func (*Path) FrontPoint

func (me *Path) FrontPoint() *geom.Coord

func (*Path) PushBack

func (me *Path) PushBack(seg PathSegment)

func (*Path) PushFront

func (me *Path) PushFront(seg PathSegment)

func (*Path) PushPathBack

func (me *Path) PushPathBack(path *Path)

func (*Path) PushPathFront

func (me *Path) PushPathFront(path *Path)

func (*Path) Reverse

func (me *Path) Reverse()

type PathCircArc

type PathCircArc struct {
	A, B            geom.Coord
	R               float64
	LargeArc, Sweep bool
}

func NewPathCircArc

func NewPathCircArc(a, b geom.Coord, r float64, largeArc, sweep bool) *PathCircArc

func (*PathCircArc) Bounds

func (a *PathCircArc) Bounds() geom.Rect

func (*PathCircArc) Equals

func (a *PathCircArc) Equals(oi interface{}) bool

func (*PathCircArc) P1

func (a *PathCircArc) P1() *geom.Coord

func (*PathCircArc) P2

func (a *PathCircArc) P2() *geom.Coord

func (*PathCircArc) PathDraw

func (a *PathCircArc) PathDraw(svg *SVGWriter)

func (*PathCircArc) Reverse

func (a *PathCircArc) Reverse()

type PathLine

type PathLine struct {
	A, B geom.Coord
}

func NewPathLine

func NewPathLine(a, b geom.Coord) *PathLine

func (*PathLine) Bounds

func (cl *PathLine) Bounds() geom.Rect

func (*PathLine) Equals

func (cl *PathLine) Equals(oi interface{}) bool

func (*PathLine) P1

func (cl *PathLine) P1() *geom.Coord

func (*PathLine) P2

func (cl *PathLine) P2() *geom.Coord

func (*PathLine) PathDraw

func (cl *PathLine) PathDraw(svg *SVGWriter)

func (*PathLine) Reverse

func (cl *PathLine) Reverse()

type PathSegment

type PathSegment interface {
	P1() *geom.Coord
	P2() *geom.Coord
	Reverse()
	PathDraw(w *SVGWriter)
}

type SVGWriter

type SVGWriter struct {
	// contains filtered or unexported fields
}

func NewSVG

func NewSVG(w io.Writer) *SVGWriter

func (*SVGWriter) Circle

func (svg *SVGWriter) Circle(c geom.Coord, r float64, s ...string)

func (*SVGWriter) CircularArc

func (svg *SVGWriter) CircularArc(p1, p2 geom.Coord, r float64, largeArc, sweep bool, s ...string)

func (*SVGWriter) CubicBezier

func (svg *SVGWriter) CubicBezier(p1, ctrl1, ctrl2, p2 geom.Coord, s ...string)

func (*SVGWriter) End

func (svg *SVGWriter) End()

func (*SVGWriter) EndPath

func (svg *SVGWriter) EndPath()

func (*SVGWriter) Line

func (svg *SVGWriter) Line(p1 geom.Coord, p2 geom.Coord, s ...string)

func (*SVGWriter) PathCircularArcTo

func (svg *SVGWriter) PathCircularArcTo(p geom.Coord, r float64, largeArc, sweep bool)

func (*SVGWriter) PathClose

func (svg *SVGWriter) PathClose()

func (*SVGWriter) PathCubicBezierTo

func (svg *SVGWriter) PathCubicBezierTo(p, ctrl1, ctrl2 geom.Coord)

func (*SVGWriter) PathLineTo

func (svg *SVGWriter) PathLineTo(p geom.Coord)

func (*SVGWriter) PathQuadBezierTo

func (svg *SVGWriter) PathQuadBezierTo(p, ctrl1 geom.Coord)

func (*SVGWriter) QuadBezier

func (svg *SVGWriter) QuadBezier(p1 geom.Coord, ctrl1 geom.Coord, p2 geom.Coord, s ...string)

func (*SVGWriter) Start

func (svg *SVGWriter) Start(viewBox geom.Rect, s ...string)

func (*SVGWriter) StartPath

func (svg *SVGWriter) StartPath(p1 geom.Coord, s ...string)

Jump to

Keyboard shortcuts

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