Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateYAML ¶
GenerateYAML generates YAML from a Canvas
Types ¶
type Background ¶
type Background struct { Color string `yaml:"color,omitempty"` Image string `yaml:"image,omitempty"` }
Background represents the canvas background.
type Canvas ¶
type Canvas struct { Width int `yaml:"width"` Height int `yaml:"height"` Background Background `yaml:"background"` Elements []ElementWrapper `yaml:"elements"` }
Canvas represents the SVG canvas configuration.
func (*Canvas) GetElements ¶
GetElements converts []ElementWrapper to []Element.
type Circle ¶
type Circle struct { Type string `yaml:"type"` ID string `yaml:"id,omitempty"` CX int `yaml:"cx"` CY int `yaml:"cy"` R int `yaml:"r"` Fill string `yaml:"fill,omitempty"` Stroke string `yaml:"stroke,omitempty"` StrokeWidth int `yaml:"stroke_width,omitempty"` Transform *Transform `yaml:"transform,omitempty"` }
Circle represents an SVG circle.
type ElementWrapper ¶
type ElementWrapper struct {
Element
}
ElementWrapper is a proxy for unmarshaling different Element types.
func (ElementWrapper) MarshalYAML ¶
func (ew ElementWrapper) MarshalYAML() (interface{}, error)
MarshalYAML implements custom marshaling for the Element interface.
func (*ElementWrapper) UnmarshalYAML ¶
func (ew *ElementWrapper) UnmarshalYAML(value *yaml.Node) error
UnmarshalYAML implements custom unmarshaling for the Element interface.
type Ellipse ¶
type Ellipse struct { Type string `yaml:"type"` ID string `yaml:"id,omitempty"` CX int `yaml:"cx"` CY int `yaml:"cy"` RX int `yaml:"rx"` RY int `yaml:"ry"` Fill string `yaml:"fill,omitempty"` Stroke string `yaml:"stroke,omitempty"` StrokeWidth int `yaml:"stroke_width,omitempty"` Transform *Transform `yaml:"transform,omitempty"` }
Ellipse represents an SVG ellipse.
type Group ¶
type Group struct { Type string `yaml:"type"` ID string `yaml:"id,omitempty"` Transform *Transform `yaml:"transform,omitempty"` Elements []Element `yaml:"elements"` }
Group represents an SVG group, which can contain nested elements.
func (*Group) GetElements ¶
func (*Group) MarshalYAML ¶
func (*Group) UnmarshalYAML ¶
type Image ¶
type Image struct { Type string `yaml:"type"` ID string `yaml:"id,omitempty"` Href string `yaml:"href"` X int `yaml:"x"` Y int `yaml:"y"` Width int `yaml:"width"` Height int `yaml:"height"` Transform *Transform `yaml:"transform,omitempty"` }
Image represents an SVG image.
type Line ¶
type Line struct { Type string `yaml:"type"` ID string `yaml:"id,omitempty"` X1 int `yaml:"x1"` Y1 int `yaml:"y1"` X2 int `yaml:"x2"` Y2 int `yaml:"y2"` Stroke string `yaml:"stroke,omitempty"` StrokeWidth int `yaml:"stroke_width,omitempty"` Transform *Transform `yaml:"transform,omitempty"` }
Line represents an SVG line.
type Polygon ¶
type Polygon struct { Type string `yaml:"type"` ID string `yaml:"id,omitempty"` Points [][2]int `yaml:"points"` Fill string `yaml:"fill,omitempty"` Stroke string `yaml:"stroke,omitempty"` StrokeWidth int `yaml:"stroke_width,omitempty"` Transform *Transform `yaml:"transform,omitempty"` }
Polygon represents an SVG polygon.
type Rectangle ¶
type Rectangle struct { Type string `yaml:"type"` ID string `yaml:"id,omitempty"` X int `yaml:"x"` Y int `yaml:"y"` Width int `yaml:"width"` Height int `yaml:"height"` Fill string `yaml:"fill,omitempty"` Stroke string `yaml:"stroke,omitempty"` StrokeWidth int `yaml:"stroke_width,omitempty"` Transform *Transform `yaml:"transform,omitempty"` }
Rectangle represents an SVG rectangle.
type SVGDSL ¶
type SVGDSL struct {
SVG Canvas `yaml:"svg"`
}
SVGDSL represents the root of the YAML DSL.
type Text ¶
type Text struct { Type string `yaml:"type"` ID string `yaml:"id,omitempty"` X int `yaml:"x"` Y int `yaml:"y"` Content string `yaml:"content"` FontSize string `yaml:"font_size,omitempty"` FontFamily string `yaml:"font_family,omitempty"` Fill string `yaml:"fill,omitempty"` TextAnchor string `yaml:"text_anchor,omitempty"` Transform *Transform `yaml:"transform,omitempty"` }
Text represents an SVG text element.
type Transform ¶
type Transform struct { Translate []int `yaml:"translate,omitempty"` // [x, y] Rotate float64 `yaml:"rotate,omitempty"` // degrees Scale []float64 `yaml:"scale,omitempty"` // [x, y] }
Transform represents transformations applied to SVG elements.
type Triangle ¶
type Triangle struct { Type string `yaml:"type"` ID string `yaml:"id,omitempty"` Points [][2]int `yaml:"points"` Fill string `yaml:"fill,omitempty"` Stroke string `yaml:"stroke,omitempty"` StrokeWidth int `yaml:"stroke_width,omitempty"` Transform *Transform `yaml:"transform,omitempty"` }
Triangle represents an SVG triangle.