Documentation ¶
Overview ¶
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Package svg holds SVG object creation and manipulation methods.
Index ¶
- Constants
- func Convert(input, output string)
- func ConvertToSize(input, output string, width, height int)
- func LoadStyle(path string) string
- func Round3(val float64) float64
- type Circle
- type Defs
- type Element
- type Ellipse
- type FilterEffect
- type GraphicElement
- func (ge *GraphicElement) IsElement() bool
- func (ge *GraphicElement) NoFill()
- func (ge *GraphicElement) NoStroke()
- func (ge *GraphicElement) RotateDeg(deg float64)
- func (ge *GraphicElement) RotateRad(rad float64)
- func (ge *GraphicElement) Scale(x, y float64)
- func (ge *GraphicElement) SetFillColor(c color.Color)
- func (ge *GraphicElement) SetFillOpacity(opacity float64)
- func (ge *GraphicElement) SetFillRGB(r, g, b int)
- func (ge *GraphicElement) SetFillRandom()
- func (ge *GraphicElement) SetFilters(filters ...string)
- func (ge *GraphicElement) SetID(id string)
- func (ge *GraphicElement) SetLineCap(cap string)
- func (ge *GraphicElement) SetLineJoin(cap string)
- func (ge *GraphicElement) SetMiterLimit(limit float64)
- func (ge *GraphicElement) SetStrokeColor(c color.Color)
- func (ge *GraphicElement) SetStrokeDash(dash ...int)
- func (ge *GraphicElement) SetStrokeOpacity(width float64)
- func (ge *GraphicElement) SetStrokeRGB(r, g, b int)
- func (ge *GraphicElement) SetStrokeWidth(width float64)
- func (ge *GraphicElement) SetStyle(style string)
- func (ge *GraphicElement) Translate(x, y float64)
- func (ge *GraphicElement) Uniscale(s float64)
- type Group
- type Line
- type Path
- type Polygon
- type Polyline
- type Rect
- type SVG
- func (s *SVG) AddCircle(x, y, r float64) *Circle
- func (s *SVG) AddElement(element Element)
- func (s *SVG) AddEllipse(x, y, rx, ry float64) *Ellipse
- func (s *SVG) AddFilter(fe *FilterEffect)
- func (s *SVG) AddGroup() *Group
- func (s *SVG) AddGroupDef() *Group
- func (s *SVG) AddLine(x1, y1, x2, y2 float64) *Line
- func (s *SVG) AddPath() *Path
- func (s *SVG) AddPolygon(points ...float64) *Polygon
- func (s *SVG) AddPolyline(points ...float64) *Polyline
- func (s *SVG) AddRect(x, y, w, h float64) *Rect
- func (s *SVG) AddRegularPolygon(x, y float64, points int, radius, rotation float64) *Polygon
- func (s *SVG) AddStar(x, y float64, points int, innerRadius, outerRadius, rotation float64) *Polygon
- func (s *SVG) AddStyleSheet(path string)
- func (s *SVG) AddText(x, y float64, text string) *Text
- func (s *SVG) AddUse(href string, x, y float64) *Use
- func (s *SVG) SetBackgroundRGB(r, g, b int)
- func (s *SVG) WriteToFile(filename string) error
- type StyleSheet
- type Text
- type Use
Constants ¶
const ( // EvenOdd is the fill rule "evenodd" EvenOdd = "evenodd" // NonZero is the fill rule "NonZero" NonZero = "nonzero" // Butt is the stroke line cap constant for "butt" Butt = "butt" // Square is the stroke line cap constant for "square" Square = "square" // Round is the stroke line cap or stroke line join constant for "round" Round = "round" // Miter is the stroke line join constant for "miter" Miter = "miter" // Bevel is the stroke line join constant for "bevel" Bevel = "bevel" // Normal is the normal constant for font-weight or font-style Normal = "normal" // Bold is the bold font-weight constant. Bold = "bold" // Italic is the italic font-style constant. Italic = "italic" // Underline is the underline text-decoration constant. Underline = "underline" // Overline is the overline text-decoration constant. Overline = "overline" // LineThrough is the line-through text-decoration constant. LineThrough = "line-through" )
Variables ¶
This section is empty.
Functions ¶
func Convert ¶
func Convert(input, output string)
Convert uses ImageMagick convert to convert an image from one format to another.
func ConvertToSize ¶
ConvertToSize uses rsvg-convert to convert an svg to a png with a given size
Types ¶
type Circle ¶
type Circle struct { GraphicElement XMLName xml.Name `xml:"circle"` Cx float64 `xml:"cx,attr"` Cy float64 `xml:"cy,attr"` Radius float64 `xml:"r,attr"` }
Circle creates a new Circle object.
type Defs ¶
type Defs struct { Style []*StyleSheet FilterEffects []*FilterEffect Groups []*Group }
Defs holds styles, etc.
type Element ¶
type Element interface { IsElement() bool SetFillColor(color.Color) SetFillRGB(int, int, int) SetFillOpacity(float64) NoFill() SetStrokeColor(color.Color) SetStrokeRGB(int, int, int) SetStrokeWidth(float64) SetStrokeOpacity(float64) SetStrokeDash(...int) NoStroke() SetStyle(string) }
Element is an interface defining an SVG Element.
type Ellipse ¶
type Ellipse struct { GraphicElement XMLName xml.Name `xml:"ellipse"` Cx float64 `xml:"cx,attr"` Cy float64 `xml:"cy,attr"` Rx float64 `xml:"rx,attr"` Ry float64 `xml:"ry,attr"` }
Ellipse creates a new Ellipse object.
func NewEllipse ¶
NewEllipse creates a new Ellipse object.
type FilterEffect ¶
type FilterEffect struct { XMLName xml.Name `xml:"filter"` ID string `xml:"id,attr"` Filter string `xml:",innerxml"` X string `xml:"x,attr,omitempty"` Y string `xml:"y,attr,omitempty"` Width string `xml:"width,attr,omitempty"` Height string `xml:"height,attr,omitempty"` }
FilterEffect defines a filter effect.
func NewBlurFilter ¶
func NewBlurFilter(id string, blur float64) *FilterEffect
NewBlurFilter creates a new drop shadow filter effect
func NewDropShadow ¶
func NewDropShadow(id string, blur, strength, dx, dy float64) *FilterEffect
NewDropShadow creates a new drop shadow filter effect
func NewGlowFilter ¶
func NewGlowFilter(id string, blur, r, g, b, a float64) *FilterEffect
NewGlowFilter creates a new glow filter effect rgba values are float64s in the range of 0.0 to 1.0.
func (*FilterEffect) SetBoundPercent ¶
func (fe *FilterEffect) SetBoundPercent(percent int)
SetBoundPercent sets the bounds of the filter in terms of percent of the object's bounding box. Sets all bounds with a single value. The default values would be equivalent to passing 10 here, allowing for 10% more on each side.
func (*FilterEffect) SetBoundPercents ¶
func (fe *FilterEffect) SetBoundPercents(x, y, w, h int)
SetBoundPercents sets the bounds of the filter in terms of percent of the object's bounding box. Allows for setting the bounds on each edge separately. The default values would be equivalent to passing 10, 10, 120, 120 here, allowing for 10% more on each side.
type GraphicElement ¶
type GraphicElement struct { ID string `xml:"id,attr,omitempty"` Stroke string `xml:"stroke,attr,omitempty"` Fill string `xml:"fill,attr,omitempty"` FillOpacity float64 `xml:"fill-opacity,attr,omitempty"` StrokeWidth float64 `xml:"stroke-width,attr,omitempty"` StrokeOpacity float64 `xml:"stroke-opacity,attr,omitempty"` StrokeDash string `xml:"stroke-dasharray,attr,omitempty"` Style string `xml:"style,attr,omitempty"` Class string `xml:"class,attr,omitempty"` LineCap string `xml:"stroke-linecap,attr,omitempty"` LineJoin string `xml:"stroke-linejoin,attr,omitempty"` MiterLimit float64 `xml:"stroke-miterlimit,attr,omitempty"` Filters string `xml:"filter,attr,omitempty"` Transform string `xml:"transform,attr,omitempty"` }
GraphicElement represents an SVG Node.
func NewGraphicElement ¶
func NewGraphicElement() *GraphicElement
NewGraphicElement returns a new GraphicElement
func (*GraphicElement) IsElement ¶
func (ge *GraphicElement) IsElement() bool
IsElement returns true for Elements.
func (*GraphicElement) NoFill ¶
func (ge *GraphicElement) NoFill()
NoFill sets the fill of the element to "none".
func (*GraphicElement) NoStroke ¶
func (ge *GraphicElement) NoStroke()
NoStroke sets the element to render without a stroke.
func (*GraphicElement) RotateDeg ¶
func (ge *GraphicElement) RotateDeg(deg float64)
RotateDeg rotates the element the given number of degrees.
func (*GraphicElement) RotateRad ¶
func (ge *GraphicElement) RotateRad(rad float64)
RotateRad rotates the element the given number of radians.
func (*GraphicElement) Scale ¶
func (ge *GraphicElement) Scale(x, y float64)
Scale scales the element the given percent.
func (*GraphicElement) SetFillColor ¶
func (ge *GraphicElement) SetFillColor(c color.Color)
SetFillColor sets the fill attribute using a blgo Color
func (*GraphicElement) SetFillOpacity ¶
func (ge *GraphicElement) SetFillOpacity(opacity float64)
SetFillOpacity sets the opacity of the stroke on this element.
func (*GraphicElement) SetFillRGB ¶
func (ge *GraphicElement) SetFillRGB(r, g, b int)
SetFillRGB sets the fill color of this element with rgb integer values and full opacity.
func (*GraphicElement) SetFillRandom ¶
func (ge *GraphicElement) SetFillRandom()
SetFillRandom sets the fill to a random color.
func (*GraphicElement) SetFilters ¶
func (ge *GraphicElement) SetFilters(filters ...string)
SetFilters sets a list of filters to use on this element.
func (*GraphicElement) SetID ¶
func (ge *GraphicElement) SetID(id string)
SetID sets the id of the element.
func (*GraphicElement) SetLineCap ¶
func (ge *GraphicElement) SetLineCap(cap string)
SetLineCap sets the line cap of this element.
func (*GraphicElement) SetLineJoin ¶
func (ge *GraphicElement) SetLineJoin(cap string)
SetLineJoin sets the line join of this polygon.
func (*GraphicElement) SetMiterLimit ¶
func (ge *GraphicElement) SetMiterLimit(limit float64)
SetMiterLimit sets the miter limit of this polygon.
func (*GraphicElement) SetStrokeColor ¶
func (ge *GraphicElement) SetStrokeColor(c color.Color)
SetStrokeColor sets the stroke attribute using a blgo Color
func (*GraphicElement) SetStrokeDash ¶
func (ge *GraphicElement) SetStrokeDash(dash ...int)
SetStrokeDash sets the dash values for a stroke.
func (*GraphicElement) SetStrokeOpacity ¶
func (ge *GraphicElement) SetStrokeOpacity(width float64)
SetStrokeOpacity sets the width of the stroke on this element.
func (*GraphicElement) SetStrokeRGB ¶
func (ge *GraphicElement) SetStrokeRGB(r, g, b int)
SetStrokeRGB sets the stroke color of this element with rgb integer values and full opacity.
func (*GraphicElement) SetStrokeWidth ¶
func (ge *GraphicElement) SetStrokeWidth(width float64)
SetStrokeWidth sets the width of the stroke on this element.
func (*GraphicElement) SetStyle ¶
func (ge *GraphicElement) SetStyle(style string)
SetStyle sets an inline style.
func (*GraphicElement) Translate ¶
func (ge *GraphicElement) Translate(x, y float64)
Translate rotates the element the given number of degrees.
func (*GraphicElement) Uniscale ¶
func (ge *GraphicElement) Uniscale(s float64)
Uniscale scales the element the given percent.
type Group ¶
type Group struct { GraphicElement XMLName xml.Name `xml:"g"` Elements []Element }
Group creates a new Circle object.
func (*Group) AddElement ¶
AddElement adds and element to the group.
type Line ¶
type Line struct { GraphicElement 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"` }
Line creates a new Line object.
type Path ¶
type Path struct { GraphicElement XMLName xml.Name `xml:"path"` D string `xml:"d,attr"` }
Path creates a new Path object.
func (*Path) CubicCurveTo ¶
CubicCurveTo draws a quadratic bezier curve.
func (*Path) QuadraticCurveTo ¶
QuadraticCurveTo draws a quadratic bezier curve.
type Polygon ¶
type Polygon struct { GraphicElement XMLName xml.Name `xml:"polygon"` Points string `xml:"points,attr"` FillRule string `xml:"fill-rule,attr,omitempty"` }
Polygon creates a new Polygon object.
func NewPolygon ¶
NewPolygon creates a new Polygon object.
func NewRegularPolygon ¶
NewRegularPolygon creates a regular polygon with the given number of points, radius and rotation.
type Polyline ¶
type Polyline struct { GraphicElement XMLName xml.Name `xml:"polyline"` Points string `xml:"points,attr"` }
Polyline creates a new Polyline object.
func NewPolyline ¶
NewPolyline creates a new Polyline object.
type Rect ¶
type Rect struct { GraphicElement XMLName xml.Name `xml:"rect"` X float64 `xml:"x,attr"` Y float64 `xml:"y,attr"` Width float64 `xml:"width,attr"` Height float64 `xml:"height,attr"` Rx float64 `xml:"rx,attr,omitempty"` Ry float64 `xml:"ry,attr,omitempty"` }
Rect creates a new Rect object.
type SVG ¶
type SVG struct { XMLName xml.Name `xml:"svg"` StyleSheet string `xml:"-"` Width float64 `xml:"width,attr"` Height float64 `xml:"height,attr"` Namespace string `xml:"xmlns,attr"` Title string `xml:"title"` Description string `xml:"desc,omitempty"` Style string `xml:"style,omitempty"` BackgroundRect *Rect `xml:"rect"` Defs *Defs `xml:"defs,omitempty"` Elements []Element }
SVG is a struct representing an SVG object.
func (*SVG) AddElement ¶
AddElement adds a new GraphicElement to the SVG.
func (*SVG) AddEllipse ¶
AddEllipse adds a new Ellipse object to the SVG.
func (*SVG) AddFilter ¶
func (s *SVG) AddFilter(fe *FilterEffect)
AddFilter adds an filter effect to the SVG.
func (*SVG) AddGroupDef ¶
AddGroupDef adds a new Group object to the SVG.
func (*SVG) AddPolygon ¶
AddPolygon adds a new Polygon object to the SVG.
func (*SVG) AddPolyline ¶
AddPolyline adds a new Polyline object to the SVG.
func (*SVG) AddRegularPolygon ¶
AddRegularPolygon adds a new Rect object to the SVG.
func (*SVG) AddStar ¶
func (s *SVG) AddStar(x, y float64, points int, innerRadius, outerRadius, rotation float64) *Polygon
AddStar adds a new Star object to the SVG.
func (*SVG) AddStyleSheet ¶
AddStyleSheet adds an internal stylesheet to the SVG document, with the given path. The stylesheet is embedded in the SVG document at compile time. Imagemagick convert respects the styles set there, but not external stylesheets.
func (*SVG) SetBackgroundRGB ¶
SetBackgroundRGB creates a background rect of the given color.
func (*SVG) WriteToFile ¶
WriteToFile saves this SVG object as an SVG file.
type StyleSheet ¶
type StyleSheet struct { XMLName xml.Name `xml:"style"` Type string `xml:"type,attr"` StyleData string `xml:",cdata"` }
StyleSheet respresents an internal stylesheet.
func NewStyleSheet ¶
func NewStyleSheet(path string) *StyleSheet
NewStyleSheet creates a new StyleSheet with the given style data.
type Text ¶
type Text struct { GraphicElement XMLName xml.Name `xml:"text"` X float64 `xml:"x,attr"` Y float64 `xml:"y,attr"` Text string `xml:",innerxml"` FontSize float64 `xml:"font-size,attr,omitempty"` FontFamily string `xml:"font-family,attr,omitempty"` FontWeight string `xml:"font-weight,attr,omitempty"` FontStyle string `xml:"font-style,attr,omitempty"` TextDecoration string `xml:"text-decoration,attr,omitempty"` }
Text creates a new Text object.
func (*Text) SetFontFamily ¶
SetFontFamily sets the font family in this text.
func (*Text) SetFontSize ¶
SetFontSize sets the size of the font used in this text.
func (*Text) SetFontStyle ¶
SetFontStyle sets the font style in this text.
func (*Text) SetTextDecoration ¶
SetTextDecoration sets the text decoration type of this text.