Documentation
¶
Index ¶
- Constants
- func ArrowheadDrawables(arrowhead d2target.Arrowhead, stroke string, strokeWidth int) ([]rough.Drawable, bool)
- func ArrowheadDrawablesWithWidth(arrowhead d2target.Arrowhead, stroke string, strokeWidth float64) ([]rough.Drawable, bool)
- func ArrowheadPlacement(connection d2target.Connection, isTarget bool, adjustment *geo.Point) (anchor geo.Point, degrees float64)
- func Arrowheads(connection d2target.Connection, srcAdj, dstAdj *geo.Point) (string, error)
- func ArrowheadsWithPaint(connection d2target.Connection, srcAdj, dstAdj *geo.Point, ...) (string, error)
- func Class(shape d2target.Shape) (string, error)
- func Connection(connection d2target.Connection, path, attributes string) (string, error)
- func ConnectionDrawable(ctx context.Context, path d2scene.Path, limits SceneLimits) (rough.Drawable, error)
- func ConnectionWithAttributes(connection d2target.Connection, path string, attributes []svg.Attribute) (string, error)
- func DefineFillPatterns(buf *bytes.Buffer, diagramHash string)
- func DefineSharedFillPatterns(buf *bytes.Buffer, diagramHash string)
- func DoubleOval(shape d2target.Shape, diagramHash string) (string, error)
- func DoubleRect(shape d2target.Shape, diagramHash string) (string, error)
- func MarkdownBackground(s d2target.Shape, sketch bool) string
- func Oval(shape d2target.Shape, diagramHash string) (string, error)
- func Paths(shape d2target.Shape, diagramHash string, paths []string) (string, error)
- func Rect(shape d2target.Shape, diagramHash string) (string, error)
- func Table(shape d2target.Shape) (string, error)
- func TexturePaint(s d2target.Shape, renderedFill string) string
- type PencilFill
- type SceneLimits
- type ScenePath
Constants ¶
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 ArrowheadDrawablesWithWidth ¶ added in v0.10.0
func ArrowheadDrawablesWithWidth(arrowhead d2target.Arrowhead, stroke string, strokeWidth float64) ([]rough.Drawable, bool)
ArrowheadDrawablesWithWidth accepts fractional widths from animation frames.
func ArrowheadPlacement ¶ added in v0.10.0
func ArrowheadPlacement(connection d2target.Connection, isTarget bool, adjustment *geo.Point) (anchor geo.Point, degrees float64)
ArrowheadPlacement positions a sketch arrowhead's local geometry in diagram coordinates. Gradient paints use the same placement as the rendered paths.
func Arrowheads ¶
func ArrowheadsWithPaint ¶ added in v0.10.0
func ArrowheadsWithPaint(connection d2target.Connection, srcAdj, dstAdj *geo.Point, srcStroke, dstStroke string) (string, error)
ArrowheadsWithPaint accepts a paint for each endpoint in its local coordinates.
func Connection ¶
func Connection(connection d2target.Connection, path, attributes string) (string, error)
Connection is retained for source compatibility. Its legacy textual attribute list is parsed and re-serialized before use. Deprecated: use ConnectionWithAttributes.
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 ConnectionWithAttributes ¶ added in v0.10.0
func DefineFillPatterns ¶
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 DefineSharedFillPatterns ¶ added in v0.10.0
DefineSharedFillPatterns reuses the path between inks. Use DefineFillPatterns when a custom stylesheet can target the path inside each pattern.
func MarkdownBackground ¶ added in v0.10.0
MarkdownBackground keeps the viewport behind the glyphs clear while pencil strokes are visible. A label outside or across the border still needs its own backing. At either endpoint use the authored board's normal backing.
func TexturePaint ¶ added in v0.10.0
TexturePaint selects the material for the existing streak overlay. Static sketch textures use the material produced by the element renderer (which also resolves gradients). A pencil pattern takes its texture from the underlying sampled color, rather than from its temporary paint-server ID.
Types ¶
type PencilFill ¶ added in v0.10.0
PencilFill is one sampled pass of diagonal pencil strokes, in shape-local coordinates. Both exporters use these same strokes; the shape supplies the silhouette. Each quadrilateral is ordered around its perimeter.
func SamplePencilFill ¶ added in v0.10.0
func SamplePencilFill(s d2target.Shape) *PencilFill
type SceneLimits ¶ added in v0.9.0
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.