Documentation ¶
Index ¶
- Constants
- Variables
- func GetIconSize(box *geo.Box, position string) int
- func IsShape(s string) bool
- type Arrowhead
- type Class
- type ClassField
- type ClassMethod
- type Connection
- type Diagram
- func (diagram Diagram) BoundingBox() (topLeft, bottomRight Point)
- func (diagram Diagram) Bytes() ([]byte, error)
- func (diagram Diagram) GetCorpus() string
- func (diagram Diagram) GetNestedCorpus() string
- func (diagram Diagram) HasShape(condition func(Shape) bool) bool
- func (diagram Diagram) HashID() (string, error)
- func (diagram Diagram) NestedBoundingBox() (topLeft, bottomRight Point)
- type MText
- type Point
- type SQLColumn
- type SQLTable
- type Shape
- type Text
- type TextDimensions
Constants ¶
View Source
const ( PrefixPadding = 10 PrefixWidth = 20 CenterPadding = 50 // 10px of padding top and bottom so text doesn't look squished VerticalPadding = 20 )
View Source
const ( DEFAULT_ICON_SIZE = 32 MAX_ICON_SIZE = 64 THREE_DEE_OFFSET = 15 MULTIPLE_OFFSET = 10 INNER_BORDER_OFFSET = 5 BG_COLOR = color.N7 FG_COLOR = color.N1 )
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 = 10 // Setting table font size sets it for columns // The header needs to be a little larger for visual hierarchy HeaderFontAdd = 4 )
Variables ¶
View Source
var Arrowheads = map[string]struct{}{ string(NoArrowhead): {}, string(ArrowArrowhead): {}, string(TriangleArrowhead): {}, string(DiamondArrowhead): {}, string(FilledDiamondArrowhead): {}, string(CircleArrowhead): {}, string(FilledCircleArrowhead): {}, string(CfOne): {}, string(CfMany): {}, string(CfOneRequired): {}, string(CfManyRequired): {}, }
View Source
var BorderOffset = geo.NewVector(5, 5)
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 Arrowhead ¶
type Arrowhead string
const ( NoArrowhead Arrowhead = "none" ArrowArrowhead Arrowhead = "arrow" TriangleArrowhead Arrowhead = "triangle" DiamondArrowhead Arrowhead = "diamond" FilledDiamondArrowhead Arrowhead = "filled-diamond" CircleArrowhead Arrowhead = "circle" FilledCircleArrowhead Arrowhead = "filled-circle" // For fat arrows LineArrowhead Arrowhead = "line" // Crows feet notation CfOne Arrowhead = "cf-one" CfMany Arrowhead = "cf-many" CfOneRequired Arrowhead = "cf-one-required" CfManyRequired Arrowhead = "cf-many-required" )
func ToArrowhead ¶
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(fontSize int) *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(fontSize int) *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"` BorderRadius float64 `json:"borderRadius,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) CSSStyle ¶ added in v0.1.6
func (c Connection) CSSStyle() string
func (Connection) GetFontColor ¶ added in v0.2.2
func (c Connection) GetFontColor() string
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"` // See docs on the same field in d2graph to understand what it means. IsFolderOnly bool `json:"isFolderOnly"` Description string `json:"description,omitempty"` FontFamily *d2fonts.FontFamily `json:"fontFamily,omitempty"` Shapes []Shape `json:"shapes"` Connections []Connection `json:"connections"` Root Shape `json:"root"` Layers []*Diagram `json:"layers,omitempty"` Scenarios []*Diagram `json:"scenarios,omitempty"` Steps []*Diagram `json:"steps,omitempty"` }
func NewDiagram ¶
func NewDiagram() *Diagram
func (Diagram) BoundingBox ¶
func (Diagram) GetNestedCorpus ¶ added in v0.3.0
func (Diagram) NestedBoundingBox ¶ added in v0.3.0
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"` FillPattern string `json:"fillPattern,omitempty"` Stroke string `json:"stroke"` Shadow bool `json:"shadow"` ThreeDee bool `json:"3d"` Multiple bool `json:"multiple"` DoubleBorder bool `json:"double-border"` 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"` }
func (Shape) GetFontColor ¶ added in v0.2.2
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"` LabelFill string `json:"labelFill,omitempty"` }
type TextDimensions ¶
func NewTextDimensions ¶
func NewTextDimensions(w, h int) *TextDimensions
Click to show internal directories.
Click to hide internal directories.