Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Circle ¶
type Circle struct { ID string `xml:"id,attr"` Transform string `xml:"transform,attr"` Style string `xml:"style,attr"` Cx float64 `xml:"cx,attr"` Cy float64 `xml:"cy,attr"` Radius float64 `xml:"r,attr"` Fill string `xml:"fill,attr"` // contains filtered or unexported fields }
Circle is an SVG circle element
func (*Circle) ParseDrawingInstructions ¶
func (c *Circle) ParseDrawingInstructions() (chan *DrawingInstruction, chan error)
ParseDrawingInstructions implements the DrawingInstructionParser interface
type CurvePoints ¶
CurvePoints are the points needed by a bezier curve.
type DrawingInstruction ¶
type DrawingInstruction struct { Kind InstructionType M *Tuple CurvePoints *CurvePoints Radius *float64 StrokeWidth *float64 Opacity *float64 Fill *string Stroke *string StrokeLineCap *string StrokeLineJoin *string }
DrawingInstruction contains enough information that a simple drawing library can draw the shapes contained in an SVG file.
The struct contains all necessary fields but only the ones needed (as indicated byt the InstructionType) will be non-nil.
type DrawingInstructionParser ¶
type DrawingInstructionParser interface {
ParseDrawingInstructions() (chan *DrawingInstruction, chan error)
}
DrawingInstructionParser allow getting segments and drawing instructions from them. All SVG elements should implement this interface.
type Ellipse ¶
type Ellipse struct { ID string `xml:"id,attr"` Transform string `xml:"transform,attr"` Style string `xml:"style,attr"` Cx string `xml:"cx,attr"` Cy string `xml:"cy,attr"` Rx string `xml:"rx,attr"` Ry string `xml:"ry,attr"` // contains filtered or unexported fields }
Ellipse is an SVG ellipse XML element
type Group ¶
type Group struct { ID string Stroke string StrokeWidth float64 Fill string Opacity float64 FillRule string Elements []DrawingInstructionParser TransformString string Transform *mt.Transform // row, column Parent *Group Owner *Svg // contains filtered or unexported fields }
Group represents an SVG group (usually located in a 'g' XML element)
func (*Group) ParseDrawingInstructions ¶
func (g *Group) ParseDrawingInstructions() (chan *DrawingInstruction, chan error)
ParseDrawingInstructions implements the DrawingInstructionParser interface
This method makes it easier to get all the drawing instructions.
func (*Group) UnmarshalXML ¶
UnmarshalXML implements the encoding.xml.Unmarshaler interface
type InstructionType ¶
type InstructionType int
InstructionType tells our path drawing library which function it has to call
const ( MoveInstruction InstructionType = iota CircleInstruction CurveInstruction LineInstruction CloseInstruction PaintInstruction )
These are instruction types that we use with our path drawing library
type Line ¶
type Line struct { ID string `xml:"id,attr"` Transform string `xml:"transform,attr"` Style string `xml:"style,attr"` X1 string `xml:"x1,attr"` X2 string `xml:"x2,attr"` Y1 string `xml:"y1,attr"` Y2 string `xml:"y2,attr"` // contains filtered or unexported fields }
Line is an SVG XML line element
type Path ¶
type Path struct { ID string `xml:"id,attr"` D string `xml:"d,attr"` Style string `xml:"style,attr"` TransformString string `xml:"transform,attr"` StrokeWidth float64 `xml:"stroke-width,attr"` Fill *string `xml:"fill,attr"` Opacity *float64 `xml:"opacity,attr"` Stroke *string `xml:"stroke,attr"` StrokeLineCap *string `xml:"stroke-linecap,attr"` StrokeLineJoin *string `xml:"stroke-linejoin,attr"` Segments chan Segment // contains filtered or unexported fields }
Path is an SVG XML path element
func (*Path) Parse ¶
Parse interprets path description, transform and style atttributes to create a channel of segments.
func (*Path) ParseDrawingInstructions ¶
func (p *Path) ParseDrawingInstructions() (chan *DrawingInstruction, chan error)
ParseDrawingInstructions returns two channels. One is a channel of Segments identical to the one returned by Parse() and the other one is a channel of DrawingInstruction. The latter should be used to pass to a path drawing library (like Cairo or something comparable)
type PolyLine ¶
type PolyLine struct { ID string `xml:"id,attr"` Transform string `xml:"transform,attr"` Style string `xml:"style,attr"` Points string `xml:"points,attr"` // contains filtered or unexported fields }
PolyLine is a set of connected line segments that typically form a closed shape
type Polygon ¶
type Polygon struct { ID string `xml:"id,attr"` Transform string `xml:"transform,attr"` Style string `xml:"style,attr"` Points string `xml:"points,attr"` // contains filtered or unexported fields }
Polygon is a closed shape of straight line segments
type Rect ¶
type Rect struct { ID string `xml:"id,attr"` Width string `xml:"width,attr"` Height string `xml:"height,attr"` Transform string `xml:"transform,attr"` Style string `xml:"style,attr"` Rx string `xml:"rx,attr"` Ry string `xml:"ry,attr"` // contains filtered or unexported fields }
Rect is an SVG XML rect element
func (*Rect) ParseDrawingInstructions ¶
func (r *Rect) ParseDrawingInstructions() (chan *DrawingInstruction, chan error)
ParseDrawingInstructions implements the DrawingInstructionParser interface
type Segment ¶
A Segment of a path that contains a list of connected points, its stroke Width and if the segment forms a closed loop. Points are defined in world space after any matrix transformation is applied.
type Svg ¶
type Svg struct { Title string `xml:"title"` Groups []Group `xml:"g"` Width string `xml:"width,attr"` Height string `xml:"height,attr"` ViewBox string `xml:"viewBox,attr"` Elements []DrawingInstructionParser Name string Transform *mt.Transform // contains filtered or unexported fields }
Svg represents an SVG file containing at least a top level group or a number of Paths
func ParseSvgFromReader ¶
ParseSvgFromReader parses an SVG struct from an io.Reader
func (*Svg) ParseDrawingInstructions ¶
func (s *Svg) ParseDrawingInstructions() (chan *DrawingInstruction, chan error)
ParseDrawingInstructions implements the DrawingInstructionParser interface
This method makes it easier to get all the drawing instructions.
func (*Svg) UnmarshalXML ¶
UnmarshalXML implements the encoding.xml.Unmarshaler interface
func (*Svg) ViewBoxValues ¶
ViewBoxValues returns all the numerical values in the viewBox attribute.