Documentation
¶
Index ¶
- Constants
- Variables
- func CalculateTooltipPosition(shapeX, shapeY, shapeWidth, shapeHeight float64, ...) (x, y float64)
- func CanonicalSQLConstraint(s string) string
- func CanonicalShape(s string) string
- func ConnectionCrossings(connections []Connection, shapes map[string]Shape, sketch bool, ...) [][]ConnectionGap
- func DeprecatedSQLConstraint(s string) (canonical string, ok bool)
- func DeprecatedShapeName(s string) (canonical string, ok bool)
- func GetIconSize(box *geo.Box, position string) int
- func IsShape(s string) bool
- func LabelReadingMS(text string, markdown bool) int
- func NumberedCaption(number int, label string) string
- func SharedShaftGroups(connections []Connection, shapes map[string]Shape, eligible func(int) bool) map[int][]int
- func SharedShapeBorders(shapes []Shape, eligible func(int) bool, covering []*Connection) map[string]ShapeBorderPlan
- func StrokeWidthExtent(width int, offset float64) int
- func TweenFrameCount(durationMS int) int
- func ValidMotionOffset(p *geo.Point) bool
- func ValidStrokeWidthOffset(width int, offset float64) bool
- func ValidateAnimateProgressColor(paint string) error
- func ValidateIconLoopDuration(board *Diagram, loopMS int) error
- func ValidateRenderTarget(root *Diagram) error
- type Annotation
- type AnnotationMark
- type Arrowhead
- type BorderCut
- type Class
- type ClassField
- type ClassMethod
- type Config
- type Connection
- func (c Connection) ArrowheadAdjustments(shapes map[string]Shape) (src, dst *geo.Point)
- func (c Connection) ArrowheadAdjustmentsForWidths(srcWidth, dstWidth float64) (src, dst *geo.Point)
- func (c Connection) CSSStyle() string
- func (c *Connection) EndpointInsets(srcWidth, dstWidth float64) [2]float64
- func (connection *Connection) GetArrowheadLabelPosition(isDst bool) *geo.Point
- func (c Connection) GetFontColor() string
- func (c Connection) GetID() string
- func (c *Connection) GetIconPosition() *geo.Point
- func (c *Connection) GetLabelTopLeft() *geo.Point
- func (c Connection) GetZIndex() int
- func (c Connection) GradientBounds() *geo.Box
- func (c Connection) HasLabel() bool
- func (c *Connection) HasStaticIcon() bool
- func (c *Connection) HasVisibleIconStream() bool
- func (c *Connection) IconMotionPath(srcWidth, dstWidth float64) IconMotionPath
- func (c *Connection) IconPolygon(center geo.Point) []geo.Point
- func (c *Connection) IconSize() int
- func (c *Connection) LabelFillBounds(x, y float64) (left, top, width, height float64)
- func (c *Connection) LabelMasksStroke(paintVisible func(string) bool) bool
- func (c *Connection) MovingIconFootprint() MovingIconFootprint
- func (c Connection) PathCommands(srcAdj, dstAdj *geo.Point) iter.Seq[ConnectionPathCommand]
- func (c Connection) RenderedStrokeWidth() float64
- func (c *Connection) ResolveGradientAngles()
- func (c Connection) RichNumber() string
- func (connection *Connection) ValidateIconMotion(path string) error
- type ConnectionGap
- type ConnectionIconAnimation
- type ConnectionIconSchedule
- type ConnectionIconTrip
- type ConnectionPathCommand
- type Diagram
- func (diagram *Diagram) AnnotationMarks() []AnnotationMark
- func (diagram Diagram) BoundingBox() (topLeft, bottomRight Point)
- func (diagram Diagram) Bytes() ([]byte, error)
- func (diagram *Diagram) CaptionBox(inkTL, inkBR Point) *geo.Box
- func (d *Diagram) ConnectionIconPeriods() iter.Seq2[*Connection, float64]
- func (d *Diagram) ConnectionIconRoutes() iter.Seq2[int, IconMotionPath]
- func (d *Diagram) GetBoard(boardPath []string) *Diagram
- func (diagram Diagram) GetCorpus() string
- func (diagram Diagram) GetNestedCorpus() string
- func (d *Diagram) HasSequenceActivations() bool
- func (diagram Diagram) HasShape(condition func(Shape) bool) bool
- func (diagram Diagram) HashID(salt *string) (string, error)
- func (diagram Diagram) InkBoundingBox() (topLeft, bottomRight Point)
- func (diagram Diagram) NestedBoundingBox() (topLeft, bottomRight Point)
- func (diagram *Diagram) ReadingMS() int
- func (d *Diagram) ResolveBoard(path []string) (*Diagram, []string)
- func (d *Diagram) ScenarioPredecessors() map[*Diagram]*Diagram
- func (d *Diagram) SequenceLifelineLabelGaps(sketch bool, paintVisible func(string) bool) map[int][]SequenceLabelGap
- func (d *Diagram) TweenFrameEndMS(i int) int
- func (d *Diagram) WithIconLabelInsets() *Diagram
- type IconMotionPath
- type ImageFit
- type ImagePosition
- type Legend
- type MText
- type MarkdownStrikeTransition
- type MotionBox
- type MotionClip
- type MotionLabel
- type MovingIconFootprint
- type Point
- type RectBorderRegion
- type SQLColumn
- type SQLPrimaryKeyLayout
- type SQLRowReveal
- type SQLTable
- type SequenceLabelGap
- type Shape
- func (s Shape) AppendixLinkText() string
- func (s Shape) CSSStyle() string
- func (s *Shape) CanDrawOutline() bool
- func (s *Shape) CanShadeSketchFill() bool
- func (s *Shape) CodeBlockBounds() *geo.Box
- func (s *Shape) DrawingOutline() bool
- func (s *Shape) DrawnOutline() []geo.Point
- func (s *Shape) Geometry() shape.Shape
- func (s Shape) GetFontColor() string
- func (s Shape) GetID() string
- func (s Shape) GetZIndex() int
- func (s *Shape) IconBounds(outline shape.Shape) *geo.Box
- func (s *Shape) IsSequenceHeader() bool
- func (s *Shape) LabelBox(position label.Position, outline shape.Shape) *geo.Box
- func (s *Shape) LabelFillBox(text *geo.Point) geo.Box
- func (s *Shape) LabelTopLeft(position label.Position, box *geo.Box) *geo.Point
- func (s *Shape) OuterLabelBox(box *geo.Box) *geo.Box
- func (s *Shape) OverlaySequenceCaption(shapes []Shape, sketch bool) bool
- func (s *Shape) RenderedPosition() geo.Point
- func (s Shape) RenderedStrokeWidth() float64
- func (s *Shape) ResolveGradientAngles()
- func (s *Shape) ResolveSequenceFrameFill()
- func (s *Shape) SQLRowDivider(index int, y, radius float64) (bottom, inset float64, last bool)
- func (s *Shape) SQLRowHeight() float64
- func (s *Shape) SQLRowVisibleHeight(top, height float64) float64
- func (s *Shape) SetType(t string)
- type ShapeBorder
- type ShapeBorderPlan
- type ShapeOption
- type ShapeOptionValues
- type SketchFillTransition
- type Text
- type TextDimensions
- type ThemeOverrides
- type TraceEndpoint
Constants ¶
const ( AnnotationCircle = "circle" AnnotationBox = "box" AnnotationUnderline = "underline" AnnotationBrace = "brace" AnnotationCross = "cross" AnnotationTrace = "trace" AnnotationHighlight = "highlight" AnnotationArrow = "arrow" AnnotationLasso = "lasso" )
The marks an annotation can draw. A trace follows a connection; the others surround a shape, and a cross can strike out either.
const ( // DefaultAnnotationStroke is a pen color that stays legible over both // light and dark themes, the way a marker stands apart from the page. DefaultAnnotationStroke = "#E8590C" AnnotationStrokeWidth = 3 AnnotationTraceOpacity = 0.38 // DefaultHighlightStroke is the yellow of a highlighter. A label reads // through it at AnnotationHighlightOpacity. DefaultHighlightStroke = "#FFD43B" AnnotationHighlightOpacity = 0.45 // CaptionGap separates a board's caption from the lowest ink above it. CaptionGap = 28 // AnnotationFontSize is the size of the note beside a mark, and // CaptionFontSize the size of a board's caption. AnnotationFontSize = 16 CaptionFontSize = 24 )
const ( PrefixPadding = 10 PrefixWidth = 20 CenterPadding = 50 // 10px of padding top and bottom so text doesn't look squished VerticalPadding = 20 )
const ( DEFAULT_SHAPE_STROKE_WIDTH = 2 DEFAULT_ICON_SIZE = 32 MAX_ICON_SIZE = 64 SHADOW_SIZE_X = 3 SHADOW_SIZE_Y = 5 THREE_DEE_OFFSET = 15 MULTIPLE_OFFSET = 10 INNER_BORDER_OFFSET = 5 BG_COLOR = color.N7 FG_COLOR = color.N1 MIN_ARROWHEAD_STROKE_WIDTH = 2 ARROWHEAD_PADDING = 2. CONNECTION_ICON_LABEL_GAP = 8 )
const ( MaxTweenDurationMS = 600_000 TweenFPS = 60 // Keep the full sampling rate for transitions up to 4.8 seconds. MaxTweenFrames = 288 )
Limits shared by D2 source compilation and callers supplying sampled targets.
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" ShapeC4Person = "c4-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" ShapeSequenceDiagramV2 = "sequence-diagram" ShapeSequenceDiagramActorGroup = "actor-group" ShapeSequenceDiagramActor = "actor" ShapeSequenceDiagramEdgeGroup = "edge-group" ShapeSequenceDiagramCheckpoint = "sequence-diagram-checkpoint" ShapeHierarchy = "hierarchy" )
const ( NamePadding = 10 TypePadding = 20 ConstraintPadding = 20 HeaderPadding = 10 // Setting table font size sets it for columns // The header needs to be a little larger for visual hierarchy HeaderFontAdd = 4 )
const ( SQLConstraintPrimaryKey = "primary-key" SQLConstraintForeignKey = "foreign-key" SQLConstraintUnique = "unique" )
SQL column constraints that render as abbreviations. Other constraints render as written.
const ConnectionIconTriangle = "triangle"
const IconMotionSpeed = 180.0
IconMotionSpeed is measured in diagram coordinates per second, before export scaling.
const MaxMovingIconsPerConnection = 64
const (
// MaxRenderTargetBoards includes authored boards and their tween samples.
MaxRenderTargetBoards = 16_384
)
const SequenceActivationZIndex = 4
SequenceActivationZIndex is the layer for activation bars. Frame captions are painted immediately above it and below the messages.
const SequenceNumberGap = 4
SequenceNumberGap separates the ordinal from a rich message label, in pixels.
Variables ¶
var Arrowheads = map[string]struct{}{ string(NoArrowhead): {}, string(ArrowArrowhead): {}, string(TriangleArrowhead): {}, string(DiamondArrowhead): {}, string(CircleArrowhead): {}, string(BoxArrowhead): {}, string(CfOne): {}, string(CfMany): {}, string(CfOneRequired): {}, string(CfManyRequired): {}, string(CrossArrowhead): {}, }
valid values for arrowhead.shape
var BorderOffset = geo.NewVector(5, 5)
var ConnectionIconShapes = []string{ShapeCircle, ShapeSquare, ConnectionIconTriangle, ShapeDiamond}
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, ShapeC4Person: shape.C4_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, ShapeSequenceDiagramV2: shape.SQUARE_TYPE, ShapeSequenceDiagramCheckpoint: shape.SQUARE_TYPE, ShapeSequenceDiagramEdgeGroup: shape.SQUARE_TYPE, ShapeSequenceDiagramActorGroup: shape.SQUARE_TYPE, ShapeSequenceDiagramActor: shape.SQUARE_TYPE, ShapeHierarchy: shape.SQUARE_TYPE, }
var SHAPE_TYPE_TO_DSL_SHAPE map[string]string
var Shapes = []string{ ShapeRectangle, ShapeSquare, ShapePage, ShapeParallelogram, ShapeDocument, ShapeCylinder, ShapeQueue, ShapePackage, ShapeStep, ShapeCallout, ShapeStoredData, ShapePerson, ShapeC4Person, ShapeDiamond, ShapeOval, ShapeCircle, ShapeHexagon, ShapeCloud, ShapeText, ShapeCode, ShapeClass, ShapeSQLTable, ShapeImage, ShapeSequenceDiagram, ShapeSequenceDiagramV2, ShapeSequenceDiagramCheckpoint, ShapeSequenceDiagramEdgeGroup, ShapeSequenceDiagramActorGroup, ShapeSequenceDiagramActor, ShapeHierarchy, }
Functions ¶
func CanonicalSQLConstraint ¶ added in v0.10.1
CanonicalSQLConstraint returns the name D2 uses for the constraint spelled s, folding deprecated underscore spellings. Constraints are free text, so any other value, including other capitalizations, is returned as written.
func CanonicalShape ¶ added in v0.10.1
CanonicalShape returns the name D2 uses for the shape spelled s, folding case and deprecated underscore spellings. Unknown names are only lowercased.
func ConnectionCrossings ¶ added in v0.10.0
func ConnectionCrossings(connections []Connection, shapes map[string]Shape, sketch bool, strokeVisible func(string) bool) [][]ConnectionGap
ConnectionCrossings returns one list for each input connection in original diagram order. A higher z-index passes in front; ties use stable paint order.
func DeprecatedSQLConstraint ¶ added in v0.10.1
DeprecatedSQLConstraint reports the hyphenated name of a deprecated underscore spelling of a constraint, such as "primary-key" for "primary_key".
func DeprecatedShapeName ¶ added in v0.10.1
DeprecatedShapeName reports the hyphenated name of a deprecated underscore spelling of a shape, such as "sql-table" for "sql_table".
func LabelReadingMS ¶ added in v0.10.1
LabelReadingMS applies the animation's reading pace to a single label.
func NumberedCaption ¶ added in v0.10.1
NumberedCaption formats an ordinal for plain text renderers without changing the authored label.
func SharedShaftGroups ¶ added in v0.10.1
func SharedShaftGroups(connections []Connection, shapes map[string]Shape, eligible func(int) bool) map[int][]int
SharedShaftGroups finds overlapping connections within each run of compatible paint at a z-index. Map keys are the first paint position of each group. Callers must validate the target and may veto individual effects or palettes.
func SharedShapeBorders ¶ added in v0.10.1
func SharedShapeBorders(shapes []Shape, eligible func(int) bool, covering []*Connection) map[string]ShapeBorderPlan
SharedShapeBorders returns the residual stroke for each affected shape. A present, empty path means a later painter owns the whole outline. Fills and other decorations stay with their original shape. Covering connections must have been checked for renderer-specific masks and paint effects. The caller must validate the render target first.
func StrokeWidthExtent ¶ added in v0.10.0
StrokeWidthExtent rounds a validated stroke outward for integer layout bounds.
func TweenFrameCount ¶ added in v0.10.0
TweenFrameCount rounds up so a positive transition always gets a sample.
func ValidMotionOffset ¶ added in v0.10.1
ValidMotionOffset reports whether a sampled translation fits inside one layout unit on each axis. A nil offset uses the integer layout position.
func ValidStrokeWidthOffset ¶ added in v0.10.0
ValidStrokeWidthOffset checks that the fractional part of an animated stroke preserves a nonnegative width and an outward bound representable as an int.
func ValidateAnimateProgressColor ¶ added in v0.10.1
ValidateAnimateProgressColor permits an unset override or a solid, opaque color with the same meaning in SVG and raster exports.
func ValidateIconLoopDuration ¶ added in v0.10.1
ValidateIconLoopDuration checks authored departure periods against the entire repeating film. Individual board holds can be shorter than a departure period.
func ValidateRenderTarget ¶ added in v0.10.0
ValidateRenderTarget checks the invariants required by renderers which consume Diagram JSON directly. Compiler output already satisfies these invariants, but callers of the public render API can construct a Diagram without going through the compiler.
Types ¶
type Annotation ¶ added in v0.10.1
type Annotation struct {
Label string `json:"label,omitempty"`
LabelWidth int `json:"labelWidth,omitempty"`
LabelHeight int `json:"labelHeight,omitempty"`
// Shape is the resolved mark. A caption has none.
Shape string `json:"shape,omitempty"`
// Position is an authored side for the note. Empty picks the side with
// the most room on each board.
Position string `json:"position,omitempty"`
Stroke string `json:"stroke,omitempty"`
// FontColor is an authored color for the text alone. Empty, the note is
// written in the pen.
FontColor string `json:"fontColor,omitempty"`
// Members are the IDs of the other shapes a lasso holds, besides the one
// that carries it.
Members []string `json:"members,omitempty"`
// Cues are the IDs of the shapes a caption names, in reading order.
Cues []string `json:"cues,omitempty"`
// Anchor pins a caption's top center. Animations set it so that every
// frame shares one lower third. Unset, the caption follows its own board.
Anchor *Point `json:"anchor,omitempty"`
// Drawn is the part of the mark a sampled frame shows, as fractions of
// its stroke length. Nil is the whole mark.
Drawn *[2]float64 `json:"drawn,omitempty"`
}
Annotation is a mark and a short Markdown note drawn over a shape or a connection for the length of its board. On a diagram's root it is the board's caption. It takes no part in layout.
func (*Annotation) CaptionBox ¶ added in v0.10.1
func (a *Annotation) CaptionBox(inkTL, inkBR Point) *geo.Box
CaptionBox places the caption under the board's ink extent, or at its pinned Anchor when set.
func (*Annotation) CaptionOpacity ¶ added in v0.10.1
func (a *Annotation) CaptionOpacity() float64
CaptionOpacity cross-fades one board's caption into the next.
func (*Annotation) CaptionPaint ¶ added in v0.10.1
func (a *Annotation) CaptionPaint(text string) string
CaptionPaint returns the paint for a caption's text. A caption is set in the board's own text color unless its author gave it a color or a pen.
func (*Annotation) GetStroke ¶ added in v0.10.1
func (a *Annotation) GetStroke() string
GetStroke returns the paint of the mark: the authored pen, or the default for the kind of mark it is.
type AnnotationMark ¶ added in v0.10.1
type AnnotationMark struct {
// ID names the mark after its target, for element IDs.
ID string
Strokes [][]geo.Point
Paint string
Width float64
Opacity float64
// Flat ends the strokes square, as a highlighter does. Other marks end round.
Flat bool
Label string
// NotePaint is the paint of the note, which can differ from the mark's.
// The note is set in the board's font, which is the font it was measured in.
NotePaint string
LabelBox *geo.Box
LabelOpacity float64
}
AnnotationMark is one annotation resolved to ink for a board: polylines in diagram coordinates and, when it has a note, where the note goes.
func (AnnotationMark) Bounds ¶ added in v0.10.1
func (m AnnotationMark) Bounds() (x1, y1, x2, y2 float64)
Bounds returns the extent of the ink, including half its stroke width. A mark with no ink has no extent.
type Arrowhead ¶
type Arrowhead string
const ( NoArrowhead Arrowhead = "none" ArrowArrowhead Arrowhead = "arrow" UnfilledTriangleArrowhead Arrowhead = "unfilled-triangle" TriangleArrowhead Arrowhead = "triangle" DiamondArrowhead Arrowhead = "diamond" FilledDiamondArrowhead Arrowhead = "filled-diamond" CircleArrowhead Arrowhead = "circle" FilledCircleArrowhead Arrowhead = "filled-circle" CrossArrowhead Arrowhead = "cross" BoxArrowhead Arrowhead = "box" FilledBoxArrowhead Arrowhead = "filled-box" // 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" DefaultArrowhead Arrowhead = TriangleArrowhead )
func ToArrowhead ¶
func (Arrowhead) Dimensions ¶
type BorderCut ¶ added in v0.10.1
type BorderCut struct {
From, To geo.Point
Curved bool // A whole clockwise corner of a rounded rectangle.
}
BorderCut is a covered stretch of the original rectangle outline.
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"`
Underline bool `json:"underline"`
}
func (ClassField) Text ¶
func (cf ClassField) Text(fontSize int) *MText
func (ClassField) VisibilityToken ¶
func (cf ClassField) VisibilityToken() string
type ClassMethod ¶
type ClassMethod struct {
Name string `json:"name"`
Return string `json:"return"`
Visibility string `json:"visibility"`
Underline bool `json:"underline"`
}
func (ClassMethod) Text ¶
func (cm ClassMethod) Text(fontSize int) *MText
func (ClassMethod) VisibilityToken ¶
func (cm ClassMethod) VisibilityToken() string
type Config ¶
type Config struct {
AnimateProgress *bool `json:"animateProgress,omitempty"`
AnimateProgressColor string `json:"animateProgressColor,omitempty"`
AnimateInterval *int64 `json:"animateInterval,omitempty"` // Milliseconds per board.
AnimateDuration *int64 `json:"animateDuration,omitempty"` // Milliseconds for step transitions and linked layer zooms.
Scale *float64 `json:"scale,omitempty"`
ForceAppendix *bool `json:"forceAppendix,omitempty"`
Sketch *bool `json:"sketch"`
ThemeID *int64 `json:"themeID"`
DarkThemeID *int64 `json:"darkThemeID"`
Pad *int64 `json:"pad"`
Center *bool `json:"center"`
LayoutEngine *string `json:"layoutEngine"`
ThemeOverrides *ThemeOverrides `json:"themeOverrides,omitempty"`
DarkThemeOverrides *ThemeOverrides `json:"darkThemeOverrides,omitempty"`
// Data is a data structure for holding user-defined data
// useful for layout engines that allow users to configure within source code
Data map[string]interface{} `json:"data,omitempty"`
}
func (*Config) ResolveAnimateInterval ¶ added in v0.10.0
ResolveAnimateInterval returns the explicit render setting, falling back to the source configuration. A nil result leaves the output format's default intact.
func (*Config) ResolveAnimateProgress ¶ added in v0.10.1
ResolveAnimateProgress defaults to showing progress when a positive playback interval was configured. A format's automatic interval does not count.
func (*Config) ResolveAnimateProgressColor ¶ added in v0.10.1
ResolveAnimateProgressColor gives a nonempty render setting precedence over the source.
func (*Config) ResolveForceAppendix ¶ added in v0.10.0
ResolveForceAppendix preserves an explicit false when the source enables footnotes.
type Connection ¶
type Connection struct {
ID string `json:"id"`
SequenceNumber int `json:"sequenceNumber,omitempty"`
SequenceNumberWidth int `json:"sequenceNumberWidth,omitempty"`
SequenceRole string `json:"sequenceRole,omitempty"`
MotionClip *MotionClip `json:"motionClip,omitempty"`
MotionLabel *MotionLabel `json:"motionLabel,omitempty"`
// MotionTip marks the free end of a partially drawn connection.
MotionTip TraceEndpoint `json:"motionTip,omitempty"`
// MotionDashOffset pins a backward trace’s dashes to its stationary end.
MotionDashOffset float64 `json:"motionDashOffset,omitempty"`
Classes []string `json:"classes,omitempty"`
Src string `json:"src"`
SrcArrow Arrowhead `json:"srcArrow"`
SrcLabel *Text `json:"srcLabel,omitempty"`
Dst string `json:"dst"`
DstArrow Arrowhead `json:"dstArrow"`
DstLabel *Text `json:"dstLabel,omitempty"`
Opacity float64 `json:"opacity"`
StrokeDash float64 `json:"strokeDash"`
StrokeWidth int `json:"strokeWidth"`
// Tween frames retain the subpixel difference from the integer layout width.
StrokeWidthOffset float64 `json:"strokeWidthOffset,omitempty"`
Stroke string `json:"stroke"`
Fill string `json:"fill,omitempty"`
BorderRadius float64 `json:"borderRadius,omitempty"`
Text
LabelPosition string `json:"labelPosition"`
LabelPercentage float64 `json:"labelPercentage"`
Link string `json:"link"`
PrettyLink string `json:"prettyLink,omitempty"`
Route []*geo.Point `json:"route"`
IsCurve bool `json:"isCurve,omitempty"`
Animated bool `json:"animated"`
Tooltip string `json:"tooltip"`
Icon *url.URL `json:"icon"`
IconPosition string `json:"iconPosition,omitempty"`
IconBorderRadius float64 `json:"iconBorderRadius,omitempty"`
IconShape string `json:"iconShape,omitempty"`
IconAnimation *ConnectionIconAnimation `json:"iconAnimation,omitempty"`
// IconLabelInsets is derived from the current board's endpoint stroke widths.
IconLabelInsets [2]float64 `json:"-"`
// IconPositions holds sampled centers. Nil leaves playback to the renderer.
IconPositions []geo.Point `json:"-"`
IconSchedule *ConnectionIconSchedule `json:"-"`
// Annotation is drawn over the connection without taking part in layout.
Annotation *Annotation `json:"annotation,omitempty"`
// LeavingAnnotation is the previous board's annotation while a sampled
// frame erases it.
LeavingAnnotation *Annotation `json:"leavingAnnotation,omitempty"`
ZIndex int `json:"zIndex"`
}
func BaseConnection ¶
func BaseConnection() *Connection
func SharedBorderConnections ¶ added in v0.10.1
func SharedBorderConnections(connections []Connection, shapes []Shape, eligibleEdge, eligibleShape func(int) bool) (covering []*Connection, borderOwned map[int]bool)
SharedBorderConnections assigns matching paint between the last shapes and first connections at each z-index. A short shaft wholly inside a continuous rectangle border keeps its markers and hit target, but needs no visible stroke. Other compatible shafts can own part of the underlying outlines. The optional predicates exclude renderer-specific effects. Callers must validate the render target before passing routes and shapes to the planner.
func (Connection) ArrowheadAdjustments ¶ added in v0.10.0
func (c Connection) ArrowheadAdjustments(shapes map[string]Shape) (src, dst *geo.Point)
ArrowheadAdjustments inset the centerline's endpoints for the strokes and markers.
func (Connection) ArrowheadAdjustmentsForWidths ¶ added in v0.10.0
func (c Connection) ArrowheadAdjustmentsForWidths(srcWidth, dstWidth float64) (src, dst *geo.Point)
ArrowheadAdjustmentsForWidths uses the current stroke widths of the two endpoint shapes.
func (Connection) CSSStyle ¶
func (c Connection) CSSStyle() string
func (*Connection) EndpointInsets ¶ added in v0.10.1
func (c *Connection) EndpointInsets(srcWidth, dstWidth float64) [2]float64
EndpointInsets gives the two distances that trim the painted centerline.
func (*Connection) GetArrowheadLabelPosition ¶
func (connection *Connection) GetArrowheadLabelPosition(isDst bool) *geo.Point
func (Connection) GetFontColor ¶
func (c Connection) GetFontColor() string
func (Connection) GetID ¶
func (c Connection) GetID() string
func (*Connection) GetIconPosition ¶
func (c *Connection) GetIconPosition() *geo.Point
func (*Connection) GetLabelTopLeft ¶
func (c *Connection) GetLabelTopLeft() *geo.Point
func (Connection) GetZIndex ¶
func (c Connection) GetZIndex() int
func (Connection) GradientBounds ¶ added in v0.10.0
func (c Connection) GradientBounds() *geo.Box
GradientBounds anchors a connection's stroke paint to its full route, before the shaft is shortened for arrowheads. Even a straight horizontal or vertical connection needs a paintable cross section for its stroke and markers.
func (Connection) HasLabel ¶ added in v0.10.1
func (c Connection) HasLabel() bool
func (*Connection) HasStaticIcon ¶ added in v0.10.1
func (c *Connection) HasStaticIcon() bool
func (*Connection) HasVisibleIconStream ¶ added in v0.10.1
func (c *Connection) HasVisibleIconStream() bool
HasVisibleIconStream reports whether the connection's clock can paint an icon. An image remains visible on a transparent wire, as can part of a gradient.
func (*Connection) IconMotionPath ¶ added in v0.10.1
func (c *Connection) IconMotionPath(srcWidth, dstWidth float64) IconMotionPath
func (*Connection) IconPolygon ¶ added in v0.10.1
func (c *Connection) IconPolygon(center geo.Point) []geo.Point
IconPolygon returns the upright vertices of a built-in polygon with its filled centroid at center. Circles and image icons have no polygon.
func (*Connection) IconSize ¶ added in v0.10.1
func (c *Connection) IconSize() int
func (*Connection) LabelFillBounds ¶ added in v0.10.1
func (c *Connection) LabelFillBounds(x, y float64) (left, top, width, height float64)
LabelFillBounds returns the painted background of the connection label. Plain captions have a padded rounded rectangle. Markdown paints its viewport.
func (*Connection) LabelMasksStroke ¶ added in v0.10.1
func (c *Connection) LabelMasksStroke(paintVisible func(string) bool) bool
LabelMasksStroke reports whether the main caption contributes a knockout. Rich content can supply its own ink. Legacy labels keep their existing masks.
func (*Connection) MovingIconFootprint ¶ added in v0.10.1
func (c *Connection) MovingIconFootprint() MovingIconFootprint
func (Connection) PathCommands ¶ added in v0.10.0
func (c Connection) PathCommands(srcAdj, dstAdj *geo.Point) iter.Seq[ConnectionPathCommand]
PathCommands walks the final routed path, including arrowhead insets and rounded polyline corners. Consumers must first validate the render target.
func (Connection) RenderedStrokeWidth ¶ added in v0.10.0
func (c Connection) RenderedStrokeWidth() float64
func (*Connection) ResolveGradientAngles ¶ added in v0.10.1
func (c *Connection) ResolveGradientAngles()
ResolveGradientAngles uses the route box shared by the shaft and markers, and the label box for foreground and background text paints.
func (Connection) RichNumber ¶ added in v0.10.1
func (c Connection) RichNumber() string
Rich labels reserve room for a separate number so the parser sees only the authored content.
func (*Connection) ValidateIconMotion ¶ added in v0.10.1
func (connection *Connection) ValidateIconMotion(path string) error
ValidateIconMotion checks retained artwork and the bounded particles used by SVG, the native scene builder, and callers constructing targets directly.
type ConnectionGap ¶ added in v0.10.0
ConnectionGap is a transparent opening in an individual connection stroke.
type ConnectionIconAnimation ¶ added in v0.10.1
type ConnectionIconAnimation struct {
Rate *float64 `json:"rate,omitempty"`
// DurationMS sets the trip time of a single repeating icon. A positive duration
// is mutually exclusive with Rate. Zero uses the diagram's default travel speed.
DurationMS int64 `json:"durationMs,omitempty"`
// Identifies an incoming stream across a board transition. Steps omit
// an unchanged ID. Scenarios set it explicitly when continuing streams.
// An empty predecessor marks a new or replacement stream.
PreviousID *string `json:"previousID,omitempty"`
}
A nil Rate repeats one icon. An explicit rate emits icons per second; zero stops new emissions while icons already in flight finish their trips.
func (*ConnectionIconAnimation) HasExplicitPeriod ¶ added in v0.10.1
func (a *ConnectionIconAnimation) HasExplicitPeriod() bool
HasExplicitPeriod reports whether the author specified a repeating departure interval.
type ConnectionIconSchedule ¶ added in v0.10.1
type ConnectionIconSchedule struct {
// FixedLayer also allows a clicked board to keep running indefinitely.
FixedLayer bool
StartMS, DurationMS, FilmMS int
Transit, First, Period float64 // seconds
Carried []ConnectionIconTrip
}
ConnectionIconSchedule describes a fixed picture on a repeating multiboard SVG clock. Existing copies finish once; the remaining copies launch at First and repeat with Period (positive infinity means no additional launches).
type ConnectionIconTrip ¶ added in v0.10.1
type ConnectionIconTrip struct {
Progress float64 // fraction of the route already traveled
Transit float64 // seconds for the full trip, including the part already traveled
}
ConnectionIconTrip describes an icon already in flight at the start of a picture.
type ConnectionPathCommand ¶ added in v0.10.0
ConnectionPathCommand is an absolute M, L, C, or S command on the rendered centerline. Cubics include both control points, including the implicit first control of an S command.
func SharedShaftPath ¶ added in v0.10.1
func SharedShaftPath(connections []Connection, shapes map[string]Shape, indices []int) []ConnectionPathCommand
SharedShaftPath paints shared straight spans and identical cubic bends once. Bends remain in their original subpaths wherever they meet. Marker placement and interaction geometry continue to use each original connection. The result contains absolute M, L and C commands only.
type Diagram ¶
type Diagram struct {
Name string `json:"name"`
Config *Config `json:"config,omitempty"`
// 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"`
MonoFontFamily *d2fonts.FontFamily `json:"monoFontFamily,omitempty"`
Shapes []Shape `json:"shapes"`
Connections []Connection `json:"connections"`
Root Shape `json:"root"`
Legend *Legend `json:"legend,omitempty"`
Layers []*Diagram `json:"layers,omitempty"`
Scenarios []*Diagram `json:"scenarios,omitempty"`
Steps []*Diagram `json:"steps,omitempty"`
// TweenFrames are samples of this board's incoming transition,
// starting at time zero. The board itself supplies the exact endpoint.
TweenFrames []*Diagram `json:"tweenFrames,omitempty"`
TweenDurationMS int `json:"tweenDurationMS,omitempty"`
// TweenFrameEndsMS holds exclusive sample ends for nonuniform playback.
// The authored endpoint takes over when the final sample ends.
// Omit it for uniformly spaced samples.
TweenFrameEndsMS []int `json:"tweenFrameEndsMS,omitempty"`
// GridMotion keeps a common coordinate system for raster playback as cells reflow.
GridMotion bool `json:"gridMotion,omitempty"`
// LayoutContinuity means the board shares layout coordinates with its
// layout predecessor. Animated scenarios can share coordinates with
// the preceding sibling. Independent layers start their own coordinate system.
LayoutContinuity bool `json:"layoutContinuity,omitempty"`
// Canvas is a box the board's bounds always include. An animation with
// annotations gives every board and frame the same canvas, so the picture
// keeps one size while notes come and go.
Canvas *MotionBox `json:"canvas,omitempty"`
}
func NewDiagram ¶
func NewDiagram() *Diagram
func (*Diagram) AnnotationMarks ¶ added in v0.10.1
func (diagram *Diagram) AnnotationMarks() []AnnotationMark
AnnotationMarks resolves every annotation on the board, in drawing order. A sampled frame can carry the previous board's marks while they are erased.
func (Diagram) BoundingBox ¶
func (*Diagram) CaptionBox ¶ added in v0.10.1
CaptionBox places the board's caption under everything else on the board. ink is the board's extent without the caption.
func (*Diagram) ConnectionIconPeriods ¶ added in v0.10.1
func (d *Diagram) ConnectionIconPeriods() iter.Seq2[*Connection, float64]
ConnectionIconPeriods yields the effective departure period in seconds for each visible stream on this laid-out board. For a single repeating icon, the period is the travel time along its painted route.
func (*Diagram) ConnectionIconRoutes ¶ added in v0.10.1
func (d *Diagram) ConnectionIconRoutes() iter.Seq2[int, IconMotionPath]
ConnectionIconRoutes yields motion paths in connection order, using the stroke widths of this board's endpoints. Routes must already be laid out.
func (Diagram) GetNestedCorpus ¶
func (*Diagram) HasSequenceActivations ¶ added in v0.10.1
func (Diagram) InkBoundingBox ¶ added in v0.10.1
InkBoundingBox bounds everything drawn on the board except its caption, which is placed under this box.
func (Diagram) NestedBoundingBox ¶
func (*Diagram) ReadingMS ¶ added in v0.10.1
ReadingMS estimates how long the board's caption and notes take to read. An animation holds the board at least this long, so that a step lasts as long as its sentence. Subtitles are paced at about 17 characters a second; the constant gives the eye time to find each new piece of text.
func (*Diagram) ResolveBoard ¶ added in v0.10.1
ResolveBoard also returns the fully qualified path relative to d. A target may omit board namespaces, while a compiled shape link always includes them.
func (*Diagram) ScenarioPredecessors ¶ added in v0.10.1
ScenarioPredecessors identifies the parent or sibling on screen just before each drawable scenario. A folder consumes no time, but one of its children may interrupt the comparison.
func (*Diagram) SequenceLifelineLabelGaps ¶ added in v0.10.1
func (d *Diagram) SequenceLifelineLabelGaps(sketch bool, paintVisible func(string) bool) map[int][]SequenceLabelGap
SequenceLifelineLabelGaps returns stroke masks keyed by connection index. Keeping the original route intact preserves the phase of its dashes and its animation.
func (*Diagram) TweenFrameEndMS ¶ added in v0.10.1
TweenFrameEndMS returns the exclusive end of an existing sample on a whole-millisecond clock. Uniform sample boundaries round down.
func (*Diagram) WithIconLabelInsets ¶ added in v0.10.1
WithIconLabelInsets resolves derived geometry for standalone render targets and for frames whose endpoint strokes changed after layout. The original board and its connections remain usable by concurrent renders.
type IconMotionPath ¶ added in v0.10.1
IconMotionPath follows the painted centerline in the connection's travel direction. Distances are cumulative arc lengths, so equal time intervals cover equal distances.
func (IconMotionPath) LaunchPeriod ¶ added in v0.10.1
func (p IconMotionPath) LaunchPeriod(animation *ConnectionIconAnimation) float64
LaunchPeriod gives the time in seconds between visible departures. The one-icon loop launches its next copy when the previous copy lands.
func (IconMotionPath) Length ¶ added in v0.10.1
func (p IconMotionPath) Length() float64
func (IconMotionPath) PointAt ¶ added in v0.10.1
func (p IconMotionPath) PointAt(distance float64) geo.Point
func (IconMotionPath) TransitDuration ¶ added in v0.10.1
func (p IconMotionPath) TransitDuration(animation *ConnectionIconAnimation) float64
TransitDuration returns the time in seconds for one complete trip.
type ImageFit ¶ added in v0.10.1
type ImageFit string
ImageFit controls how an image is sized within its shape.
type ImagePosition ¶ added in v0.10.1
type ImagePosition string
ImagePosition locates the fitted image within its shape.
func (ImagePosition) Alignment ¶ added in v0.10.1
func (position ImagePosition) Alignment() (x, y int, ok bool)
Alignment returns the horizontal and vertical anchors as 0 (start), 1 (center), or 2 (end).
type Legend ¶
type Legend struct {
Label string `json:"label,omitempty"`
Shapes []Shape `json:"shapes,omitempty"`
Connections []Connection `json:"connections,omitempty"`
}
type MText ¶
type MarkdownStrikeTransition ¶ added in v0.10.0
type MarkdownStrikeTransition struct {
From string `json:"from"`
Progress float64 `json:"progress"`
// On a plain destination these are the struck ranges of its shaped line,
// in fractions of the total advance. Its own renderer paints the glyphs.
PlainRanges [][2]float64 `json:"plainRanges,omitempty"`
}
MarkdownStrikeTransition retains the previous markup when only strikethrough spans change.
func (*MarkdownStrikeTransition) PlainRules ¶ added in v0.10.0
func (t *MarkdownStrikeTransition) PlainRules(left, baseline, width, fontSize float64, draw func(x, y, width, height float64))
type MotionBox ¶ added in v0.10.0
type MotionBox = MotionClip
MotionBox holds reference bounds in diagram coordinates during an animation.
type MotionClip ¶ added in v0.10.0
MotionClip is the visible rectangle of an unfolding grid cell, in diagram coordinates.
type MotionLabel ¶ added in v0.10.0
MotionLabel anchors the caption and its mask while a partial route is drawn.
type MovingIconFootprint ¶ added in v0.10.1
type MovingIconFootprint uint8
MovingIconFootprint describes the artwork that a primary caption must clear. A stopped stream keeps its footprint while its last icons finish traveling.
func (MovingIconFootprint) LabelTopLeft ¶ added in v0.10.1
func (icon MovingIconFootprint) LabelTopLeft(c *Connection, pos label.Position, fraction, width, height float64, charge func(int64) bool) *geo.Point
LabelTopLeft measures a candidate caption at the same position for layout and for painting. Inline captions retain their intentional gap in the connection. A layout work guard can stop the measurement by returning false from charge.
type RectBorderRegion ¶ added in v0.10.1
type RectBorderRegion struct {
X, Y, Width, Height int
Outline []svg.PathCommand
Dividers []BorderCut
}
RectBorderRegion describes the combined frame of adjoining cells. An empty Outline uses the bounding rectangle. Other outlines consist of closed paths, including any holes. Each divider is a separate straight stroke.
type SQLColumn ¶
type SQLColumn struct {
Name Text `json:"name"`
Type Text `json:"type"`
Constraint []string `json:"constraint"`
Reference string `json:"reference"`
}
func (SQLColumn) ConstraintAbbr ¶
func (SQLColumn) HasConstraint ¶ added in v0.10.1
HasConstraint reports whether the column has the constraint, accepting deprecated spellings in diagrams serialized by earlier versions.
type SQLPrimaryKeyLayout ¶ added in v0.10.1
type SQLPrimaryKeyLayout struct {
// contains filtered or unexported fields
}
func (SQLPrimaryKeyLayout) Constraint ¶ added in v0.10.1
func (k SQLPrimaryKeyLayout) Constraint(index int, text string) (string, int)
Constraint returns the text and the number of consecutive rows occupied by its cell. The empty portion of a shared cell is represented by zero rows.
func (SQLPrimaryKeyLayout) DividerInset ¶ added in v0.10.1
func (k SQLPrimaryKeyLayout) DividerInset(index, fontSize int) float64
DividerInset shortens only the dividers inside the shared constraint cell.
type SQLRowReveal ¶ added in v0.10.0
type SQLRowReveal struct {
FullHeight int `json:"fullHeight"`
}
SQLRowReveal fixes row spacing at the authored height while the table's moving bottom edge uncovers each appended row.
type SQLTable ¶
type SQLTable struct {
Columns []SQLColumn `json:"columns"`
// PrimaryKey lists the zero-based column indices in key order.
PrimaryKey []int `json:"primaryKey,omitempty"`
PrimaryKeyLabelWidth int `json:"primaryKeyLabelWidth,omitempty"`
}
func (*SQLTable) AppendsRowsTo ¶ added in v0.10.0
AppendsRowsTo reports whether adding fields preserves existing row spacing and the horizontal alignment of the type column.
func (SQLTable) PrimaryKeyLayout ¶ added in v0.10.1
func (t SQLTable) PrimaryKeyLayout() SQLPrimaryKeyLayout
PrimaryKeyLayout shares a constraint cell when a key follows the row order and there are no individual constraints in those cells. Ordinals identify the row membership and key order in every other case.
type SequenceLabelGap ¶ added in v0.10.1
SequenceLabelGap clears a lifeline beneath a caption in diagram coordinates.
type Shape ¶
type Shape struct {
ID string `json:"id"`
Type string `json:"type"`
// SequenceRole preserves the v2 timeline role independently of shape geometry and paint order.
SequenceRole string `json:"sequenceRole,omitempty"`
Classes []string `json:"classes,omitempty"`
// MotionOffset preserves the fractional translation of a sampled shape. Pos
// remains the integer coordinate used by layout and static render targets.
// A non-nil zero denotes an integer sample on a continuous trajectory.
MotionOffset *geo.Point `json:"motionOffset,omitempty"`
// Only intermediate grid frames carry a viewport, caption anchor or LaTeX scale.
MotionScale float64 `json:"motionScale,omitempty"`
MotionClip *MotionClip `json:"motionClip,omitempty"`
MotionLabelTopLeft *Point `json:"motionLabelTopLeft,omitempty"`
// MotionLabelBox holds the authored body bounds for a stationary inside label.
MotionLabelBox *MotionBox `json:"motionLabelBox,omitempty"`
RowReveal *SQLRowReveal `json:"rowReveal,omitempty"`
// OutlineProgress traces an incoming container frame in a transition sample.
OutlineProgress *float64 `json:"outlineProgress,omitempty"`
Pos Point `json:"pos"`
Width int `json:"width"`
Height int `json:"height"`
Opacity float64 `json:"opacity"`
StrokeDash float64 `json:"strokeDash"`
StrokeWidth int `json:"strokeWidth"`
// Tween frames retain the subpixel difference from the integer layout width.
StrokeWidthOffset float64 `json:"strokeWidthOffset,omitempty"`
BorderRadius int `json:"borderRadius"`
Fill string `json:"fill"`
FillPattern string `json:"fillPattern,omitempty"`
SketchFillTransition *SketchFillTransition `json:"sketchFillTransition,omitempty"`
Stroke string `json:"stroke"`
Animated bool `json:"animated"`
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"`
PrettyLink string `json:"prettyLink,omitempty"`
Icon *url.URL `json:"icon"`
IconBorderRadius int `json:"iconBorderRadius,omitempty"`
IconPosition string `json:"iconPosition"`
ImageFit ImageFit `json:"imageFit,omitempty"`
ImagePosition ImagePosition `json:"imagePosition,omitempty"`
// Whether the shape should allow shapes behind it to bleed through
// Currently just used for sequence diagram groups
Blend bool `json:"blend"`
Class
SQLTable
ContentAspectRatio *float64 `json:"contentAspectRatio,omitempty"`
Text
LabelPosition string `json:"labelPosition,omitempty"`
TooltipPosition string `json:"tooltipPosition,omitempty"`
// Annotation is drawn over the shape without taking part in layout. On a
// diagram's root it is the board's caption.
Annotation *Annotation `json:"annotation,omitempty"`
// LeavingAnnotation is the previous board's annotation while a sampled
// frame erases it.
LeavingAnnotation *Annotation `json:"leavingAnnotation,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) AppendixLinkText ¶ added in v0.10.0
AppendixLinkText returns the text listed in a static export's appendix for the shape's link, or "" when the shape has no link. Every shape with a Link gets a numbered link marker, so it must also get an appendix entry: when no board label could be derived for PrettyLink (e.g. a link to the parent board), the link itself is listed so the marker and appendix numbers stay in one sequence.
func (*Shape) CanDrawOutline ¶ added in v0.10.0
CanDrawOutline reports whether a plain rectangular body has one visible solid contour. Rounded, double and decorated contours keep their own paint.
func (*Shape) CanShadeSketchFill ¶ added in v0.10.0
CanShadeSketchFill reports whether the shape has a single solid sketch surface.
func (*Shape) CodeBlockBounds ¶ added in v0.10.1
CodeBlockBounds places code inside a v2 page note. Other code backgrounds use the dimensions of their enclosing shape.
func (*Shape) DrawingOutline ¶ added in v0.10.0
DrawingOutline selects partial geometry for intermediate frames. A complete frame goes through the ordinary closed-stroke renderer, including its joins.
func (*Shape) DrawnOutline ¶ added in v0.10.0
DrawnOutline follows two equal-length strokes from the top center down the sides. Joining them through the common origin yields one open polyline in both SVG and raster, and keeps the stroke width constant as the frame grows.
func (*Shape) Geometry ¶ added in v0.10.0
Geometry returns the same outline and inner content box used for rendering.
func (Shape) GetFontColor ¶
func (*Shape) IconBounds ¶ added in v0.10.0
IconBounds returns the rendered icon rectangle for a shape with an icon.
func (*Shape) IsSequenceHeader ¶ added in v0.10.1
IsSequenceHeader also recognizes repeated participants drawn at a checkpoint or mirrored at the bottom of the diagram.
func (*Shape) LabelBox ¶ added in v0.10.1
LabelBox is the outline or inner content box anchoring an ordinary caption.
func (*Shape) LabelFillBox ¶ added in v0.10.1
LabelFillBox gives the painted backdrop around a caption. A sequence frame's top-left title tab extends toward its outline and around its text.
func (*Shape) LabelTopLeft ¶ added in v0.10.0
LabelTopLeft resolves both ordinary captions and intermediate animation anchors.
func (*Shape) OuterLabelBox ¶ added in v0.10.0
OuterLabelBox is the painted outline used to place outside and border labels.
func (*Shape) OverlaySequenceCaption ¶ added in v0.10.1
OverlaySequenceCaption reports whether to move a frame title or branch guard into the foreground when the diagram has activations.
func (*Shape) RenderedPosition ¶ added in v0.10.1
RenderedPosition includes a moving shape's fractional translation in diagram coordinates.
func (Shape) RenderedStrokeWidth ¶ added in v0.10.0
func (*Shape) ResolveGradientAngles ¶ added in v0.10.1
func (s *Shape) ResolveGradientAngles()
ResolveGradientAngles applies the paint box for each CSS degree angle. Renderers call it on their local shape before creating paint resources.
func (*Shape) ResolveSequenceFrameFill ¶ added in v0.10.1
func (s *Shape) ResolveSequenceFrameFill()
ResolveSequenceFrameFill selects adaptive paint on the renderer's shape copy. Exported diagrams retain the ordinary N5 palette entry used by older readers. An actor group has no frame caption backdrop.
func (*Shape) SQLRowDivider ¶ added in v0.10.0
SQLRowDivider keeps the separator and moving bottom border together.
func (*Shape) SQLRowHeight ¶ added in v0.10.0
func (*Shape) SQLRowVisibleHeight ¶ added in v0.10.0
SQLRowVisibleHeight is the portion of a row below its stationary top edge. While the slot opens, its contents travel with the bottom of the table.
type ShapeBorder ¶ added in v0.10.1
type ShapeBorder struct {
Path []svg.PathCommand
// RectCuts lets SVG keep a rectangle's native corner rasterization.
// Each cut follows the shape's original centerline.
RectCuts []BorderCut
// Region replaces the borders of adjoining cells at the last cell's paint position.
Region *RectBorderRegion
}
ShapeBorder describes the remaining path at one fill/stroke paint position.
type ShapeBorderPlan ¶ added in v0.10.1
type ShapeBorderPlan map[int]ShapeBorder
ShapeBorderPlan maps an original body path index to its remaining stroke. A missing index keeps the original stroke. A non-nil, empty Path hides it.
type ShapeOption ¶ added in v0.10.1
type ShapeOption struct {
Name string
Detail string
Values *ShapeOptionValues
}
ShapeOption describes one scalar setting in an object's shape map. These options are local to their shape and do not reserve ordinary object names.
func FindShapeOption ¶ added in v0.10.1
func FindShapeOption(shape, name string) *ShapeOption
func ShapeOptions ¶ added in v0.10.1
func ShapeOptions(shape string) []ShapeOption
ShapeOptions returns the registered scalar options in completion order. Rich image and SQL table options have their own parsers.
type ShapeOptionValues ¶ added in v0.10.1
ShapeOptionValues describes the accepted literals and the value used by filters when an option is omitted.
func UnqualifiedShapeOptionValues ¶ added in v0.10.1
func UnqualifiedShapeOptionValues(name string) *ShapeOptionValues
UnqualifiedShapeOptionValues lets editors complete an option while the author is still typing the shape. Ambiguous value types require a shape.
type SketchFillTransition ¶ added in v0.10.0
type SketchFillTransition struct {
From string `json:"from"`
To string `json:"to"`
Progress float64 `json:"progress"`
}
SketchFillTransition describes the pencil shading on one sampled frame.
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"`
// CodeFontColor selects an authored color over the syntax theme for code labels.
CodeFontColor bool `json:"codeFontColor,omitempty"`
Italic bool `json:"italic"`
Bold bool `json:"bold"`
Underline bool `json:"underline"`
// UnderlineProgress is the visible fraction of the underline on a sampled frame.
UnderlineProgress *float64 `json:"underlineProgress,omitempty"`
MarkdownStrike *MarkdownStrikeTransition `json:"markdownStrike,omitempty"`
LabelWidth int `json:"labelWidth"`
LabelHeight int `json:"labelHeight"`
LabelFill string `json:"labelFill,omitempty"`
}
type TextDimensions ¶
func NewTextDimensions ¶
func NewTextDimensions(w, h int) *TextDimensions
type ThemeOverrides ¶
type ThemeOverrides struct {
N1 *string `json:"n1"`
N2 *string `json:"n2"`
N3 *string `json:"n3"`
N4 *string `json:"n4"`
N5 *string `json:"n5"`
N6 *string `json:"n6"`
N7 *string `json:"n7"`
B1 *string `json:"b1"`
B2 *string `json:"b2"`
B3 *string `json:"b3"`
B4 *string `json:"b4"`
B5 *string `json:"b5"`
B6 *string `json:"b6"`
AA2 *string `json:"aa2"`
AA4 *string `json:"aa4"`
AA5 *string `json:"aa5"`
AB4 *string `json:"ab4"`
AB5 *string `json:"ab5"`
}
type TraceEndpoint ¶ added in v0.10.0
type TraceEndpoint string
TraceEndpoint identifies which end of an animated polyline is still being drawn.
const ( TraceSource TraceEndpoint = "source" TraceDestination TraceEndpoint = "destination" )
Source Files
¶
- annotation.go
- annotation_marks.go
- board_outline.go
- class.go
- connection_crossings.go
- connection_dash.go
- connection_icon_loop.go
- connection_icon_motion.go
- connection_icon_shape.go
- connection_label_icon.go
- connection_path.go
- connection_sketch_crossing.go
- d2target.go
- image.go
- rect_border_region.go
- rect_border_strip.go
- render_validation.go
- sequence_captions.go
- sequence_lifeline.go
- shape_options.go
- shared_border_connections.go
- shared_borders.go
- shared_shafts.go
- sqltable.go