svgtosst

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: None detected not legal advice Imports: 0 Imported by: 0

Documentation

Overview

This package converts a SVG file into a coressponding SST 2D geometry representation.

Index

Constants

This section is empty.

Variables

View Source
var IdentityMatrix = Matrix{
	{1, 0, 0},
	{0, 1, 0},
	{0, 0, 1},
}

Identity matrix

Functions

func CombineTransforms

func CombineTransforms(parentTransform, childTransform string) string

func ConverSvgToGraph

func ConverSvgToGraph(svgContent string, id uuid.UUID) (sst.NamedGraph, error)

func ConvertSVGFromText

func ConvertSVGFromText(svgContent, baseName, outputDir string) error

func GetArcCenterPoint

func GetArcCenterPoint(arc EllipticalArc) (float64, float64)

func Transform

func Transform()

Types

type Circle

type Circle struct {
	CX     float64 `xml:"cx,attr"`
	CY     float64 `xml:"cy,attr"`
	Radius float64 `xml:"r,attr"`
	ShapeStyle
	Transform string `xml:"transform,attr,omitempty"`
	Direction float64
}

func (Circle) GetDirection

func (c Circle) GetDirection() float64

func (Circle) GetStyle

func (c Circle) GetStyle() ShapeStyle

func (Circle) GetType

func (c Circle) GetType() string

type CubicBezier

type CubicBezier struct {
	StartX    float64
	StartY    float64
	ControlX1 float64
	ControlY1 float64
	ControlX2 float64
	ControlY2 float64
	EndX      float64
	EndY      float64
}

type Ellipse

type Ellipse struct {
	CX float64 `xml:"cx,attr"`
	CY float64 `xml:"cy,attr"`
	RX float64 `xml:"rx,attr"`
	RY float64 `xml:"ry,attr"`
	ShapeStyle
	Transform string `xml:"transform,attr,omitempty"`
	Direction float64
}

func (Ellipse) GetDirection

func (e Ellipse) GetDirection() float64

func (Ellipse) GetStyle

func (e Ellipse) GetStyle() ShapeStyle

func (Ellipse) GetType

func (e Ellipse) GetType() string

type EllipticalArc

type EllipticalArc struct {
	RX            float64
	RY            float64
	StartX        float64
	StartY        float64
	EndX          float64
	EndY          float64
	XAxisRotation float64
	LargeArcFlag  bool
	SweepFlag     bool
}

type Group

type Group struct {
	XMLName xml.Name `xml:"g"`
	Style   string   `xml:"style,attr,omitempty"`
	ShapeStyle
	Transform string     `xml:"transform,attr,omitempty"`
	Rects     []Rect     `xml:"rect"`
	Texts     []Text     `xml:"text"`
	Circles   []Circle   `xml:"circle"`
	Ellipses  []Ellipse  `xml:"ellipse"`
	Lines     []Line     `xml:"line"`
	Paths     []Path     `xml:"path"`
	Polygons  []Polygon  `xml:"polygon"`
	Polylines []Polyline `xml:"polyline"`
	Groups    []Group    `xml:"g"`
}

type Line

type Line struct {
	XMLName xml.Name `xml:"line"`
	X1      float64  `xml:"x1,attr"`
	Y1      float64  `xml:"y1,attr"`
	X2      float64  `xml:"x2,attr"`
	Y2      float64  `xml:"y2,attr"`
	ShapeStyle
	Transform string `xml:"transform,attr,omitempty"`
	Direction float64
}

func (Line) GetDirection

func (l Line) GetDirection() float64

func (Line) GetStyle

func (l Line) GetStyle() ShapeStyle

func (Line) GetType

func (l Line) GetType() string

type Matrix

type Matrix [3][3]float64

func MatrixTransform

func MatrixTransform(args []float64) Matrix

MatrixTransform creates a transformation matrix from matrix(a, b, c, d, e, f) parameters.

func MultiplyMatrix

func MultiplyMatrix(m1, m2 Matrix) Matrix

Matrix multiplication

func ParseTransform

func ParseTransform(transform string) Matrix

Parse the transform attribute and generate a transformation matrix

func RotateMatrix

func RotateMatrix(args []float64) Matrix

func ScaleMatrix

func ScaleMatrix(args []float64) Matrix

Scaling transformation matrix

func TranslateMatrix

func TranslateMatrix(args []float64) Matrix

Translation transformation matrix

type Path

type Path struct {
	XMLName xml.Name `xml:"path"`
	D       string   `xml:"d,attr"`
	ShapeStyle
	Transform string `xml:"transform,attr,omitempty"`
	Direction float64
}

func (Path) GetDirection

func (p Path) GetDirection() float64

