1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//! Layout and styling constants for the flowchart renderer.
// ---------------------------------------------------------------------------
// Typography
// ---------------------------------------------------------------------------
/// Default font size for node labels (px).
pub const FONT_SIZE: f64 = 16.0;
/// TEXT_SCALE: browser renders Arial 16px ~11.7% wider than ab_glyph raw metrics.
/// Now using monospace (Courier New) metrics via measure_mono.
pub const TEXT_SCALE: f64 = 1.117;
// ---------------------------------------------------------------------------
// Node geometry
// ---------------------------------------------------------------------------
/// Height of a standard rectangular node (px).
pub const RECT_H: f64 = 54.0;
/// Height of compact nodes: Stadium, Subroutine, Asymmetric (px).
pub const COMPACT_H: f64 = 39.0;
/// Horizontal padding (each side) for Rectangle / Default nodes (px).
pub const H_PAD: f64 = 30.0;
/// Horizontal padding (each side) for RoundedRect and Stadium nodes (px).
pub const SMALL_PAD: f64 = 15.0;
/// Horizontal padding (each side) for Diamond and Hexagon nodes (px).
pub const DIAMOND_PAD: f64 = 27.0;
/// Total horizontal padding for Subroutine nodes (inner pad + line offsets, px).
pub const SUBROUTINE_H_PAD: f64 = 38.0;
/// Inset from the left/right edge for the decorative vertical lines on Subroutine nodes (px).
pub const SUBROUTINE_LINE_INSET: f64 = 6.0;
/// Total horizontal padding for Asymmetric nodes (base pad, px).
pub const ASYMMETRIC_BASE_PAD: f64 = 20.0;
/// Depth of the V-notch on the left side of an Asymmetric node (px).
pub const ASYMMETRIC_NOTCH_DEPTH: f64 = 10.0;
/// Minimum radius for a Circle node (px).
pub const CIRCLE_MIN_RADIUS: f64 = 27.0;
/// Extra padding added to the text half-width to compute the Circle radius (px).
pub const CIRCLE_LABEL_PAD: f64 = 7.5;
/// Horizontal padding for Cylinder nodes (px).
pub const CYLINDER_H_PAD: f64 = 16.0;
/// Fraction of the half-width used as the ellipse ry for Cylinder nodes.
pub const CYLINDER_RY_FACTOR: f64 = 0.24;
/// Minimum ellipse ry for Cylinder nodes (px).
pub const CYLINDER_MIN_RY: f64 = 7.0;
/// Body height of a Cylinder node, excluding the top/bottom ellipses (px).
pub const CYLINDER_BODY_H: f64 = 49.0;
// ---------------------------------------------------------------------------
// Label geometry
// ---------------------------------------------------------------------------
/// Height of a `<foreignObject>` label box (px).
pub const LABEL_FO_HEIGHT: f64 = 24.0;
/// Y-offset applied to the label `<g>` element (= -LABEL_FO_HEIGHT / 2, px).
pub const LABEL_Y_OFFSET: i32 = -12;
/// Y-offset for Cylinder node labels, which sit lower to centre in the body (px).
pub const CYLINDER_LABEL_Y_OFFSET: i32 = -2;
/// Y baseline for plain SVG `<text>` node labels, relative to the group origin (px).
pub const TEXT_LABEL_Y: i32 = 5;
/// Y offset added to the cluster-rect top to position the plain-text cluster label (px).
pub const CLUSTER_LABEL_TEXT_DY: f64 = 14.0;
// ---------------------------------------------------------------------------
// Layout / dagre parameters
// ---------------------------------------------------------------------------
/// Graph margin on each axis (marginx = marginy, px).
pub const GRAPH_MARGIN: f64 = 8.0;
/// 2 × GRAPH_MARGIN: added to a subgraph's cluster-rect size to get the full group size.
pub const SG_LAYOUT_MARGIN: f64 = 16.0;
/// Node separation used by dagre for all layout levels (px).
pub const NODE_SEP: f64 = 50.0;
/// Rank separation for the outermost dagre layout (px).
pub const OUTER_RANKSEP: f64 = 50.0;
/// Amount added to the ranksep at each recursive subgraph layout level (px).
pub const RANKSEP_INCREMENT: f64 = 25.0;
// ---------------------------------------------------------------------------
// Edge geometry
// ---------------------------------------------------------------------------
/// How far (px) to trim the path end so the arrowhead tip lands on the node boundary.
/// pointEnd: viewBox 10, refX 5, tip at x=10, markerWidth 8 → (10-5)*8/10 = 4 px.
pub const POINT_END_TRIM: f64 = 4.0;
/// How far (px) to trim the path start for a reverse arrow.
/// pointStart: viewBox 10, refX 4.5, tip at x=0, markerWidth 8 → 4.5*8/10 = 3.6 px.
pub const POINT_START_TRIM: f64 = 3.6;
// ---------------------------------------------------------------------------
// Subgraph padding (legacy — kept for compute_subgraph_bbox)
// ---------------------------------------------------------------------------
/// Horizontal padding around a subgraph bounding box (px).
pub const SG_PAD_H: f64 = 10.0;
/// Top padding above the subgraph bounding box (px).
pub const SG_PAD_T: f64 = 24.0;
/// Bottom padding below the subgraph bounding box (px).
pub const SG_PAD_B: f64 = 10.0;