d2sketch

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BG_COLOR = color.N7
	FG_COLOR = color.N1
)

Variables

This section is empty.

Functions

func ArrowheadDrawables added in v0.9.0

func ArrowheadDrawables(arrowhead d2target.Arrowhead, stroke string, strokeWidth int) ([]rough.Drawable, bool)

ArrowheadDrawables returns the bounded, structured rough-go geometry for one D2 arrowhead. Every generator input has a fixed number of points, and each endpoint gets a fresh seeded generator so output is independent of object or frame traversal order.

func Arrowheads

func Arrowheads(connection d2target.Connection, srcAdj, dstAdj *geo.Point) (string, error)

func Class

func Class(shape d2target.Shape) (string, error)

func Connection

func Connection(connection d2target.Connection, path, attrs string) (string, error)

func ConnectionDrawable added in v0.9.0

func ConnectionDrawable(ctx context.Context, path d2scene.Path, limits SceneLimits) (rough.Drawable, error)

ConnectionDrawable converts a typed connection path into deterministic rough-go operations without serializing or parsing SVG path data. Cubics are flattened at a fixed resolution before roughening; this keeps generation work predictable while retaining the route's rounded/curved silhouette. limits bound the rough intermediate before any expanded point slice is allocated. Long routes are generated in fixed-size sets so cancellation is observed between bounded rough-go calls.

func DefineFillPatterns

func DefineFillPatterns(buf *bytes.Buffer, diagramHash string)

DefineFillPatterns adds reusable patterns that are overlayed on shapes with fill. This gives it a subtle streaky effect that subtly looks hand-drawn but not distractingly so.

func DoubleOval

func DoubleOval(shape d2target.Shape, diagramHash string) (string, error)

func DoubleRect

func DoubleRect(shape d2target.Shape, diagramHash string) (string, error)

func Oval

func Oval(shape d2target.Shape, diagramHash string) (string, error)

func Paths

func Paths(shape d2target.Shape, diagramHash string, paths []string) (string, error)

TODO need to personalize this per shape like we do in Terrastruct app

func Rect

func Rect(shape d2target.Shape, diagramHash string) (string, error)

func Table

func Table(shape d2target.Shape) (string, error)

TODO cleanup

Types

type SceneLimits added in v0.9.0

type SceneLimits struct {
	MaxSets int
	MaxOps  int
}

SceneLimits bounds conversion work after rough-go has generated a drawable. D2 callers must additionally charge the generated commands against their document-wide scene/path budget.

type ScenePath added in v0.9.0

type ScenePath struct {
	Path        d2scene.Path
	Fill        string
	Stroke      string
	StrokeWidth float64
	Dash        []float64
	DashOffset  float64
}

ScenePath is the renderer-neutral form of one ordered rough-go operation set. Paint remains a string so callers can resolve D2 theme colors before constructing scene paint.

func CompileScenePaths added in v0.9.0

func CompileScenePaths(ctx context.Context, drawable rough.Drawable, limits SceneLimits) ([]ScenePath, error)

CompileScenePaths translates the rough-go operation types emitted by D2 into typed scene paths. It rejects path2D operation sets.

Jump to

Keyboard shortcuts

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