Documentation ¶
Index ¶
Constants ¶
View Source
const ( PrefixPadding = 10 PrefixWidth = 20 )
View Source
const ( DEFAULT_ICON_SIZE = 32 MAX_ICON_SIZE = 64 )
View Source
const ( ShapeRectangle = "rectangle" ShapeSquare = "square" ShapePage = "page" ShapeParallelogram = "parallelogram" ShapeDocument = "document" ShapeCylinder = "cylinder" ShapeQueue = "queue" ShapePackage = "package" ShapeStep = "step" ShapeCallout = "callout" ShapeStoredData = "stored_data" ShapePerson = "person" ShapeDiamond = "diamond" ShapeOval = "oval" ShapeCircle = "circle" ShapeHexagon = "hexagon" ShapeCloud = "cloud" ShapeText = "text" ShapeCode = "code" ShapeClass = "class" ShapeSQLTable = "sql_table" ShapeImage = "image" ShapeSequenceDiagram = "sequence_diagram" )
View Source
const ( NamePadding = 10 TypePadding = 20 HeaderPadding = 20 )
Variables ¶
View Source
var Arrowheads = map[string]struct{}{ string(NoArrowhead): {}, string(ArrowArrowhead): {}, string(TriangleArrowhead): {}, string(DiamondArrowhead): {}, string(FilledDiamondArrowhead): {}, }
View Source
var DSL_SHAPE_TO_SHAPE_TYPE = map[string]string{ "": shape.SQUARE_TYPE, ShapeRectangle: shape.SQUARE_TYPE, ShapeSquare: shape.REAL_SQUARE_TYPE, ShapePage: shape.PAGE_TYPE, ShapeParallelogram: shape.PARALLELOGRAM_TYPE, ShapeDocument: shape.DOCUMENT_TYPE, ShapeCylinder: shape.CYLINDER_TYPE, ShapeQueue: shape.QUEUE_TYPE, ShapePackage: shape.PACKAGE_TYPE, ShapeStep: shape.STEP_TYPE, ShapeCallout: shape.CALLOUT_TYPE, ShapeStoredData: shape.STORED_DATA_TYPE, ShapePerson: shape.PERSON_TYPE, ShapeDiamond: shape.DIAMOND_TYPE, ShapeOval: shape.OVAL_TYPE, ShapeCircle: shape.CIRCLE_TYPE, ShapeHexagon: shape.HEXAGON_TYPE, ShapeCloud: shape.CLOUD_TYPE, ShapeText: shape.TEXT_TYPE, ShapeCode: shape.CODE_TYPE, ShapeClass: shape.CLASS_TYPE, ShapeSQLTable: shape.TABLE_TYPE, ShapeImage: shape.IMAGE_TYPE, ShapeSequenceDiagram: shape.SQUARE_TYPE, }
View Source
var SHAPE_TYPE_TO_DSL_SHAPE map[string]string
View Source
var Shapes = []string{ ShapeRectangle, ShapeSquare, ShapePage, ShapeParallelogram, ShapeDocument, ShapeCylinder, ShapeQueue, ShapePackage, ShapeStep, ShapeCallout, ShapeStoredData, ShapePerson, ShapeDiamond, ShapeOval, ShapeCircle, ShapeHexagon, ShapeCloud, ShapeText, ShapeCode, ShapeClass, ShapeSQLTable, ShapeImage, ShapeSequenceDiagram, }
Functions ¶
Types ¶
type Class ¶
type Class struct { Fields []ClassField `json:"fields"` Methods []ClassMethod `json:"methods"` }
type ClassField ¶
type ClassField struct { Name string `json:"name"` Type string `json:"type"` Visibility string `json:"visibility"` }
func (ClassField) Text ¶
func (cf ClassField) Text() *MText
func (ClassField) VisibilityToken ¶ added in v0.1.3
func (cf ClassField) VisibilityToken() string
type ClassMethod ¶
type ClassMethod struct { Name string `json:"name"` Return string `json:"return"` Visibility string `json:"visibility"` }
func (ClassMethod) Text ¶
func (cm ClassMethod) Text() *MText
func (ClassMethod) VisibilityToken ¶ added in v0.1.3
func (cm ClassMethod) VisibilityToken() string
type Connection ¶
type Connection struct { ID string `json:"id"` Src string `json:"src"` SrcArrow Arrowhead `json:"srcArrow"` SrcLabel string `json:"srcLabel"` Dst string `json:"dst"` DstArrow Arrowhead `json:"dstArrow"` DstLabel string `json:"dstLabel"` Opacity float64 `json:"opacity"` StrokeDash float64 `json:"strokeDash"` StrokeWidth int `json:"strokeWidth"` Stroke string `json:"stroke"` Fill string `json:"fill,omitempty"` Text LabelPosition string `json:"labelPosition"` LabelPercentage float64 `json:"labelPercentage"` Route []*geo.Point `json:"route"` IsCurve bool `json:"isCurve,omitempty"` Animated bool `json:"animated"` Tooltip string `json:"tooltip"` Icon *url.URL `json:"icon"` ZIndex int `json:"zIndex"` }
func BaseConnection ¶
func BaseConnection() *Connection
func (Connection) GetID ¶ added in v0.1.0
func (c Connection) GetID() string
func (*Connection) GetLabelTopLeft ¶
func (c *Connection) GetLabelTopLeft() *geo.Point
func (Connection) GetZIndex ¶ added in v0.1.0
func (c Connection) GetZIndex() int
type Diagram ¶
type Diagram struct { Name string `json:"name"` Description string `json:"description,omitempty"` FontFamily *d2fonts.FontFamily `json:"fontFamily,omitempty"` Shapes []Shape `json:"shapes"` Connections []Connection `json:"connections"` }
func NewDiagram ¶
func NewDiagram() *Diagram
func (Diagram) BoundingBox ¶
type MText ¶
type SQLColumn ¶
type SQLColumn struct { Name Text `json:"name"` Type Text `json:"type"` Constraint string `json:"constraint"` Reference string `json:"reference"` }
func (SQLColumn) ConstraintAbbr ¶ added in v0.1.3
type Shape ¶
type Shape struct { ID string `json:"id"` Type string `json:"type"` Pos Point `json:"pos"` Width int `json:"width"` Height int `json:"height"` Opacity float64 `json:"opacity"` StrokeDash float64 `json:"strokeDash"` StrokeWidth int `json:"strokeWidth"` BorderRadius int `json:"borderRadius"` Fill string `json:"fill"` Stroke string `json:"stroke"` Shadow bool `json:"shadow"` ThreeDee bool `json:"3d"` Multiple bool `json:"multiple"` Tooltip string `json:"tooltip"` Link string `json:"link"` Icon *url.URL `json:"icon"` IconPosition string `json:"iconPosition"` // Whether the shape should allow shapes behind it to bleed through // Currently just used for sequence diagram groups Blend bool `json:"blend"` Class SQLTable Text LabelPosition string `json:"labelPosition,omitempty"` ZIndex int `json:"zIndex"` Level int `json:"level"` // These are used for special shapes, sql_table and class PrimaryAccentColor string `json:"primaryAccentColor,omitempty"` SecondaryAccentColor string `json:"secondaryAccentColor,omitempty"` NeutralAccentColor string `json:"neutralAccentColor,omitempty"` }
type Text ¶
type Text struct { Label string `json:"label"` FontSize int `json:"fontSize"` FontFamily string `json:"fontFamily"` Language string `json:"language"` Color string `json:"color"` Italic bool `json:"italic"` Bold bool `json:"bold"` Underline bool `json:"underline"` LabelWidth int `json:"labelWidth"` LabelHeight int `json:"labelHeight"` }
type TextDimensions ¶
func NewTextDimensions ¶
func NewTextDimensions(w, h int) *TextDimensions
Click to show internal directories.
Click to hide internal directories.