d2target

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2022 License: MPL-2.0 Imports: 12 Imported by: 23

Documentation

Index

Constants

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"
)

Variables

View Source
var SHAPE_TYPE_TO_DSL_SHAPE map[string]string

Functions

func IsShape

func IsShape(s string) bool

Types

type Arrowhead

type Arrowhead string
const (
	NoArrowhead            Arrowhead = "none"
	ArrowArrowhead         Arrowhead = "arrow"
	TriangleArrowhead      Arrowhead = "triangle"
	DiamondArrowhead       Arrowhead = "diamond"
	FilledDiamondArrowhead Arrowhead = "filled-diamond"

	// For fat arrows
	LineArrowhead Arrowhead = "line"
)

func ToArrowhead

func ToArrowhead(arrowheadType string, filled bool) Arrowhead

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

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

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"`

	Shapes      []Shape      `json:"shapes"`
	Connections []Connection `json:"connections"`
}

func NewDiagram

func NewDiagram() *Diagram

func (Diagram) BoundingBox

func (diagram Diagram) BoundingBox() (topLeft, bottomRight Point)

func (Diagram) HashID added in v0.1.0

func (diagram Diagram) HashID() (string, error)

type MText

type MText struct {
	Text     string `json:"text"`
	FontSize int    `json:"fontSize"`
	IsBold   bool   `json:"isBold"`
	IsItalic bool   `json:"isItalic"`
	Language string `json:"language"`
	Shape    string `json:"shape"`

	Dimensions TextDimensions `json:"dimensions,omitempty"`
}

func (MText) GetColor

func (text MText) GetColor(theme *d2themes.Theme, isItalic bool) string

type Point

type Point struct {
	X int `json:"x"`
	Y int `json:"y"`
}

func NewPoint

func NewPoint(x, y int) Point

type SQLColumn

type SQLColumn struct {
	Name       string `json:"name"`
	Type       string `json:"type"`
	Constraint string `json:"constraint"`
	Reference  string `json:"reference"`
}

func (SQLColumn) Text

func (c SQLColumn) Text() *MText

type SQLTable

type SQLTable struct {
	Columns []SQLColumn `json:"columns"`
}

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"`
}

func BaseShape

func BaseShape() *Shape

func (Shape) GetID added in v0.1.0

func (s Shape) GetID() string

func (*Shape) GetIconSize

func (s *Shape) GetIconSize(box *geo.Box) int

func (Shape) GetZIndex added in v0.1.0

func (s Shape) GetZIndex() int

func (*Shape) SetType

func (s *Shape) SetType(t string)

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

type TextDimensions struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

func NewTextDimensions

func NewTextDimensions(w, h int) *TextDimensions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL