svg

package module
v0.0.0-...-d86af11 Latest Latest
Warning

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

Go to latest
Published: May 5, 2017 License: MIT Imports: 9 Imported by: 0

README

svg

Go library for parsing svg files.
Includes Bezier Curve rasterization.

Currently used for svg2kicad

Documentation

Index

Constants

View Source
const (
	MOVETO = iota
	LINETO
	CURVETO
)

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        string `xml:"cx,attr"`
	Cy        string `xml:"cy,attr"`
	Radius    string `xml:"r,attr"`
	// contains filtered or unexported fields
}

type Command

type Command struct {
	Name   int
	Points []Tuple
}

Command is

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
}

type Group

type Group struct {
	Id              string
	Stroke          string
	StrokeWidth     int32
	Fill            string
	FillRule        string
	Elements        []interface{}
	TransformString string
	Transform       *Transform // row, column
	Parent          *Group
	Owner           *Svg
}

func (*Group) SetOwner

func (g *Group) SetOwner(svg *Svg)

func (*Group) UnmarshalXML

func (g *Group) UnmarshalXML(decoder *xml.Decoder, start xml.StartElement) error

Implements encoding.xml.Unmarshaler interface

type Item

type Item struct {
	Type  ItemType
	Value string
	// contains filtered or unexported fields
}

func (Item) String

func (i Item) String() string

type ItemType

type ItemType int
const (
	ItemError ItemType = iota
	ItemDot
	ItemEOS
	ItemLetter
	ItemWord
	ItemNumber
	ItemComma
	ItemFlag
	ItemWSP
	ItemParan
)

type Lexer

type Lexer struct {
	Items chan Item
	// contains filtered or unexported fields
}

func Lex

func Lex(name, input string) (*Lexer, chan Item)

func (*Lexer) ConsumeWhiteSpace

func (l *Lexer) ConsumeWhiteSpace() error

func (*Lexer) NextItem

func (l *Lexer) NextItem() Item

func (*Lexer) PeekItem

func (l *Lexer) PeekItem() Item

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
}

type Path

type Path struct {
	ID    string `xml:"id,attr"`
	D     string `xml:"d,attr"`
	Style string `xml:"style,attr"`
	// contains filtered or unexported fields
}

Path is

func (*Path) Parse

func (p *Path) Parse() chan *Command

Parse interprets path description, transform and style atttributes to create a channel of segments.

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 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 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
}

type Svg

type Svg struct {
	Title     string  `xml:"title"`
	Groups    []Group `xml:"g"`
	Name      string
	Transform *Transform
	// contains filtered or unexported fields
}

func ParseSvg

func ParseSvg(str string, name string, scale float64) (*Svg, error)

type Transform

type Transform [3][3]float64

func Identity

func Identity() Transform

func MultiplyTransforms

func MultiplyTransforms(a Transform, b Transform) Transform

func NewTransform

func NewTransform() *Transform

func (*Transform) Apply

func (t *Transform) Apply(tuple Tuple) Tuple

func (*Transform) MultiplyWith

func (a *Transform) MultiplyWith(b Transform)

func (*Transform) RotateOrigin

func (t *Transform) RotateOrigin(angle float64)

func (*Transform) RotatePoint

func (t *Transform) RotatePoint(angle float64, x float64, y float64)

func (*Transform) Scale

func (t *Transform) Scale(x float64, y float64)

func (*Transform) SkewX

func (t *Transform) SkewX(angle float64)

func (*Transform) SkewY

func (t *Transform) SkewY(angle float64)

func (*Transform) Translate

func (t *Transform) Translate(x float64, y float64)

type Tuple

type Tuple [2]float64

Jump to

Keyboard shortcuts

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