func (Path) GetStyle

func (p Path) GetStyle() ShapeStyle

func (Path) GetType

func (p Path) GetType() string

type PathCommand

type PathCommand struct {
	Command string
	Params  []float64
}

func ParsePathData

func ParsePathData(data string) ([]PathCommand, error)

string -> []PathCommand

type Point

type Point struct {
	X float64
	Y float64
}

type Polygon

type Polygon struct {
	XMLName xml.Name `xml:"polygon"`
	Points  string   `xml:"points,attr"`
	ShapeStyle
	Transform string `xml:"transform,attr,omitempty"`
	Direction float64
}

func (Polygon) GetDirection

func (p Polygon) GetDirection() float64

func (Polygon) GetStyle

func (p Polygon) GetStyle() ShapeStyle

func (Polygon) GetType

func (p Polygon) GetType() string

type Polyline

type Polyline struct {
	XMLName xml.Name `xml:"polyline"`
	Points  string   `xml:"points,attr"`
	ShapeStyle
	Transform string `xml:"transform,attr,omitempty"`
	Direction float64
}

func (Polyline) GetDirection

func (p Polyline) GetDirection() float64

func (Polyline) GetStyle

func (p Polyline) GetStyle() ShapeStyle

func (Polyline) GetType

func (p Polyline) GetType() string

type QuadraticBezier

type QuadraticBezier struct {
	StartX   float64
	StartY   float64
	ControlX float64
	ControlY float64
	EndX     float64
	EndY     float64
}

type Rect

type Rect struct {
	XMLName xml.Name `xml:"rect"`
	Style   string   `xml:"style,attr"`
	XLength float64  `xml:"width,attr"`
	YLength float64  `xml:"height,attr"`
	X       float64  `xml:"x,attr"`
	Y       float64  `xml:"y,attr"`
	RX      float64  `xml:"rx,attr"`
	RY      float64  `xml:"ry,attr"`
	ShapeStyle
	Transform string `xml:"transform,attr,omitempty"`
	Direction float64
}

func (Rect) GetDirection

func (r Rect) GetDirection() float64

func (Rect) GetStyle

func (r Rect) GetStyle() ShapeStyle

func (Rect) GetType

func (r Rect) GetType() string

type SVG

type SVG struct {
	XMLName   xml.Name   `xml:"svg"`
	Width     string     `xml:"width,attr"`
	Height    string     `xml:"height,attr"`
	ViewBox   string     `xml:"viewBox,attr"`
	XMLNS     string     `xml:"xmlns,attr"`
	Version   string     `xml:"version,attr"`
	Title     string     `xml:"title"`
	Desc      string     `xml:"desc"`
	Rects     []Rect     `xml:"rect"`
	Texts     []Text     `xml:"text"`
	Circles   []Circle   `xml:"circle"`
	Ellipses  []Ellipse  `xml:"ellipse"`
	Lines     []Line     `xml:"line"`
	Paths     []Path     `xml:"path"`
	Polygons  []Polygon  `xml:"polygon"`
	Polylines []Polyline `xml:"polyline"`
	Groups    []Group    `xml:"g"`
}

type Shape

type Shape interface {
	GetStyle() ShapeStyle
	GetType() string
	GetDirection() float64
}

func TransformShape

func TransformShape(shape Shape, transform string) Shape

type ShapeStyle

type ShapeStyle struct {
	Fill        string `xml:"fill,attr"`
	Stroke      string `xml:"stroke,attr"`
	StrokeWidth string `xml:"stroke-width,attr"`
}

func CombineShapeStyles

func CombineShapeStyles(parentStyle, currentStyle ShapeStyle) ShapeStyle

type StyledShape

type StyledShape interface {
	Shape
}

type Text

type Text struct {
	XMLName        xml.Name `xml:"text"`
	Style          string   `xml:"style,attr"`
	X              float64  `xml:"x,attr"`
	Y              float64  `xml:"y,attr"`
	Content        string   `xml:",chardata"`
	FontFamily     string   `xml:"font-family,attr,omitempty"`
	FontSize       float64  `xml:"font-size,attr,omitempty"`
	FontStyle      string   `xml:"font-style,attr,omitempty"`
	FontWeight     string   `xml:"font-weight,attr,omitempty"`
	TextDecoration string   `xml:"text-decoration,attr,omitempty"`
	ShapeStyle
	Transform string `xml:"transform,attr,omitempty"`
	Direction float64
}

func (Text) GetDirection

func (t Text) GetDirection() float64

func (Text) GetStyle

func (t Text) GetStyle() ShapeStyle

func (Text) GetType

func (t Text) GetType() string

Jump to

Keyboard shortcuts

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