Skip to content
D
Documentation

Models — constants

reference
1 min readUpdated

Constants

Import these from @grafloria/engine.

Constants

DEFAULT_GROUP_HEADER_HEIGHT

ts
const DEFAULT_GROUP_HEADER_HEIGHT: 24

DEFAULT_GROUP_PADDING

Defaults for groups AUTHORED in code (constructor path). A fitted frame needs breathing room and a title band or its label lands under the first member. Loaded documents are exempt: restore assigns the stored values (padding verbatim — possibly undefined, which getPadding() resolves to 0 — and headerHeight number-or-0), so legacy geometry is byte-stable.

ts
const DEFAULT_GROUP_PADDING: 16

DEFAULT_PORT_SNAP_RADIUS

How near a port must be to a point for {@link DiagramModel.findNearestPort} to consider it, in world units. Roughly a fingertip at 100% zoom.

ts
const DEFAULT_PORT_SNAP_RADIUS: 24

DEFAULT_SIMPLIFY_EPSILON

Douglas-Peucker tolerance, in WORLD units.

0.6 is tuned against real traces: below ~0.4 you keep the sensor jitter you were trying to remove; above ~1.2 a deliberate small loop (the dot of an "i", a tick) starts to visibly flatten. At 0.6 a 500-point scribble lands around 40-70 points and is indistinguishable from the raw trace at 100% zoom.

It is world-space, so ink drawn while zoomed OUT is simplified more aggressively in screen terms — which is right: you cannot see detail you did not draw.

ts
const DEFAULT_SIMPLIFY_EPSILON: 0.6

DEFAULT_STROKE_STYLE

ts
const DEFAULT_STROKE_STYLE: StrokeStyle

LINK_LABEL_SLOT_POSITIONS

Where each of the three edge label SLOTS sits along the path.

Pulled IN from the endpoints on purpose: at exactly 0 and 1 a slot label would land under the arrowhead and on top of the port. 0.12 / 0.88 clears both while still reading as "at the start / at the end of this edge".

ONE definition, shared by the model (LinkModel.addLabel), the renderer (LabelRenderer) and the edge optimizer — three places that must never disagree about where a label actually is.

ts
const LINK_LABEL_SLOT_POSITIONS: Record<'start' | 'center' | 'end', number>

Was this page helpful?

Models — constants — Grafloria