Documentation
¶
Overview ¶
Package shape provides various SVG shapes
Index ¶
- Variables
- func Move(m Movable, xd, yd int)
- type Actor
- func (a *Actor) Direction() Direction
- func (a *Actor) Edge(start xy.Position) xy.Position
- func (a *Actor) Height() int
- func (a *Actor) Position() (int, int)
- func (a *Actor) SetClass(class string)
- func (a *Actor) SetHeight(h int)
- func (a *Actor) SetX(x int)
- func (a *Actor) SetY(y int)
- func (a *Actor) String() string
- func (a *Actor) Width() int
- func (a *Actor) WriteSvg(out io.Writer) error
- type Adjuster
- type Aligner
- type Alignment
- type Arrow
- func (a *Arrow) DirQ1() bool
- func (a *Arrow) DirQ2() bool
- func (a *Arrow) DirQ3() bool
- func (a *Arrow) DirQ4() bool
- func (a *Arrow) Direction() Direction
- func (a *Arrow) Height() int
- func (a *Arrow) Position() (int, int)
- func (a *Arrow) SetClass(c string)
- func (a *Arrow) SetX(x int)
- func (a *Arrow) SetY(y int)
- func (a *Arrow) String() string
- func (a *Arrow) Width() int
- func (a *Arrow) WriteSvg(out io.Writer) error
- type Box
- type Circle
- func (c *Circle) Direction() Direction
- func (c *Circle) Edge(start xy.Position) xy.Position
- func (c *Circle) Height() int
- func (c *Circle) Position() (int, int)
- func (c *Circle) SetClass(class string)
- func (c *Circle) SetX(x int)
- func (c *Circle) SetY(y int)
- func (c *Circle) String() string
- func (c *Circle) Width() int
- func (c *Circle) WriteSvg(out io.Writer) error
- type Component
- func (c *Component) Direction() Direction
- func (c *Component) Edge(start xy.Position) xy.Position
- func (c *Component) Height() int
- func (c *Component) Position() (int, int)
- func (c *Component) SetClass(v string)
- func (c *Component) SetFont(f Font)
- func (c *Component) SetTextPad(pad Padding)
- func (c *Component) SetX(x int)
- func (c *Component) SetY(y int)
- func (c *Component) String() string
- func (c *Component) Width() int
- func (c *Component) WriteSvg(out io.Writer) error
- type Diamond
- func (d *Diamond) Direction() Direction
- func (d *Diamond) Edge(start xy.Position) xy.Position
- func (d *Diamond) Height() int
- func (d *Diamond) Position() (int, int)
- func (d *Diamond) SetClass(c string)
- func (d *Diamond) SetX(x int)
- func (d *Diamond) SetY(y int)
- func (d *Diamond) String() string
- func (d *Diamond) Width() int
- func (d *Diamond) WriteSvg(out io.Writer) error
- type Direction
- type Dot
- func (d *Dot) Direction() Direction
- func (d *Dot) Edge(start xy.Position) xy.Position
- func (d *Dot) Height() int
- func (d *Dot) Position() (int, int)
- func (d *Dot) SetClass(class string)
- func (d *Dot) SetX(x int)
- func (d *Dot) SetY(y int)
- func (d *Dot) String() string
- func (d *Dot) Width() int
- func (d *Dot) WriteSvg(out io.Writer) error
- type Edge
- type ExitDot
- func (e *ExitDot) Direction() Direction
- func (e *ExitDot) Edge(start xy.Position) xy.Position
- func (e *ExitDot) Height() int
- func (e *ExitDot) Position() (int, int)
- func (e *ExitDot) SetClass(class string)
- func (e *ExitDot) SetX(x int)
- func (e *ExitDot) SetY(y int)
- func (e *ExitDot) String() string
- func (e *ExitDot) Width() int
- func (e *ExitDot) WriteSvg(out io.Writer) error
- type Font
- type HasFont
- type HasTextPad
- type Label
- func (l *Label) Direction() Direction
- func (l *Label) Edge(start xy.Position) xy.Position
- func (l *Label) Height() int
- func (l *Label) Position() (int, int)
- func (l *Label) SetClass(c string)
- func (l *Label) SetX(x int)
- func (l *Label) SetY(y int)
- func (l *Label) String() string
- func (l *Label) Width() int
- func (l *Label) WriteSvg(w io.Writer) error
- type Line
- type Movable
- type Note
- func (n *Note) Direction() Direction
- func (n *Note) Edge(start xy.Position) xy.Position
- func (n *Note) Height() int
- func (n *Note) Position() (int, int)
- func (n *Note) SetClass(c string)
- func (n *Note) SetX(x int)
- func (n *Note) SetY(y int)
- func (n *Note) String() string
- func (n *Note) Width() int
- func (n *Note) WriteSvg(out io.Writer) error
- type Padding
- type Record
- func (r *Record) Direction() Direction
- func (r *Record) Edge(start xy.Position) xy.Position
- func (r *Record) Height() int
- func (r *Record) HideFields()
- func (r *Record) HideMethod(m string) (found bool)
- func (r *Record) HideMethods()
- func (r *Record) Position() (int, int)
- func (r *Record) SetClass(c string)
- func (r *Record) SetFont(f Font)
- func (r *Record) SetTextPad(pad Padding)
- func (r *Record) SetX(x int)
- func (r *Record) SetY(y int)
- func (r *Record) String() string
- func (r *Record) Width() int
- func (r *Record) WriteSvg(out io.Writer) error
- type Rect
- func (r *Rect) Direction() Direction
- func (r *Rect) Edge(start xy.Position) xy.Position
- func (r *Rect) Height() int
- func (r *Rect) Position() (int, int)
- func (r *Rect) SetClass(c string)
- func (r *Rect) SetFont(f Font)
- func (r *Rect) SetHeight(h int)
- func (r *Rect) SetTextPad(pad Padding)
- func (r *Rect) SetWidth(w int)
- func (r *Rect) SetX(x int)
- func (r *Rect) SetY(y int)
- func (r *Rect) String() string
- func (r *Rect) Width() int
- func (r *Rect) WriteSvg(out io.Writer) error
- type Shape
- type State
- func (r *State) Direction() Direction
- func (r *State) Edge(start xy.Position) xy.Position
- func (r *State) Height() int
- func (r *State) Position() (int, int)
- func (r *State) SetClass(c string)
- func (r *State) SetFont(f Font)
- func (r *State) SetTextPad(pad Padding)
- func (r *State) SetX(x int)
- func (r *State) SetY(y int)
- func (r *State) String() string
- func (r *State) Width() int
- func (r *State) WriteSvg(out io.Writer) error
- type Style
- type Triangle
- func (t *Triangle) Direction() Direction
- func (t *Triangle) Height() int
- func (t *Triangle) Position() (int, int)
- func (t *Triangle) SetClass(c string)
- func (t *Triangle) SetX(x int)
- func (t *Triangle) SetY(y int)
- func (t *Triangle) String() string
- func (t *Triangle) Width() int
- func (t *Triangle) WriteSvg(out io.Writer) error
Constants ¶
This section is empty.
Variables ¶
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} )
var ClassAttributes = map[string]string{
"actor": `stroke="black" stroke-width="2" fill="#ffffff"`,
"circle": `stroke="black" stroke-width="2" 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"`,
"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"`,
"span-green": `stroke="#d3d3d3" fill="#ccff99" rx="5" ry="5"`,
"span-blue": `stroke="#d3d3d3" fill="#99e6ff" rx="5" ry="5"`,
"span-red": `stroke="#d3d3d3" fill="#ff9999" rx="5" ry="5"`,
"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"`,
"caption": `font-family="Arial,Helvetica,sans-serif"`,
"diamond": `stroke="#d3d3d3" fill="#333333"`,
"decision": `stroke="#d3d3d3" fill="#ffffff"`,
}
ClassAttributes define mapping between classes and svg attributes. Setting attributes that modify size or position is not advised.
Functions ¶
Types ¶
type Actor ¶ added in v0.8.0
type Actor struct {
// contains filtered or unexported fields
}
type Adjuster ¶
type Adjuster struct {
// contains filtered or unexported fields
}
Adjuster is used to position a shape relative to other shapes or at a specific xy position.
func NewAdjuster ¶
NewAdjuster returns an adjuster with default space of 30 pixels.
func (*Adjuster) Above ¶
Above places the wrapped shape above o. Optional space to override default.
func (*Adjuster) Below ¶
Below places the wrapped shape below o. Optional space to override default.
type Aligner ¶
type Aligner struct{}
Aligner type aligns multiple shapes
func (Aligner) HAlignBottom ¶
HAlignBottom aligns shape[1:] to shape[0] bottom coordinates horizontally
func (Aligner) HAlignCenter ¶
HAlignCenter aligns shape[1:] to shape[0] center coordinates horizontally
func (Aligner) VAlignCenter ¶
VAlignCenter aligns shape[1:] to shape[0] center coordinates vertically
func (Aligner) VAlignLeft ¶
VAlignLeft aligns shape[1:] to shape[0] left coordinates vertically
func (Aligner) VAlignRight ¶
VAlignRight aligns shape[1:] to shape[0] right coordinates vertically
type Arrow ¶
type Arrow struct {
Start xy.Position
End xy.Position
Tail Shape
Head Shape
// contains filtered or unexported fields
}
func NewArrowBetween ¶
type Component ¶
type Component struct {
X, Y int
Title string
Font Font
Pad Padding
// contains filtered or unexported fields
}
func NewComponent ¶
func (*Component) Edge ¶
Edge returns intersecting position of a line starting at start and pointing to the components center.
func (*Component) SetTextPad ¶
type Diamond ¶
type Diamond struct {
// contains filtered or unexported fields
}
func NewDecision ¶
func NewDecision() *Diamond
func NewDiamond ¶
func NewDiamond() *Diamond
type ExitDot ¶
type ExitDot struct {
Radius int
// contains filtered or unexported fields
}
func NewExitDot ¶
func NewExitDot() *ExitDot
type HasTextPad ¶
type HasTextPad interface {
SetTextPad(Padding)
}
type Record ¶
type Record struct {
X, Y int
Title string
Fields []string
Methods []string
Font Font
Pad Padding
// contains filtered or unexported fields
}
func NewInterfaceRecord ¶
func NewInterfaceRecord(obj interface{}) *Record
func NewStructRecord ¶
func NewStructRecord(obj interface{}) *Record
NewStructRecord returns a record shape based on a Go struct type. Reflection is used.
func (*Record) Edge ¶
Edge returns intersecting position of a line starting at start and pointing to the records center.
func (*Record) HideFields ¶
func (r *Record) HideFields()
func (*Record) HideMethod ¶
func (*Record) HideMethods ¶
func (r *Record) HideMethods()
func (*Record) SetTextPad ¶
type Rect ¶
type Rect struct {
X, Y int
Title string
Font Font
Pad Padding
// contains filtered or unexported fields
}
func (*Rect) Edge ¶
Edge returns intersecting position of a line starting at start and pointing to the rect center.
func (*Rect) SetTextPad ¶
type Shape ¶
type Shape interface {
// Position returns the xy position of the top left corner.
Position() (x int, y int)
SetX(int)
SetY(int)
Width() int
Height() int
// Direction returns in which direction the shape is drawn.
// The direction and position is needed when aligning shapes.
Direction() Direction
SetClass(string)
WriteSvg(io.Writer) error
}
type State ¶
type State struct {
X, Y int
Title string
Font Font
Pad Padding
// contains filtered or unexported fields
}
func (*State) Edge ¶
Edge returns intersecting position of a line starting at start and pointing to the rect center.
func (*State) SetTextPad ¶
type Style ¶
type Triangle ¶
type Triangle struct {
// contains filtered or unexported fields
}
func NewTriangle ¶
func NewTriangle() *Triangle