Documentation
¶
Overview ¶
Package draw provides SVG writing features.
s := NewSVG() s.WriteSVG(os.Stdout) <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100" height="100" font-family="Arial, Helvetica, sans-serif"></svg>
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultFont = Font{Height: 12, LineHeight: 16, /* contains filtered or unexported fields */} DefaultTextPad = Padding{Left: 6, Top: 4, Bottom: 6, Right: 10} DefaultPad = Padding{Left: 10, Top: 2, Bottom: 7, Right: 10} DefaultSpacing = 30 // between elements )
View Source
var DefaultClassAttributes = ClassAttributes{
"actor": `stroke="black" stroke-width="2" fill="#ffffff"`,
"circle": `stroke="#d3d3d3" stroke-width="2" fill="#ffffff"`,
"cylinder": `stroke="#d3d3d3" stroke-width="1" fill="#ffffff"`,
"database": `stroke="#d3d3d3" stroke-width="1" fill="#ffffff"`,
"dot": `stroke="black"`,
"exit": `stroke="black" stroke-width="2" fill="#ffffff"`,
"exit-dot": `stroke="black"`,
"note": `font-family="Arial,Helvetica,sans-serif"`,
"note-box": `stroke="#d3d3d3" fill="#ffffcc"`,
"highlight": `stroke="red"`,
"highlight-head": `stroke="red" fill="#ffffff"`,
"implements-arrow": `stroke="black" stroke-dasharray="5,5,5"`,
"implements-arrow-head": `stroke="black" fill="#ffffff"`,
"arrow": `stroke="black"`,
"arrow-head": `stroke="black" fill="#ffffff"`,
"arrow-tail": `stroke="black" fill="#777777"`,
"activity-arrow": `stroke="black"`,
"activity-arrow-head": `stroke="black" fill="#ffffff"`,
"activity-arrow-tail": `stroke="black" fill="#777777"`,
"compose-arrow": `stroke="black"`,
"compose-arrow-head": `stroke="black" fill="#ffffff"`,
"compose-arrow-tail": `stroke="black" fill="#777777"`,
"aggregate-arrow": `stroke="black"`,
"aggregate-arrow-head": `stroke="black" fill="#ffffff"`,
"aggregate-arrow-tail": `stroke="black" fill="#ffffff"`,
"external": `stroke="#d3d3d3" fill="#e2e2e2"`,
"internet": `stroke="#d3d3d3" fill="#e2e2e2"`,
"internet-title": `font-family="Arial,Helvetica,sans-serif"`,
"line": `stroke="black"`,
"triangle": `stroke="black"`,
"column-line": `stroke="#d3d3d3"`,
"record": `stroke="#d3d3d3" fill="#ffffff"`,
"record-line": `stroke="#d3d3d3"`,
"record-title": `font-family="Arial,Helvetica,sans-serif"`,
"rect": `stroke="#d3d3d3" fill="#ffffff"`,
"rect-title": `font-family="Arial,Helvetica,sans-serif"`,
"root": `font-family="Arial,Helvetica,sans-serif"`,
"span-green": `stroke="#d3d3d3" fill="#ccff99" rx="5" ry="5"`,
"span-green-title": `font-family="Arial,Helvetica,sans-serif"`,
"span-blue": `stroke="#d3d3d3" fill="#99e6ff" rx="5" ry="5"`,
"span-blue-title": `font-family="Arial,Helvetica,sans-serif"`,
"span-red": `stroke="#d3d3d3" fill="#ff9999" rx="5" ry="5"`,
"span-red-title": `font-family="Arial,Helvetica,sans-serif"`,
"state-title": `font-family="Arial,Helvetica,sans-serif"`,
"state": `stroke="#d3d3d3" fill="#ffffff" rx="10" ry="10"`,
"component": `stroke="#d3d3d3" fill="#ffffff"`,
"component-title": `font-family="Arial,Helvetica,sans-serif"`,
"field": `font-family="Arial,Helvetica,sans-serif"`,
"method": `font-family="Arial,Helvetica,sans-serif"`,
"record-label": `font-family="Arial,Helvetica,sans-serif"`,
"label": `font-family="Arial,Helvetica,sans-serif"`,
"weekend": `font-family="Arial,Helvetica,sans-serif" fill="#f3f3f3"`,
"weekend-title": `font-family="Arial,Helvetica,sans-serif"`,
"caption": `font-family="Arial,Helvetica,sans-serif"`,
"diamond": `stroke="#d3d3d3" fill="#333333"`,
"decision": `stroke="#d3d3d3" fill="#ffffff"`,
}
Functions ¶
func Inline ¶ added in v0.15.0
Inline me returns SVG with inlined style.
Example ¶
package main
import (
"fmt"
"github.com/gregoryv/draw/design"
)
func main() {
d := design.NewSequenceDiagram()
fmt.Println(d.Inline())
}
Output: <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" font-family="Arial,Helvetica,sans-serif" width="1" height="1"></svg>
Types ¶
type ClassAttributes ¶ added in v0.13.0
ClassAttributes define mapping between classes and svg attributes. Setting attributes that modify size or position is not advised.
func (ClassAttributes) CSS ¶ added in v0.15.0
func (me ClassAttributes) CSS() string
CSS returns cascading rules for embedding in html
type SVG ¶ added in v0.12.0
type SVG struct {
Content []SVGWriter
// contains filtered or unexported fields
}
type Style ¶ added in v0.13.0
type TagWriter ¶
type TagWriter struct {
// contains filtered or unexported fields
}
func NewTagWriter ¶
NewTagWriter returns a writer nexus. The referenced error is set by all methods if an error occurs.
Example ¶
w, err := NewTagWriter(os.Stdout)
w.Print("hello")
*err = fmt.Errorf("stop subsequent calls")
w.Printf("cruel %s", "world")
Output: hello
func (*TagWriter) Print ¶
func (t *TagWriter) Print(args ...interface{})
Print prints arguments using the underlying writer. Does nothing if TagWriter has failed.
Click to show internal directories.
Click to hide internal directories.