Documentation
¶
Overview ¶
d2svg implements an SVG renderer for d2 diagrams. The input is d2exporter's output
Index ¶
- Constants
- Variables
- func EmbedFonts(buf *bytes.Buffer, diagramHash, source string, fontFamily *d2fonts.FontFamily, ...)
- func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error)
- func RenderContext(ctx context.Context, diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error)
- func RenderLegend(buf *bytes.Buffer, diagram *d2target.Diagram, diagramHash string, ...) error
- func RenderMultiboard(diagram *d2target.Diagram, opts *RenderOpts) ([][]byte, error)
- func RenderText(text string, x, height float64) string
- func ThemeCSS(diagramHash string, themeID *int64, darkThemeID *int64, ...) (stylesheet string, err error)
- func UsesDefaultStylesheet() bool
- func WriteAnimationStyles(buf *bytes.Buffer, diagramHash, source string, diagram *d2target.Diagram, ...) error
- func WriteAnimationStylesWithTransitions(buf *bytes.Buffer, diagramHash, source string, diagram *d2target.Diagram, ...) error
- type DiagramObject
- type ImageSize
- type RenderOpts
Constants ¶
const ( DEFAULT_PADDING = 100 // Legend constants LEGEND_PADDING = 20 LEGEND_ITEM_SPACING = 15 LEGEND_ICON_SIZE = 24 LEGEND_FONT_SIZE = 14 LEGEND_CORNER_PADDING = 10 )
Variables ¶
var BaseStylesheet = defaultBaseStylesheet
BaseStylesheet supplies the shared CSS for rendered SVG diagrams.
var DEFAULT_DARK_THEME *int64 = nil // no theme selected
var LinkIcon string
var MarkdownCSS string
MarkdownCSS is retained for compatibility with callers that used the browser-era Markdown stylesheet directly.
Deprecated: native Markdown SVG does not use or inject this HTML stylesheet.
var TooltipIcon string
Functions ¶
func EmbedFonts ¶
func EmbedFonts(buf *bytes.Buffer, diagramHash, source string, fontFamily *d2fonts.FontFamily, monoFontFamily *d2fonts.FontFamily, corpus string)
func RenderContext ¶ added in v0.10.0
func RenderContext(ctx context.Context, diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error)
RenderContext renders a single board and observes cancellation between render stages and individual objects.
func RenderLegend ¶
func RenderMultiboard ¶
func RenderMultiboard(diagram *d2target.Diagram, opts *RenderOpts) ([][]byte, error)
func RenderText ¶
func UsesDefaultStylesheet ¶ added in v0.10.0
func UsesDefaultStylesheet() bool
UsesDefaultStylesheet reports whether generated markup can be optimized without affecting selectors supplied by the caller.
func WriteAnimationStyles ¶ added in v0.10.0
func WriteAnimationStyles(buf *bytes.Buffer, diagramHash, source string, diagram *d2target.Diagram, opts RenderOpts) error
WriteAnimationStyles embeds the font faces and theme rules used by a complete animation. Source includes the shared definitions and all rendered frames.
func WriteAnimationStylesWithTransitions ¶ added in v0.10.1
func WriteAnimationStylesWithTransitions(buf *bytes.Buffer, diagramHash, source string, diagram *d2target.Diagram, opts RenderOpts, transitions []byte) error
WriteAnimationStylesWithTransitions adds the animation clock's CSS to the generated stylesheet. Custom base styles retain their own stylesheet so CSS imports and namespace declarations stay in their original positions.
Types ¶
type DiagramObject ¶
type ImageSize ¶ added in v0.10.1
ImageSize provides the intrinsic dimensions of an image source in diagram units. When unavailable, standalone SVG uses the browser's image sizing.
type RenderOpts ¶
type RenderOpts struct {
Pad *int64
Sketch *bool
Center *bool
ThemeID *int64
DarkThemeID *int64
ThemeOverrides *d2target.ThemeOverrides
DarkThemeOverrides *d2target.ThemeOverrides
// AnimateProgress overrides the elapsed-time line on animated exports.
// By default the line is shown when a positive playback interval is configured.
AnimateProgress *bool
// AnimateProgressColor overrides the color of an enabled progress line.
AnimateProgressColor string
Font string
// ImageSize supplies metadata for fitted images before SVG drawing.
ImageSize ImageSize `json:"-"`
// the svg will be scaled by this factor, if unset the svg will fit to screen
Scale *float64
// MasterID is passed when the diagram should use something other than its own hash for unique targeting
// Currently, that's when multi-boards are collapsed
MasterID string
NoXMLTag *bool
Salt *string
OmitVersion *bool
}
Source Files
¶
- annotation.go
- class.go
- code.go
- connection_crossings.go
- connection_gradient.go
- connection_icons.go
- d2svg.go
- fill_patterns.go
- font_corpus.go
- latex.go
- markdown.go
- object_writer.go
- paint_validation.go
- scheduled_icons.go
- shape_image.go
- shape_image_size_native.go
- shared_borders.go
- shared_shafts.go
- stylesheet.go
- table.go
- theme.go