Documentation
¶
Overview ¶
Package isotopo renders editable architecture diagrams from YAML, JSON and D2. The root package is the stable public API. Implementations live in internal domain packages; callers should continue importing this package.
Index ¶
- Constants
- Variables
- func ApplyOpText(format string, src []byte, op EditOp) ([]byte, error)
- func ApplyPatch(doc *Document, p Patch) bool
- func ApplyReadableProfile(doc *Document)
- func ApplyTheme(doc *Document, name string) error
- func CompileD2(ctx context.Context, d2text string, layoutEngine LayoutEngine) (*d2target.Diagram, error)
- func ComposeScene(doc *Document) []string
- func ConnectorBend(doc *Document, ci int) (float64, float64)
- func EmitBackgroundDefs(defs *strings.Builder, opts *RenderOpts) string
- func Flatten(n *Node, theme *Theme) (string, iso25d.ConvertOpts)
- func GroupHasLayout(doc *Document, groupID string) bool
- func MarshalFragmentYAML(d *Document) ([]byte, error)
- func NodeHTML(id string, svg string, yamlFragment string) string
- func NodesIndexHTML(ids []string) string
- func PartFragments(doc *Document) map[string]*Document
- func PartIDs(doc *Document) []string
- func Rasterize(svgPath string, pngPath string) error
- func Render(n *Node, theme *Theme) string
- func RenderDocument(doc *Document) map[string]string
- func RenderParts(doc *Document) map[string]string
- func RenderPlan(n *Node, theme *Theme, canvas *Canvas, annotations []*Annotation) string
- func RenderSceneWithReport(doc *Document) (SceneResult, RenderReport)
- func RenderSubgraph(doc *Document, ids []string) (string, error)
- func RenderWithCanvas(n *Node, theme *Theme, canvas *Canvas, anns []*Annotation) string
- func RepairAndReport(doc *Document) (int, []string)
- func RepairSource(lang string, src []byte) ([]byte, []string, error)
- func RepairSourceWithOptions(lang string, src []byte, opts RepairOptions) ([]byte, []string, error)
- func ResolveAllOffsets(doc *Document) map[string][3]float64
- func ResolveChildOffsets(doc *Document, groupID string) map[string][3]float64
- func ResolvePartGeom(doc *Document, id string) (float64, float64, float64, bool)
- func ResolvePartOffset(doc *Document, id string) (float64, float64, float64, bool)
- func SceneIsAuto(doc *Document) bool
- func SceneNeedsFreeze(doc *Document) bool
- func ThemeDescription(name string) string
- func ThemeNames() []string
- func TopologyHTML(svg string, sourceText string, sourceLang string, sourceFilename string) string
- func WorldDropTarget(model []PartModel, dragID string, minOverlapFrac float64) string
- type AnchorPoint
- type Annotation
- type Backglow
- type BackgroundMode
- type BodyOcclusion
- type Canvas
- type Capabilities
- type ColorStop
- type CompositePart
- type CompositionFinding
- type CompositionReport
- type ConnectionPort
- type Connector
- type ConnectorArrowVisibility
- type ConnectorAttachmentWorld
- type ConnectorAttachments
- type ConnectorBodyCoverage
- type ConnectorCollisionReport
- type ConnectorCompositing
- type ConnectorCoverSpan
- type ConnectorDepthSpan
- type ConnectorDrawing
- type ConnectorEditSpan
- type ConnectorEndpointAttachment
- type ConnectorInteriorInterval
- type ConnectorLabel
- type ConnectorLabelConflict
- type ConnectorLabelRecord
- type ConnectorPenetration
- type ConnectorProvenance
- type ConnectorRoute
- type ConnectorSegmentProvenance
- type ConnectorSourceInterval
- type ConnectorSpatialVisibility
- type ConnectorTypography
- type Content
- type ContentFitObservation
- type Direction
- type Document
- func LoadInput(ctx context.Context, format string, data []byte, layoutEngine LayoutEngine) (*Document, error)
- func Parse(data []byte) (*Document, error)
- func ParseJSON(data []byte) (*Document, error)
- func ParseYAML(data []byte) (*Document, error)
- func RepairScene(doc *Document) (*Document, int)
- func Translate(diagram *d2target.Diagram, opts *RenderOpts) *Document
- type DropShadow
- type EditOp
- type EffectItem
- type Effects
- type FaceGradient
- type FacePattern
- type FaceStyle
- type Field
- type FillSpec
- type Geom
- type Grain
- type GridPos
- type IconCap
- type InputFormat
- type IsoReport
- type IsoRouteCrowding
- type Issue
- func ApplyOp(format string, src []byte, op EditOp) ([]byte, string, []Issue, error)
- func ContainerFitIssues(doc *Document) []Issue
- func ContentFitIssues(doc *Document) []Issue
- func LabelOcclusionIssues(doc *Document) []Issue
- func MarkRepairable(before []Issue, after []Issue) []Issue
- func PlanFootprintIssues(doc *Document) []Issue
- func RenderSource(format string, src []byte) (string, []Issue, error)
- func RoundedSideIgnoredIssues(doc *Document) []Issue
- func UnknownKeyIssues(data []byte) []Issue
- func Validate(doc *Document) []Issue
- func VisualContrastIssues(doc *Document) []Issue
- func VisualLint(doc *Document) []Issue
- type IssueDiff
- type Layout
- type LayoutCap
- type LayoutEngine
- type Node
- type Outline
- type Palette
- type PartModel
- type Patch
- type Pattern
- type Place
- type PlanEdgeIssue
- type PlanLabel
- type PlanLabelConflict
- type PlanLabelLine
- type PlanLabelPlacement
- type PlanPoint
- type PlanReport
- func EvaluateIso(n *Node, theme *Theme, canvas *Canvas) *PlanReport
- func EvaluateIsoText(format string, src []byte) (*PlanReport, error)
- func EvaluatePlan(n *Node, theme *Theme, canvas *Canvas) *PlanReport
- func EvaluatePlanText(format string, src []byte) (*PlanReport, error)
- func RenderPlanAnnotated(n *Node, theme *Theme, canvas *Canvas) (string, *PlanReport)
- type PlanRouteConflict
- type PlanRouteCrowding
- type PrimitiveCap
- type ReadabilityReport
- type RenderOpts
- type RenderReport
- type RepairOptions
- type ReportDefect
- type SceneResult
- type ScreenLabel
- type ScreenLabelLine
- type ScreenLabelRect
- type Severity
- type ShapeCap
- type Stack
- type Stroke
- type StrokeLayer
- type Style
- type StyleKeyGroup
- type Text
- type Theme
- type ThemeCap
- type WorldPoint
Constants ¶
const BgDots = model.BgDots
BgDots is part of the public iso-topology API.
const BgGrid = model.BgGrid
BgGrid is part of the public iso-topology API.
const BgHatch = model.BgHatch
BgHatch is part of the public iso-topology API.
const BgSolid = model.BgSolid
BgSolid is part of the public iso-topology API.
const BgTransparent = model.BgTransparent
BgTransparent is part of the public iso-topology API.
const LayoutDagre = d2input.LayoutDagre
LayoutDagre is part of the public iso-topology API.
const LayoutELK = d2input.LayoutELK
LayoutELK is part of the public iso-topology API.
const SeverityError = model.SeverityError
SeverityError is part of the public iso-topology API.
const SeverityWarning = model.SeverityWarning
SeverityWarning is part of the public iso-topology API.
Variables ¶
var RoleNames = style.RoleNames
RoleNames are the semantic slots themes style. Kept deliberately small:
hero — the focal element the diagram is about (one per scene) tray — a category container (group/boundary) holding related parts chip — a compact member tile inside a tray (logo/label card)
Functions ¶
func ApplyOpText ¶
ApplyOpText applies an edit and returns ONLY the rewritten DSL text — the comment-preserving transform, without rendering. Embedders that render separately (or with a non-default layout engine) use this.
func ApplyPatch ¶
ApplyPatch applies a patch to the document in place, returning whether it hit a target. Patch targets match by part id or label.
func ApplyReadableProfile ¶
func ApplyReadableProfile(doc *Document)
ApplyReadableProfile turns a scene into a legibility-first "documentation" render (issue #11). It is the one-switch bundle behind `isotopo render --readable`: instead of asking authors to combine several knobs, it layers readability defaults over whatever theme the scene already uses.
It is OPT-IN and conservative — it only fills gaps the author left blank, so a scene that has already made a choice (explicit label orientation, colors, padding) keeps it:
- Labels default to screen orientation (flat, upright) with a canvas-aware contrast chip, so text is legible on any background and fill — the single biggest readability win over sheared on-face text.
- A canvas padding floor gives the scene breathing room.
Contrast auto-repair (#8) still runs in the normal render path on top of this.
func ApplyTheme ¶
ApplyTheme layers the named built-in theme under whatever theme the document already carries — the programmatic form of `theme: { use: name }`, used by the CLI's --theme flag (which is how a plain .d2 graph gets the full design system). Errors on unknown names with a did-you-mean.
func CompileD2 ¶
func CompileD2(ctx context.Context, d2text string, layoutEngine LayoutEngine) (*d2target.Diagram, error)
CompileD2 runs d2's parse + compile + chosen layout on the input text and returns the laid-out d2target.Diagram. d2lib's internal layers expect a slog.Logger on the context — we attach a silent one so we don't dump warning stacks during normal renders.
func ComposeScene ¶
ComposeScene aligns off-track parts in every composite node of the doc, mutating offsets in place. Returns a human/agent-readable fix list in the RepairAndReport style.
func ConnectorBend ¶
ConnectorBend returns the current bend of the ci-th connector on the document's scene (0,0 if unset). Used to accumulate edge drags.
func EmitBackgroundDefs ¶
func EmitBackgroundDefs(defs *strings.Builder, opts *RenderOpts) string
EmitBackgroundDefs is the exported version of emitBackgroundDefs. Callers outside this package (e.g. the `topodsl wrap` subcommand) use it to splice a TopoDSL-style canvas background into externally produced SVGs (NodeDSL composites, hand-authored diagrams, etc.).
It writes <defs> entries for the chosen mode and returns the fill reference (an SVG paint expression — colour or "url(#...)") to use on the underlying full-viewBox rect.
func Flatten ¶
func Flatten(n *Node, theme *Theme) (string, iso25d.ConvertOpts)
Flatten lowers a Node + Theme into the flat iso25d.ConvertOpts surface the renderer expects. Theme is applied first, then per-shape-type defaults, then per-node Style merged on top (3-layer ResolveStyle).
func GroupHasLayout ¶
GroupHasLayout reports whether the named container arranges its children with a layout (so a child drag must first freeze that group).
func MarshalFragmentYAML ¶
MarshalFragmentYAML serializes a per-part fragment Document to YAML bytes suitable for writing to disk and re-rendering standalone.
func NodesIndexHTML ¶
NodesIndexHTML is part of the public iso-topology API.
func PartFragments ¶
PartFragments returns one round-trip-able mini-Document per atomic part — in the same id-space as RenderParts. Each fragment is itself a valid isotopo Document with a single top-level node, so the user can drop it in a file and re-render it standalone via `isotopo render`. For composite scenes we lift each CompositePart up into its own Node (recursing into groups); for non-composite docs each top-level Node is its own fragment.
func PartIDs ¶
PartIDs returns the sorted id list of every atomic part in the document, matching the keys produced by RenderParts / PartFragments. v2 — recurses into groups so children show up in the gallery.
func Rasterize ¶
Rasterize converts an SVG file to a PNG deterministically and WITHOUT cropping: the output keeps the SVG's intrinsic width/height 1:1, so what the image shows is exactly what the SVG says — the property that makes visual self-review trustworthy for agents ("look at the PNG" only works if the PNG cannot lie about the geometry).
Rasterizer discovery, in order:
- $ISOTOPO_RASTERIZER — explicit binary; invoked as `<bin> in.svg out.png` (resvg-compatible convention);
- resvg (faithful text + gradients — the recommended install);
- ImageMagick `magick` (no -trim, full viewBox);
- headless Chrome/Chromium — found via $CHROME_PATH, common binary names, or a Playwright browsers dir ($PLAYWRIGHT_BROWSERS_PATH) — so machines with only a browser installed still get pixels.
The error on total failure enumerates every option, because "snapshot needs a rasterizer" with no next step is exactly the friction this exists to kill.
func RenderDocument ¶
RenderDocument renders every node in a Document and returns a map of node-id → SVG string. The scene node (resolved via doc.Scene()) also picks up the document's Canvas and Annotations layers; all other nodes are rendered without them.
func RenderParts ¶
RenderParts produces one standalone SVG per "atomic" element in the document — the second tier of the dsl2topo output.
For composite scenes (the canonical case — both .d2 auto-layout and most YAML examples produce a single "scene" composite), each CompositePart is lifted into its own Node and rendered in isolation so callers can embed an individual icon independently. v2 — recurses into `group` parts so nested elements get their own per-part output too (otherwise grouping would hide individual nodes from the gallery).
For non-composite documents, the top-level Nodes ARE the atomic elements and this delegates to RenderDocument.
func RenderPlan ¶
func RenderPlan(n *Node, theme *Theme, canvas *Canvas, annotations []*Annotation) string
RenderPlan emits the top-down plan SVG for a scene. A nil or empty scene yields "". Non-composite single nodes render as a single footprint.
func RenderSceneWithReport ¶
func RenderSceneWithReport(doc *Document) (SceneResult, RenderReport)
RenderSceneWithReport shares the exact emitted screen/connector-label records with the report. Other report diagnostics retain their existing resolvers.
func RenderSubgraph ¶
RenderSubgraph renders a preview of a SUBSET of the document's composite scene. ids selects what to show; each entry is one of:
"<part-id>" — a part anywhere in the scene tree. A container part
(boundary / group) brings its whole subtree along.
"edge:<N>" — connector N (0-based, matching evaluate's connector
index). Pulls in the connector AND both of its endpoint
parts so the edge always has something to dock to.
A connector is included automatically whenever BOTH its endpoints land inside the selection, so previewing two connected nodes shows the wire between them. The selection is re-laid-out on its own (auto when any connector is present, else a simple row) and cropped to its own bounds, so the result is a standalone SVG independent of the rest of the scene.
err is returned for an empty selection, an unknown id, an out-of-range edge index, or a document with no composite scene.
func RenderWithCanvas ¶
func RenderWithCanvas(n *Node, theme *Theme, canvas *Canvas, anns []*Annotation) string
RenderWithCanvas is Render plus document-level canvas + annotations: the canvas controls the iso-aware background (ground grid / dots / hatch); the annotations are screen-space callouts pinned to specific composite parts via leader lines. Both layers are optional — passing nil produces exactly what Render does.
func RepairAndReport ¶
RepairAndReport runs the projection-repair loop and returns the iteration count plus a human/agent-readable list of what it cleared (occlusions that vanished, overlap pairs that were separated). Side-effect-free measurement: the defect snapshots are taken via the clone-based detectors. This is the L1 "what I fixed" report of the agent-loop harness plan.
func RepairSource ¶
RepairSource runs the projection-repair loop (RepairScene) against the document parsed from src and persists the repairs BACK into the source text, comment-preserved — closing the loop that render-time repair leaves open: without this, `render` silently fixes occlusions/overlaps/contrast in memory on every run while `validate` keeps warning about them forever, because the author's file never learns about the fix.
Mechanics: the doc is parsed twice; one copy is repaired; the two part trees are diffed field-by-field; each difference becomes a set-field edit op applied through ApplyOpText, so comments and formatting survive exactly as they do for Studio edits. By construction, loading the persisted source reproduces the repaired document state — persistence cannot behave differently from what `render` already draws today.
Only YAML sources are supported: a .d2 file's geometry is generated by auto-layout, so there is nothing stable to write a repair into.
Returns the new source (== src when nothing needed repair), the fix list from RepairAndReport, and an error only for parse/apply failures.
func RepairSourceWithOptions ¶
RepairSourceWithOptions is RepairSource with pass selection.
func ResolveAllOffsets ¶
ResolveAllOffsets runs layout on the scene and returns every ROOT-level part's resolved world (wx, wy) keyed by id. Used to bake an auto-layout scene into explicit per-node coordinates on the first manual drag, so subsequent renders never re-flow.
func ResolveChildOffsets ¶
ResolveChildOffsets runs layout and returns the resolved offsets (relative to the group) of a group's DIRECT children, keyed by id — the nested analogue of ResolveAllOffsets, used to freeze a layout group when one of its children is dragged so the rest keep their spots.
func ResolvePartGeom ¶
ResolvePartGeom returns the part's resolved width/depth/height AFTER layout. For an auto-sized container (a group with no authored geom.w/d) this is the size the solver computed to wrap its children — what the canvas actually draws — so Studio can show "auto 380" instead of a bare blank that reads as "missing". Returns ok=false if the part isn't found.
func ResolvePartOffset ¶
ResolvePartOffset returns the solved parent-relative Offset, excluding the separately authored grid Position. Text edits can add a drag/duplicate delta without baking the grid or parent's transform twice. Operates on a clone.
func SceneIsAuto ¶
SceneIsAuto reports whether the document's scene is still under connector-driven auto-layout (layout: {mode: auto}). The Studio drag endpoint uses this to decide whether a manual move must first FREEZE the scene into explicit coordinates (drawio model: once the user takes manual control, the engine stops deciding positions).
func SceneNeedsFreeze ¶
SceneNeedsFreeze reports whether the engine still decides any root-part position — a root layout of ANY mode (auto / ring / grid / row / column) or any root part positioned by `place`. The Studio drag endpoint freezes such a scene into explicit coordinates on the first manual move. A scene with no root layout and no root place is already manual — nothing to freeze.
func ThemeDescription ¶
ThemeDescription returns the one-line description of a built-in theme.
func ThemeNames ¶
func ThemeNames() []string
ThemeNames lists the built-in themes, sorted, for capabilities/docs/agents.
func TopologyHTML ¶
TopologyHTML is part of the public iso-topology API.
func WorldDropTarget ¶
WorldDropTarget returns the id of the container that a dragged node (dragID) should be reparented into when dropped, based on world-space footprint overlap — or "" if no container qualifies (drop to scene root).
Algorithm: among all containers in the model (excluding dragID and its subtree), find the one whose AABB overlaps the dragged node's AABB the most (by area). A container must overlap by at least minOverlapFrac of the dragged node's area to qualify, preventing accidental re-homes when a node merely grazes a container's edge.
This replaces the pixel-based elementsFromPoint hit-test in Studio's containerUnder(), which failed whenever the container was smaller than the node or visually occluded.
Types ¶
type AnchorPoint ¶
type AnchorPoint = render.AnchorPoint
AnchorPoint is one named connection point on a part's surface. Name matches the anchor suffix used in connector from/to (e.g. "top", "left", "right", "bottom"). WX/WY/WZ are world coordinates — the full triple is needed so the client can apply the renderer's iso projection, including height. The legacy box anchors do not describe every shape's actual surface or the renderer's resolved connector ports.
type Annotation ¶
type Annotation = model.Annotation
Annotation is a screen-space callout pinned to a composite part. It renders as a rounded text box (multi-line if Text contains '\n') with a thin leader line back to the anchor part's projected silhouette.
Anchor is the id of a CompositePart inside the document's "scene" node. Side picks which direction the box sits relative to the anchor's projected centre: "top" | "right" | "bottom" | "left" (default "right"). Distance is the world-unit gap from the part silhouette to the box (default 60).
type Backglow ¶
Backglow is the soft radial halo painted BEHIND the part's silhouette.
radius: blur radius in screen units (typical: 40–120) opacity: 0..1, defaults to 0.6 when 0
type BackgroundMode ¶
type BackgroundMode = model.BackgroundMode
BackgroundMode is the canvas backdrop style.
"transparent" — no background "solid" — flat colour rect "grid" — iso-tilted line grid (diamond pattern), classic "ground plane" "dots" — iso-tilted dot grid "hatch" — diagonal hatched fill
type BodyOcclusion ¶
type BodyOcclusion = diagnostics.BodyOcclusion
BodyOcclusion is one body-vs-body occlusion defect: Hidden's projected silhouette is painted over by Occluder (drawn later, i.e. in front), covering Frac of Hidden's silhouette area.
func BodyOcclusions ¶
func BodyOcclusions(doc *Document) []BodyOcclusion
BodyOcclusions detects body-vs-body occlusion across the document. It is an iso-only, height-induced signal: under projection: top the silhouette IS the footprint, and footprint collisions are already the overlap metric's job, so top-projection documents report none.
type Canvas ¶
Canvas is composition-level metadata for a Document. v2 extended: `grid` selects an iso-aware backdrop ("iso" = diamond rhombus lattice, "dots" = vertex dots, "hatch" = single-axis stripes, "" = none) so authors can pick the right "ground" without computing pattern math.
type Capabilities ¶
type Capabilities = catalog.Capabilities
Capabilities is the agent-facing, structured description of what this build of isotopo can express. Emitted by the `isotopo capabilities` subcommand as JSON. Lets an agent generate valid DSL without reading source code.
The capabilities are derived from runtime data (d2 shape catalog, registered primitives, layout engines) so they cannot drift from what the renderer actually accepts.
func CapabilityReport ¶
func CapabilityReport() Capabilities
CapabilityReport returns the live capability set for this build. Pure function — no IO, no globals.
type CompositePart ¶
type CompositePart = model.CompositePart
CompositePart is one sub-element of a composite node.
type CompositionFinding ¶
type CompositionFinding = diagnostics.CompositionFinding
CompositionFinding is one located, actionable observation.
type CompositionReport ¶
type CompositionReport = diagnostics.CompositionReport
CompositionReport is the per-scene aesthetic breakdown. Every sub-score is in [0,1] (1 = ideal); Score is their weighted mean. HeroDominance is nil when the scene declares no role:hero part — absence of a hero is a style choice, not a defect.
func EvaluateComposition ¶
func EvaluateComposition(doc *Document) *CompositionReport
EvaluateComposition scores the document's scene. Safe on a raw document: layout is solved on a clone, matching what the renderer paints.
type ConnectionPort ¶
type ConnectionPort = routing.ConnectionPort
ConnectionPort identifies the displayed instance, separately from its source part. Approximate marks a semantic envelope rather than a true body.
type Connector ¶
Connector is a directed line between two anchor points on different composite parts. Style follows EdgeDSL conventions (stroke colour / width / dash). The From/To strings have the form "partID" or "partID.anchor" — e.g. "central.right-mid" or just "central" (which resolves to the centre of that part).
type ConnectorArrowVisibility ¶
type ConnectorArrowVisibility = routing.ConnectorArrowVisibility
An arrow is a direction marker on the terminal route's tangent billboard: depth varies along the terminal line and is constant across its width. Its owner identifies the attachment; it does NOT exempt any body from occlusion. ClipRegion includes a guard and must clip the original polygon once.
type ConnectorAttachmentWorld ¶
type ConnectorAttachmentWorld = routing.ConnectorAttachmentWorld
ConnectorAttachmentWorld is part of the public iso-topology API.
type ConnectorAttachments ¶
type ConnectorAttachments = routing.ConnectorAttachments
ConnectorAttachments separates logical references, resolved instance/port identity, and submitted endpoint geometry. Neither a silhouette-trimmed endpoint nor a fixed contour port is a certified physical surface interface.
type ConnectorBodyCoverage ¶
type ConnectorBodyCoverage = routing.ConnectorBodyCoverage
ConnectorBodyCoverage partitions every emitted segment into ordered, disjoint [T0,T1] spans. Empty OpaqueParts means no KNOWN opaque body fill, not proven pixel visibility. UnresolvedParts identifies potentially relevant bodies for which coverage could not be established. BoundaryError is the declared polygonal curve approximation plus SVG coordinate rounding.
type ConnectorCollisionReport ¶
type ConnectorCollisionReport = routing.ConnectorCollisionReport
ConnectorCollisionReport concerns the producer's lift of the SUBMITTED centreline into world space. It does not reinterpret contour ports as physical surface interfaces, nor measure a cable radius or the screen stroke. Only a complete report with no intervals establishes no interior occupancy in the supplied supported boxes. Missing/unsupported geometry is unresolved.
type ConnectorCompositing ¶
type ConnectorCompositing = routing.ConnectorCompositing
Painter compositing avoids multiplying a foreground body's antialias coverage by a second, complementary clip. Each original primitive is drawn once. A whole-primitive order must satisfy every supported overlap; cycles and budget exhaustion retain the existing clip path. Mixed-depth bodies retain local clips and contribute ordering constraints before any SVG is committed.
type ConnectorCoverSpan ¶
type ConnectorCoverSpan = routing.ConnectorCoverSpan
ConnectorCoverSpan is part of the public iso-topology API.
type ConnectorDepthSpan ¶
type ConnectorDepthSpan = routing.ConnectorDepthSpan
ConnectorDepthSpan is part of the public iso-topology API.
type ConnectorDrawing ¶
type ConnectorDrawing = routing.ConnectorDrawing
ConnectorDrawing records what the SVG emitter submitted, in root SVG user coordinates. A quadratic has [start, control, end]; a polyline has vertices. These points are not all visible: Coverage describes only later opaque BODY FILLS at the centreline, not stroke width, dashes, text, effects, overlay labels, or true 3-D visibility. Paint order is observed, not certified correct.
type ConnectorEditSpan ¶
type ConnectorEditSpan = routing.ConnectorEditSpan
ConnectorEditSpan identifies an authored-route edit through the emitter's source mapping. T0/T1 are final-segment parameters. Only intervals without another coincident final segment are offered. Coverage and client-space hit testing further restrict these intervals; this is not a visibility claim.
type ConnectorEndpointAttachment ¶
type ConnectorEndpointAttachment = routing.ConnectorEndpointAttachment
ConnectorEndpointAttachment is part of the public iso-topology API.
type ConnectorInteriorInterval ¶
type ConnectorInteriorInterval = routing.ConnectorInteriorInterval
Segment indexes Drawing.Points, not the pre-clip route. T0/T1 bound the positive-length parameter interval in the box's open interior; face contact and isolated tangency are excluded. Source mapping, when it exists, remains in Drawing.Provenance. A derived chord needs no fictitious source mapping.
type ConnectorLabel ¶
type ConnectorLabel = routing.ConnectorLabel
ConnectorLabel is the actual rounded pill rectangle and text anchor. Its Rect is the pill envelope, not glyph ink. Optional Typography supplies the measured lines for a fully bound font. Arrow/label paint in the connector overlay, independently of the route's PaintBeforePart.
type ConnectorLabelConflict ¶
type ConnectorLabelConflict = routing.ConnectorLabelConflict
ConnectorLabelConflict identifies one counterpart in the submitted placement scope. Shortfall is measured in root SVG user units: the maximum over that counterpart's primitives of the L-infinity penetration into the forbidden centre region, including the 6-unit clearance gap. It is not painted overlap area or a solution for moving the whole label/route.
type ConnectorLabelRecord ¶
type ConnectorLabelRecord = routing.ConnectorLabelRecord
ConnectorLabelRecord identifies a measured label in either projection. The index is the scene's connector index; it is not a persistent authored ID.
type ConnectorPenetration ¶
type ConnectorPenetration = routing.ConnectorPenetration
ConnectorPenetration is part of the public iso-topology API.
type ConnectorProvenance ¶
type ConnectorProvenance = routing.ConnectorProvenance
ConnectorProvenance is produced alongside path transformations, before SVG rounding. SourceSpace identifies the input to those transformations: either the collected pre-clip polyline or the analytic pre-clip quadratic (NOT the sampled World3D track). It does not refer to authored waypoint indexes.
type ConnectorRoute ¶
type ConnectorRoute = routing.ConnectorRoute
ConnectorRoute records the editable pre-clip route and the final submitted drawing of one composite connector in the same render pass.
World holds the route's ground-plane corners (wx, wy) in the same world frame as the plan footprints, source→target, PRE-clip — for orthogonal routes these are exactly the corners serialized into the data-route attribute. Straight connectors record their two anchor points; bezier connectors record a fixed-step polyline sampled along the drawn quadratic (inverse-projected back to world), so the evaluator finally scores the curve that is actually painted.
Screen holds the matching pre-clip screen-user coordinates, parallel to World (same length, same order).
func RenderWithRouteInfo ¶
func RenderWithRouteInfo(n *Node, theme *Theme, canvas *Canvas, anns []*Annotation) (string, []ConnectorRoute)
RenderWithRouteInfo is RenderWithCanvas plus WS-E's in-memory record of every rendered connector's pre-clip tracks and final submitted path/opaque body coverage (see ConnectorRoute in routecollect.go). The SVG string is byte-for-byte identical to RenderWithCanvas — collection is pure observation — so this is the structured replacement for regexing data-route out of the output. Non-composite nodes and the top-down plan projection carry no iso connector layer and return nil routes.
type ConnectorSegmentProvenance ¶
type ConnectorSegmentProvenance = routing.ConnectorSegmentProvenance
Kind is source, derived, or unresolved. Only source has an exact Source parameter mapping. Derived terminal shortcuts have their own world chord; Ancestors records inputs, not a parameter mapping to that chord. Unresolved paths retain ancestry but omit World. World is a pair of linear endpoints or three quadratic controls. ProjectionError bounds the distance between that world's projection and the submitted, rounded path in SVG user units.
type ConnectorSourceInterval ¶
type ConnectorSourceInterval = routing.ConnectorSourceInterval
ConnectorSourceInterval maps a final segment's t in [0,1] to T0+t*(T1-T0) on the specified pre-clip source segment.
type ConnectorSpatialVisibility ¶
type ConnectorSpatialVisibility = routing.ConnectorSpatialVisibility
ConnectorSpatialVisibility reports a physical depth decision separately from legacy painter coverage. Compositing draws each original primitive once, preserving gradient, dash phase, round joins and identity. ClipRegion describes geometric visibility; Compositing reports the actual paint policy. Scope covers supported opaque surfaces and solid round face borders, with a billboard-width stroke convention. It does not certify body/body order, labels, filters or alpha compositing. A fallback retains the old SVG bytes.
type ConnectorTypography ¶
type ConnectorTypography = routing.ConnectorTypography
ConnectorTypography is available only when the complete label binds to an embedded font. Placement describes clearance against the declared envelopes, not visibility of every scene pixel or global placement optimality.
type Content ¶
Content is the structural payload for shapes whose visual is composed of rows or cells. Header lands on the top face; Rows are drawn on the front-right face with one row per band. Cells (v1.3) is a 2D grid drawn on the TOP face (iso-tilted via the top matrix).
type ContentFitObservation ¶
type ContentFitObservation = diagnostics.ContentFitObservation
ContentFitObservation locates a resolved instance's final top-face layout. PartIndex is the index after group/stack lowering, not an authored array index. Path points to the authored part when an unambiguous ID is available, otherwise to its node. No automatic source patch is implied.
func ContentFits ¶
func ContentFits(doc *Document) []ContentFitObservation
ContentFits returns bounded top-face layout observations in deterministic node/instance order without mutating the author document. Free captions and other unsupported shapes remain explicitly unsupported; the separate plan renderer has no observations here. Each item identifies its measurement; these observations do not certify legibility or visibility.
type Direction ¶
Direction is the tail/arrow orientation for callout / step.
callout.tail ∈ {"down", "up", "left", "right"} (default: "down")
step.arrow ∈ {"right", "left"} (default: "right")
type Document ¶
Document bundles a Canvas + Theme + Nodes. This is the canonical top-level shape of a NodeDSL .yaml or .json file.
func LoadInput ¶
func LoadInput(ctx context.Context, format string, data []byte, layoutEngine LayoutEngine) (*Document, error)
LoadInput parses diagram source of the given format ("yaml", "json", or "d2") into a Document. YAML and JSON parse directly; d2 compiles through the given layout engine (LayoutDagre when engine is empty) and translates the laid-out diagram.
func Parse ¶
Parse picks YAML or JSON by sniffing the leading non-whitespace byte: '{' or '[' → JSON, anything else → YAML.
func RepairScene ¶
RepairScene is the Phase-1 projection-repair loop (docs/design/layout-engine- master-plan.md): it measures the rendered scene and locally repairs the defects that only exist in the projected output, re-checking each round until the scene is clean or a budget is hit — "optimize in the space you render". Repaired defect classes:
- caption clearance: a group label ridden by its front-most child → widen the group's front padding;
- node overlap: two sibling footprints collide — at the top level AND (WS-G) inside each group — → push them apart;
- routing (WS-G): an orthogonal connector crossing another edge or tunnelling a node → escalate it to routing:"orthogonal2", kept only on strict measured improvement (repair_routing.go).
It is a strict no-op on an already-clean scene (0 iterations, byte-identical output), so it is safe to run unconditionally. Returns the doc and iteration count.
func Translate ¶
func Translate(diagram *d2target.Diagram, opts *RenderOpts) *Document
Translate converts a laid-out d2 diagram into an isotopo Document whose single composite "scene" node holds all d2 shapes as parts and all d2 connections as connectors. The (X, Y) layout coords become world (wx, wy) on the z=0 plane; per-shape extrusion is picked by the d2ShapeCatalog height multiplier.
d2 source-level containers (foo.bar or "foo: { bar; }") become iso `group` CompositeParts, with children listed in their `parts`. Connector ids reference the dot-separated d2 path so nothing in the connector translation needs special-casing.
type DropShadow ¶
type DropShadow = model.DropShadow
DropShadow describes a Gaussian-blurred offset shadow under the part.
dx, dy: offset in screen units (positive y = down)
blur: Gaussian stdDeviation (0 = crisp)
color: any CSS colour; rgba("...") gets you semi-transparent shadows
type EditOp ¶
EditOp describes one direct-manipulation edit. It mirrors the operations the Studio canvas produces; Kind selects which fields are read.
move — Target node|edge + DWX/DWY world drag delta (+ Snap grid step,
or Waypoints for a drawio-style per-segment edge edit)
move-segment — CI + Segment (pre-clip route index) + DWX/DWY: move an
orthogonal leg, preserving world Z and docked endpoints.
move-multi — IDs + DWX/DWY: apply the SAME world delta to every listed node
in ONE text surgery (Studio group-move). Atomic: any id that
fails aborts the whole op and the source is returned unchanged.
set-field — Target node|edge|canvas + Fields: dotted YAML path → value
add — append a default rectangle part to the scene
delete — Target node|edge (a node also drops its connectors)
delete-multi — IDs: delete every listed node in one atomic surgery
duplicate — Target node: clone it with a fresh id, offset down-right
type EffectItem ¶
type EffectItem = model.EffectItem
EffectItem is one entry in an ordered effects pipeline (style.effects list). Kind is one of: backglow | blur | grain | outline | dropShadow. Parameters mirror the flat Effect sub-structs but are unified here so a single list can hold any mix of effects in author-controlled order.
type Effects ¶
Effects holds compositional knobs that aren't tied to a single face. v2.1 — DropShadow / Backglow / Pattern lift the existing iso25d-internal features into the DSL so authors and agents can opt into them.
type FaceGradient ¶
type FaceGradient = model.FaceGradient
FaceGradient is a linear gradient applied to one iso face.
from: start colour (any CSS colour, e.g. "#FFE188" or "rgba(...)") to: end colour dir: "down" (default) | "up" | "left" | "right" | "diag"
type FacePattern ¶
type FacePattern = model.FacePattern
FacePattern is part of the public iso-topology API.
type FaceStyle ¶
v3.3 (M3) — per-face surface overrides: style.faces maps a face name ("top" / "left" / "right", prism "side0".."sideN", or "*" wildcard) to a fill + stroke-layer description that outranks style.palette.
type Field ¶
Field is one editable, visually-impactful DSL field — one row of the Studio detail form. Fields() returns a slice of these for an element, each with its current Value, an effective-value hint (Eff) for inherited/computed fields, and an Empty placeholder for genuinely-unset ones.
func LocalizeFields ¶
LocalizeFields returns a copy of fs with the visible copy localized for the Studio UI language. lang=="zh" translates everything; otherwise the English group keys are tidied into friendly titles. The input is not mutated.
type Geom ¶
Geom is the local-frame box dimensions used by the iso projection. Sides is consumed only by `shape: polygon` — number of sides for the polygonal prism (3 = triangular, 5 = pentagon, 8 = octagon, etc.).
type Grain ¶
Grain overlays monochrome film-grain noise on the part's faces — the "risograph / print" texture. Intensity 0..1 (how visible), Scale = noise frequency (default 0.8; smaller = coarser speckle).
type IconCap ¶
IconCap is one entry in the agent-facing icon catalog (SVG body excluded — too large for the capabilities payload; see docs/agent/ICONS.md for previews).
type InputFormat ¶
type InputFormat = catalog.InputFormat
InputFormat describes one file extension the CLI accepts.
type IsoReport ¶
type IsoReport = diagnostics.IsoReport
IsoReport is the iso scorecard: the shared PlanReport plus iso-only extras.
type IsoRouteCrowding ¶
type IsoRouteCrowding = routing.IsoRouteCrowding
IsoRouteCrowding observes submitted connector geometry after known opaque fills in the actual painter order (or explicit experimental body-depth clips), before connector/connector and text compositing. Long near parallel strokes and arrow contacts hinder following distinct relationships; ordinary transverse stroke crossings are outside this scope. This is a conservative geometric clearance observation, not a pixel visibility proof.
type Issue ¶
Issue is one structural problem found by Validate. Path is a JSONPath-style locator (e.g. "nodes.scene.parts[3].shape"); Message is one line; Suggest is the closest valid value when relevant.
Designed for agent self-correction: an agent reads JSON-serialized Issues, finds the path, applies the suggestion, and re-validates — no human in the loop.
func ApplyOp ¶
ApplyOp applies a direct-manipulation edit to DSL text and re-renders it: newSrc is the rewritten document (comments and formatting preserved), svg and issues are RenderSource of that result. The operation is stateless — newSrc is a pure function of (format, src, op). err is non-nil only when the op itself can't be applied (e.g. the target id isn't in the source).
func ContainerFitIssues ¶
ContainerFitIssues warns when a child's EFFECTIVE footprint exceeds 90% of a fixed-size parent container on either axis — the "child bursting its tray / child nearly as big as its parent" defect. It reads the authored tree (auto containers have no fixed size yet) and uses partFootprint, so a clamped shape like a cloud (rendered floor 200×140) is measured at its true drawn size, not its smaller authored geom.
func ContentFitIssues ¶
ContentFitIssues reports estimated budget overflow as a warning, including intentional authored placements. Unknown font ink is not a structural error.
func LabelOcclusionIssues ¶
LabelOcclusionIssues warns when text is covered by a later-painted node in the rendered view. It covers three kinds of text:
- group labels, whose silent auto-lift (resolveGroupLabelOcclusion) would otherwise swallow the defect — a caption floating over a node body still reads as cramped;
- iso_text titles;
- ordinary node face labels (the default top-face label), which have no auto-lift at all: a node painted in front simply hides them.
Labels with text.orient: screen are drawn on the top screen layer and can never be occluded by a node body, so they are skipped — which is why the theme is threaded through (orient is often set theme-wide).
func MarkRepairable ¶
MarkRepairable flags every issue in `before` that no longer appears in `after` (the validation of a repaired clone) as auto-repairable, so agents and humans can tell "this warning will be fixed by `isotopo repair --write` (and is already auto-fixed at render time)" apart from issues that need a hand edit. Matching is exact on severity+path+message.
func PlanFootprintIssues ¶
PlanFootprintIssues flags parts whose TOP-DOWN (plan) projection footprints touch, cross, or cover one another. Where VisualLint (lint.go) reports 3-D world interpenetration — solids occupying the same physical space across containers — this looks at the flat plan view the `evaluate`/Plan renderer draws: height is dropped, every part is its (x, y, w, d) footprint rectangle, and any two rectangles that meet are a defect.
In the plan view two boxes sharing screen space read as broken regardless of their z, so the rule covers BOTH leaf nodes and group/container slabs. The one legitimate "overlap" — a child sitting inside its own group (or any ancestor) — is excluded by ancestry; stack replicas that share space by design are excluded too. boundary zones (dashed trust regions meant to wrap nodes) and iso_text labels carry no solid footprint and are skipped.
Everything is a Warning: an intentional isometric stair/stack legitimately overlaps in plan, so a hit is a strong "look at this" signal, not a hard stop.
func RenderSource ¶
RenderSource validates and renders a DSL document to one topology SVG. Parse and validation errors are returned as Issues (with an error-severity entry), not as err — err is reserved for future I/O paths and is currently always nil. The layout engine is the default (dagre); d2 auto-layout honours it, YAML/JSON have no layout step.
func RoundedSideIgnoredIssues ¶
RoundedSideIgnoredIssues warns when an explicit solid palette.right is set on a part that renders ROUNDED (cornerRadius >= the band threshold, including the default-rounded group/boundary slab). The rounded renderer (iso25d/rounded.go) collapses the two side walls into one band whose colour comes from top + left (left = the band's bottom stop); it never reads the solid right face — so a right colour the author set is silently dropped. This is the negative feedback for that footgun: set cornerRadius:0 for distinct left/right faces, or fold the colour into palette.left / a side gradient.
func UnknownKeyIssues ¶
UnknownKeyIssues strict-decodes the YAML source and reports keys that match no struct field — the misspellings (style.palett, geom.with, effects. cornerRadious) that a lenient decode silently drops, the single largest class of invisible agent mistakes. Each is a warning (the document still renders, just missing that key's effect) carrying the source line and a nearest-field suggestion.
Returns nil for JSON or anything that isn't a clean YAML type-mismatch (Parse already reports true syntax errors); this is a purely additive lint over otherwise-valid YAML, so it never blocks a render.
func VisualContrastIssues ¶
VisualContrastIssues checks colour contrast ratios:
- top face fill vs label text colour (< 3.0 → warning)
- top face fill vs canvas background (< 1.5 → warning)
- group/boundary top fill vs direct child top fill (< 1.3 → warning)
- iso:// icon with default ink on a dark top fill (luminance < 0.18, no /light or /RRGGBB suffix → warning)
It also appends cloudFaceIssues — the cloud-specific "right face is dropped" lint — so cloud styling feedback rides the same wired entry point.
func VisualLint ¶
VisualLint catches geometry problems pure structural validation can't: after solving layout/place into concrete positions, it flags atomic parts in DIFFERENT containers whose 3-D solids interpenetrate. The same-container case is already covered by the layout solver's sibling-overlap check; this adds the cross-container collisions — a `place`/`offset` that lands one group's part inside another group's part — that the sibling check structurally cannot see.
It reports WORLD-space interpenetration, not iso screen-overlap: two solids occupying the same physical space is always a mistake, whereas parts that merely overlap on screen are usually intentional depth layering. That keeps the lint quiet on well-formed scenes — it stays silent on every bundled sample — so an agent can treat a hit as a real "fix this" signal.
type IssueDiff ¶
type IssueDiff = diagnostics.IssueDiff
IssueDiff summarises what changed between two Validate calls.
func DiffIssues ¶
DiffIssues compares two issue lists (before and after an edit). Issues are matched by (Path, Message) pair.
type Layout ¶
Layout arranges a container's parts along the iso ground axes so the author never computes coordinates. All lengths are in CELLS — one cell = the document's grid step (node.gridStep, else canvas.gridStep, else 40 world units) — so arranged parts stay in register with the canvas grid texture and with orthogonal connector channels.
type LayoutEngine ¶
type LayoutEngine = d2input.LayoutEngine
LayoutEngine selects which d2 layout engine to use.
"dagre" — fast, natural-bend polyline edges (default; what most d2 docs use)
"elk" — Eclipse Layout Kernel, defaults to ORTHOGONAL right-angle edge
routing with obstacle avoidance
type Outline ¶
Outline is a silhouette-following accent stroke (emphasis / selection ring). Unlike per-face strokes it traces the whole projected outline.
type Palette ¶
Palette assigns the three iso-face fills. Each face may be either a solid colour (Top / Left / Right) or a linear gradient (TopGradient etc.); when a gradient is set it OVERRIDES the matching solid fill.
type PartModel ¶
PartModel describes one source part after layout resolution. Boxes and anchors use world units; SelectionRegions use projected world coordinates.
func BuildInteractionModel ¶
BuildInteractionModel returns the world-space geometry for every part in the document's composite scene, after layout resolution. Returns nil when the document has no composite scene.
The caller should embed the result in the render-response JSON under the key "model" so Studio can read it without a separate round-trip.
type Patch ¶
type Patch = diagnostics.Patch
Patch is a declarative, machine-applicable DSL edit that clears a defect.
type Pattern ¶
Pattern is a repeating texture overlay on the top face. Use to suggest "data surface" or "mesh" without drawing per-pixel content.
kind: "hatch" | "dots" | "grid" spacing: distance between repeats in local units (default ~10) angle: degrees, only relevant for hatch (default 0)
type Place ¶
Place positions a part relative to a sibling's footprint. Give one constraint per axis: RightOf/LeftOf pin world x, InFrontOf/Behind pin world y ("front" = toward the viewer = +y, "behind" = away = -y), Above pins world z (the part sits ON TOP of the sibling — z = sibling.z + sibling.h). With an axis unconstrained, it aligns to the referenced sibling per Align. Gaps are in cells (default 1); GapX/GapY override Gap per ground axis. Above is flush (no gap).
type PlanEdgeIssue ¶
type PlanEdgeIssue = quality.PlanEdgeIssue
PlanEdgeIssue flags one edge that tunnels through unrelated node footprints.
type PlanLabel ¶
PlanLabel describes a submitted top-projection node title. PartIndex is the preorder footprint index (containers included, stacks collapsed). Budget and ink use final SVG user coordinates. Status certifies only budget containment, not visibility against other scene objects. Unmeasured legacy titles have no invented ink geometry and report the font actually requested by their SVG.
type PlanLabelConflict ¶
type PlanLabelConflict = routing.PlanLabelConflict
PlanLabelConflict is part of the public iso-topology API.
type PlanLabelLine ¶
type PlanLabelLine = routing.PlanLabelLine
SourceLine is the zero-based authored newline index. Concatenating fragments of each source line preserves every character, including whitespace.
type PlanLabelPlacement ¶
type PlanLabelPlacement = routing.PlanLabelPlacement
PlanLabelPlacement describes clearance within a declared geometric scope. It is separate from fitting inside the owner budget. Conflicts are populated by detailed reports; absent conflicts in an ordinary preview are not proof.
type PlanReport ¶
type PlanReport = quality.PlanReport
PlanReport is the layout-quality scorecard. Lower is better for every count; a clean DAG layout scores Crossings=0, EdgesThroughNodes=0, BackwardEdges=0, NodeOverlaps=0.
func EvaluateIso ¶
func EvaluateIso(n *Node, theme *Theme, canvas *Canvas) *PlanReport
EvaluateIso scores the scene using the engine's real connector routes: orthogonal, straight AND bezier geometry all come from the in-memory collector, so the score measures exactly what is painted. Node footprints are the same applyLayout output.
func EvaluateIsoText ¶
func EvaluateIsoText(format string, src []byte) (*PlanReport, error)
EvaluateIsoText parses a document and scores the iso engine's real routing.
func EvaluatePlan ¶
func EvaluatePlan(n *Node, theme *Theme, canvas *Canvas) *PlanReport
EvaluatePlan computes the scorecard from a scene's flat geometry.
func EvaluatePlanText ¶
func EvaluatePlanText(format string, src []byte) (*PlanReport, error)
EvaluatePlanText parses a document and scores its plan-view layout.
func RenderPlanAnnotated ¶
func RenderPlanAnnotated(n *Node, theme *Theme, canvas *Canvas) (string, *PlanReport)
RenderPlanAnnotated renders the plan view with every crossing and tunnelling edge highlighted in red, and returns the scorecard alongside it.
type PlanRouteConflict ¶
type PlanRouteConflict = quality.PlanRouteConflict
PlanRouteConflict is part of the public iso-topology API.
type PlanRouteCrowding ¶
type PlanRouteCrowding = quality.PlanRouteCrowding
PlanRouteCrowding observes final submitted plan routes. Envelopes include a six-unit reading gap, continuous coverage of dash gaps, square cap bounds, and the actual triangle marker. Opaque leaf cores and bounded shared docks are removed. This is a conservative clearance observation, not pixel area. Only complete status with no conflicts establishes clearance in this scope.
type PrimitiveCap ¶
type PrimitiveCap = catalog.PrimitiveCap
PrimitiveCap describes one DSL composition primitive (group / stack / annotation / canvas-grid / ...) — the recipe an agent uses to express layered, repeated, or annotated structure.
type ReadabilityReport ¶
type ReadabilityReport = diagnostics.ReadabilityReport
ReadabilityReport is the per-scene breakdown plus the scalar score R∈[0,1].
func Readability ¶
func Readability(doc *Document) ReadabilityReport
Readability scores a parsed document. It is safe on a raw (unsolved) doc: the sub-calls each solve layout on a clone, matching what the renderer paints.
type RenderOpts ¶
type RenderOpts = model.RenderOpts
RenderOpts configures the iso rendering pipeline. Zero values fall back to the defaults from DefaultRenderOpts().
func DefaultRenderOpts ¶
func DefaultRenderOpts() *RenderOpts
DefaultRenderOpts is part of the public iso-topology API.
type RenderReport ¶
type RenderReport = diagnostics.RenderReport
RenderReport is the single payload emitted by `render --report`.
func BuildRenderReport ¶
func BuildRenderReport(doc *Document) RenderReport
BuildRenderReport assembles the report for the current scene state: R plus breakdown, and every label/caption occlusion located — with a padding patch attached to each in-group caption-ride (the value the repair loop converges to, so applying it is guaranteed to clear the ride).
type RepairOptions ¶
type RepairOptions = editing.RepairOptions
RepairOptions selects which repair passes run beyond the always-on defect loop. Compose additionally runs the composition pass (ComposeScene): bounded alignment snapping of explicitly-offset parts onto their neighbours' tracks — the acting half of the evaluate `composition` block.
type ReportDefect ¶
type ReportDefect = diagnostics.ReportDefect
ReportDefect is one defect, located, with a fix where we can generate a reliable one.
type SceneResult ¶
type SceneResult = render.SceneResult
SceneResult is a single render's submitted SVG, connector geometry and screen-label geometry. It does not yet replace the separate body, top-face budget or isometric world interaction resolvers. Empty ScreenLabels is authoritative for this layer; the plan renderer has no isometric screen-label layer.
func RenderScene ¶
func RenderScene(doc *Document) SceneResult
RenderScene collects screen labels at their producer, after obstacle placement and at the SVG emitter's precision. Collection never changes SVG bytes and does not parse geometry back out of the SVG or rerun placement.
func RenderSceneWithInteraction ¶
func RenderSceneWithInteraction(doc *Document) SceneResult
RenderSceneWithInteraction returns the preview and its world interaction model together. Plan geometry and final title placement are resolved once and shared; iso interaction retains its established body/content resolver. Each call owns its result, including the nested selection and port slices.
type ScreenLabel ¶
type ScreenLabel = typography.ScreenLabel
ScreenLabel identifies one emitted label in layer order. PartIndex is the lowered geometry index, not an authored source array index. PartID retains the emitted instance identity; anonymous parts do not invent source IDs.
type ScreenLabelLine ¶
type ScreenLabelLine = typography.ScreenLabelLine
Text is the emitted text node's content. In an estimated legacy label the browser still applies normal SVG whitespace collapsing. InkBounds/Advance are available only for a fully bound block; a known blank line has no ink.
type ScreenLabelRect ¶
type ScreenLabelRect = typography.ScreenLabelRect
ScreenLabelRect uses final SVG user coordinates, before any browser viewBox scale, CSS transform or live drag. ScreenLabel.Bounds is the emitted pointer hit rect; line InkBounds is measured glyph geometry, not a visibility mask or the chip border's stroke bounds.
type Severity ¶
Severity is how loud an Issue is. Errors mean the document won't render correctly; warnings mean it'll render but probably not how the author intended.
type ShapeCap ¶
ShapeCap describes one shape the iso renderer can lower.
AcceptedAs lists every alias an agent can use (d2 dsl + native iso names + snake/hyphen variants). HeightHint is the default extrusion multiplier — agents don't usually need to think about it but it's surfaced so they can pick when the answer should be "flat" or "tall".
type Stack ¶
Stack tells the renderer to replicate a composite part vertically. Count = total number of layers (1 is a no-op). Gap = world Z step between layers. If Gap <= 0 we use the part's own H + a small margin so layers visually sit ON TOP of each other rather than overlap.
type StrokeLayer ¶
type StrokeLayer = model.StrokeLayer
StrokeLayer is part of the public iso-topology API.
type Style ¶
Style groups every visual knob. Each sub-block is a pointer so the merge step can distinguish "explicitly empty" from "inherit from parent".
func MergeStyle ¶
MergeStyle returns a new Style whose fields come from `over` when present, otherwise from `base`.
func ResolvePartStyle ¶
ResolvePartStyle returns the fully-resolved style (theme → shape default → preset → node overrides) for the part with the given id — i.e. exactly what the renderer paints — or nil if no such part exists. Studio uses it to show the EFFECTIVE colour of a face whose colour is inherited from a preset/theme or expressed as a gradient, where the raw node YAML carries nothing.
func ResolveStyle ¶
ResolveStyle applies the canonical four-layer merge for a node:
theme.Style (document-wide defaults) theme.Shapes[shape] (per-shape-type defaults — optional) theme.Presets[preset] (named design-system preset — optional, v2.5) nodeStyle (per-node overrides — optional)
Kept as the role-less form for API compatibility; parts with a semantic role resolve through ResolveStyleWithRole.
func ResolveStyleWithRole ¶
func ResolveStyleWithRole(theme *Theme, shape string, role string, preset string, nodeStyle *Style) *Style
ResolveStyleWithRole is ResolveStyle plus the semantic-role layer:
theme.Style → theme.Shapes[shape] → theme.Roles[role] → theme.Presets[preset] → nodeStyle
The role sits below preset/style so `role:` supplies the theme's design- system look while an explicit `preset:` or `style:` still wins per part.
type StyleKeyGroup ¶
type StyleKeyGroup = catalog.StyleKeyGroup
StyleKeyGroup describes one style sub-block (Palette, Stroke, Text, Effects) so an agent can fill them out correctly.
type Text ¶
Text controls the label rendered on the top face. Orient picks how the label is composed:
"" / "iso" — default. Label sits inside the top face, tilted onto
the iso plane via a matrix transform.
"screen" — label is rendered as a horizontal box BELOW the part's
projected bounding box. Background and border are read
from BoxBg / BoxBorder; otherwise transparent.
Composite-only: takes effect on CompositePart entries.
type Theme ¶
Theme is the document-level default Style plus optional per-shape-type defaults. Resolution order for any node:
theme (base) → theme.shapes[node.Shape] → node.Style
Each step is a field-level merge: later non-empty fields override earlier ones; nil sub-blocks inherit.
type WorldPoint ¶
type WorldPoint = model.WorldPoint
WorldPoint is a point in iso world coords (wx, wy, wz). Used for both composite offsets and node anchors.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
isotopo
command
Command isotopo — DSL → iso topology renderer.
|
Command isotopo — DSL → iso topology renderer. |
|
isotopo-mcp
command
isotopo-mcp is a Model Context Protocol (MCP) server exposing the iso-topology agent loop as seven tools — iso_capabilities, iso_validate, iso_evaluate, iso_repair, iso_render, iso_preview, iso_snapshot — over the stdio transport, so MCP clients (Claude Code, Claude Desktop, Cursor, …) can draw and self-correct isometric diagrams without shelling out to the CLI.
|
isotopo-mcp is a Model Context Protocol (MCP) server exposing the iso-topology agent loop as seven tools — iso_capabilities, iso_validate, iso_evaluate, iso_repair, iso_render, iso_preview, iso_snapshot — over the stdio transport, so MCP clients (Claude Code, Claude Desktop, Cursor, …) can draw and self-correct isometric diagrams without shelling out to the CLI. |
|
isotopo-playground
command
|
|
|
internal
|
|
|
Brand-icon resolver: turn an "iso://brand/<name>" URI into a self-contained data-URI SVG so authors can write
|
Brand-icon resolver: turn an "iso://brand/<name>" URI into a self-contained data-URI SVG so authors can write |
|
Package studio owns the embedded, self-contained browser UI.
|
Package studio owns the embedded, self-contained browser UI. |
|
Package textmetrics is the repo's single source of truth for font-engine-free text width estimation.
|
Package textmetrics is the repo's single source of truth for font-engine-free text width estimation. |
|
Package themes owns the built-in theme source files.
|
Package themes owns the built-in theme source files. |
|
tools
|
|
|
gen-discovery
command
gen-discovery generates the public Mintlify discovery files from docs.json.
|
gen-discovery generates the public Mintlify discovery files from docs.json. |
|
gen-doc-images
command
gen-doc-images renders the maintained documentation gallery from source.
|
gen-doc-images renders the maintained documentation gallery from source. |
|
gen-docs
command
gen-docs writes two agent-facing files from the live capability surface so they can't drift from code:
|
gen-docs writes two agent-facing files from the live capability surface so they can't drift from code: |
|
import-icons
command
import-icons vendors a curated subset of Simple Icons (https://simpleicons.org, CC0-1.0) into iso25d/icons/si/ so the renderer can embed real brand logos offline.
|
import-icons vendors a curated subset of Simple Icons (https://simpleicons.org, CC0-1.0) into iso25d/icons/si/ so the renderer can embed real brand logos offline. |
|
visreg
command
visreg — pixel-level visual regression over the golden SVGs.
|
visreg — pixel-level visual regression over the golden SVGs. |
|
Package yamledit performs comment-preserving text surgery on the topology YAML/d2 source.
|
Package yamledit performs comment-preserving text surgery on the topology YAML/d2 source. |
