Documentation
¶
Overview ¶
Package shape provides various SVG shapes
Index ¶
- Constants
- Variables
- func Move(m Movable, xd, yd int)
- func SetClass(class string, shapes ...Shape)
- 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) AbsAngle() int
- func (a *Arrow) Angle() int
- func (a *Arrow) CenterPosition() (x int, y int)
- 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 Cylinder
- func (c *Cylinder) Direction() Direction
- func (c *Cylinder) Edge(start xy.Position) xy.Position
- func (c *Cylinder) Height() int
- func (c *Cylinder) Position() (int, int)
- func (c *Cylinder) SetClass(class string)
- func (c *Cylinder) SetX(x int)
- func (c *Cylinder) SetY(y int)
- func (c *Cylinder) String() string
- func (c *Cylinder) Width() int
- func (c *Cylinder) WriteSVG(out io.Writer) error
- type Database
- 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 Hexagon
- func (r *Hexagon) Direction() Direction
- func (r *Hexagon) Edge(start xy.Position) xy.Position
- func (r *Hexagon) Height() int
- func (r *Hexagon) Position() (int, int)
- func (r *Hexagon) SetClass(c string)
- func (r *Hexagon) SetFont(f Font)
- func (r *Hexagon) SetHeight(h int)
- func (r *Hexagon) SetTextPad(pad Padding)
- func (r *Hexagon) SetWidth(w int)
- func (r *Hexagon) SetX(x int)
- func (r *Hexagon) SetY(y int)
- func (r *Hexagon) String() string
- func (r *Hexagon) Width() int
- func (r *Hexagon) WriteSVG(out io.Writer) error
- type Internet
- 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 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 ¶
const ( DirectionRight Direction = (1 << iota) DirectionLeft DirectionUp DirectionDown DirectionDownRight = DirectionDown | DirectionRight DirectionDownLeft = DirectionDown | DirectionLeft DirectionUpLeft = DirectionUp | DirectionLeft DirectionUpRight = DirectionUp | DirectionRight )
Variables ¶
var ( DefaultFont = draw.DefaultFont DefaultPad = draw.DefaultPad DefaultTextPad = draw.DefaultTextPad DefaultSpacing = draw.DefaultSpacing )
Functions ¶
Types ¶
type Actor ¶ added in v0.8.0
type Actor struct {
// contains filtered or unexported fields
}
type Adjuster ¶
type Adjuster struct {
Spacing int
// 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 using DefaultSpacing.
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 ¶
func (*Arrow) Angle ¶ added in v0.18.0
Angle returns value in degrees. Right = 0, down = 90, left: 180, up = -90
func (*Arrow) CenterPosition ¶ added in v0.18.0
CenterPosition
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 Cylinder ¶ added in v0.10.0
func NewCylinder ¶ added in v0.10.0
type Database ¶ added in v0.10.0
func NewDatabase ¶ added in v0.10.0
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 Hexagon ¶ added in v0.19.0
type Hexagon struct {
Title string
Font Font
Pad Padding
// contains filtered or unexported fields
}
func NewHexagon ¶ added in v0.19.0
NewHexagon with a title. Radiusmust be > 0 and is the distance from left/right corners to imaginary vertical line.
func (*Hexagon) Edge ¶ added in v0.19.0
Edge returns intersecting position of a line starting at start and pointing to the rect center.
func (*Hexagon) SetTextPad ¶ added in v0.19.0
type Internet ¶ added in v0.13.0
type Internet struct {
Circle
Title string
Font Font
Pad Padding
// contains filtered or unexported fields
}
func NewInternet ¶ added in v0.13.0
func NewInternet() *Internet
func (*Internet) SetTextPad ¶ added in v0.13.0
type Record ¶
type Record struct {
X, Y int
Title string
Fields []string
Methods []string
Font Font
Pad Padding
// contains filtered or unexported fields
}
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 Triangle ¶
type Triangle struct {
// contains filtered or unexported fields
}
func NewTriangle ¶
func NewTriangle() *Triangle