windowook-skills 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -0
- package/bin/cli.js +344 -0
- package/package.json +30 -0
- package/skills/clean-tailwind/SKILL.md +131 -0
- package/skills/code-flow-report/SKILL.md +112 -0
- package/skills/code-flow-report/assets/template.html +1458 -0
- package/skills/excalidraw/README.md +76 -0
- package/skills/excalidraw/SKILL.md +281 -0
- package/skills/excalidraw/references/arrows.md +288 -0
- package/skills/excalidraw/references/colors.md +91 -0
- package/skills/excalidraw/references/examples.md +381 -0
- package/skills/excalidraw/references/export.md +124 -0
- package/skills/excalidraw/references/json-format.md +210 -0
- package/skills/excalidraw/references/validation.md +182 -0
- package/skills/execute-figma-plan/SKILL.md +54 -0
- package/skills/figma-plan/CHECKLIST.md +32 -0
- package/skills/figma-plan/PRINCIPLES.md +41 -0
- package/skills/figma-plan/SKILL.md +44 -0
- package/skills/figma-plan/TEMPLATE.md +55 -0
- package/skills/figma-reference-plan/SKILL.md +69 -0
- package/skills/figma-reference-plan/TEMPLATE.md +83 -0
- package/skills/save-context/SKILL.md +79 -0
- package/skills/save-context/TEMPLATE.md +73 -0
- package/skills/save-context/references/example.md +74 -0
- package/skills/save-context/references/guide.md +106 -0
- package/skills/slack-thread/SKILL.md +80 -0
- package/skills/slack-thread/templates/MEETING.md +39 -0
- package/skills/slack-thread/templates/REPORT.md +64 -0
- package/skills/slack-thread/templates/SUGGESTION.md +45 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# Excalidraw - Architecture Diagram Generator
|
|
2
|
+
|
|
3
|
+
Generate architecture diagrams as `.excalidraw` files from codebase analysis, with optional PNG and SVG export.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Add the ccc marketplace (if not already added)
|
|
11
|
+
/plugin marketplace add ooiyeefei/ccc
|
|
12
|
+
|
|
13
|
+
# Install the skills collection
|
|
14
|
+
/plugin install ccc-skills@ccc
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
After installing, just ask Claude Code:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
"Generate an architecture diagram for this project"
|
|
23
|
+
"Create an excalidraw diagram of the system"
|
|
24
|
+
"Visualize this codebase as an excalidraw file"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Claude Code will analyze any codebase (Node.js, Python, Java, Go, etc.), identify components, map relationships, and generate a valid `.excalidraw` JSON file.
|
|
28
|
+
|
|
29
|
+
## Features
|
|
30
|
+
|
|
31
|
+
- **Any codebase**: Discovers services, databases, APIs, and infrastructure from source code
|
|
32
|
+
- **No prerequisites**: Works without existing diagrams, Terraform, or specific file types
|
|
33
|
+
- **Proper arrows**: 90-degree elbow arrows with correct edge binding (not curved)
|
|
34
|
+
- **Color-coded**: Components styled by type (database, API, storage, AI/ML, etc.)
|
|
35
|
+
- **Cloud palettes**: AWS, Azure, GCP, and Kubernetes color schemes
|
|
36
|
+
- **Multiple layouts**: Vertical flow, horizontal pipeline, hub-and-spoke patterns
|
|
37
|
+
- **PNG/SVG export**: Optionally export to PNG and/or SVG via Playwright
|
|
38
|
+
|
|
39
|
+
## PNG/SVG Export
|
|
40
|
+
|
|
41
|
+
After generating a diagram, Claude Code will ask if you want to export to PNG, SVG, or both.
|
|
42
|
+
|
|
43
|
+
The export uses `@excalidraw/utils` loaded in a Playwright browser — fully programmatic, no manual upload to excalidraw.com needed.
|
|
44
|
+
|
|
45
|
+
**Requirements:** Playwright MCP tools must be available.
|
|
46
|
+
|
|
47
|
+
**Output:** Exported files are saved alongside the `.excalidraw` file:
|
|
48
|
+
```
|
|
49
|
+
docs/architecture/
|
|
50
|
+
├── system-architecture.excalidraw # Editable diagram
|
|
51
|
+
├── system-architecture.svg # Vector export
|
|
52
|
+
└── system-architecture.png # Raster export
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Output
|
|
56
|
+
|
|
57
|
+
- **Location**: `docs/architecture/` or user-specified path
|
|
58
|
+
- **Format**: `.excalidraw` JSON (editable in [excalidraw.com](https://excalidraw.com) or VS Code extension)
|
|
59
|
+
- **Exports**: `.svg` and `.png` viewable directly or embeddable in documentation
|
|
60
|
+
|
|
61
|
+
## Reference Files
|
|
62
|
+
|
|
63
|
+
The skill includes detailed reference documentation:
|
|
64
|
+
|
|
65
|
+
| File | Contents |
|
|
66
|
+
|------|----------|
|
|
67
|
+
| `references/json-format.md` | Element types, required properties, text bindings |
|
|
68
|
+
| `references/arrows.md` | Routing algorithm, patterns, bindings, staggering |
|
|
69
|
+
| `references/colors.md` | Default, AWS, Azure, GCP, K8s palettes |
|
|
70
|
+
| `references/examples.md` | Complete JSON examples, layout patterns |
|
|
71
|
+
| `references/validation.md` | Checklists, validation algorithm, bug fixes |
|
|
72
|
+
| `references/export.md` | PNG/SVG export procedure via Playwright |
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
MIT
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: excalidraw
|
|
3
|
+
description: Generate architecture diagrams as .excalidraw files from codebase analysis, with optional PNG/SVG export. Use when the user asks to create architecture diagrams, system diagrams, visualize codebase structure, generate excalidraw files, export excalidraw diagrams to PNG or SVG, or convert .excalidraw files to image formats.
|
|
4
|
+
argument-hint: "[시각화할 대상 경로]"
|
|
5
|
+
disable-model-invocation: false
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Excalidraw Diagram Generator
|
|
9
|
+
|
|
10
|
+
Generate architecture diagrams as `.excalidraw` files directly from codebase analysis, with optional export to PNG and SVG.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
**User just asks:**
|
|
17
|
+
```
|
|
18
|
+
"Generate an architecture diagram for this project"
|
|
19
|
+
"Create an excalidraw diagram of the system"
|
|
20
|
+
"Visualize this codebase as an excalidraw file"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Claude Code will:**
|
|
24
|
+
1. Analyze the codebase (any language/framework)
|
|
25
|
+
2. Identify components, services, databases, APIs
|
|
26
|
+
3. Map relationships and data flows
|
|
27
|
+
4. Generate valid `.excalidraw` JSON with dynamic IDs and labels
|
|
28
|
+
5. Optionally export to PNG and/or SVG using Playwright
|
|
29
|
+
|
|
30
|
+
**No prerequisites:** Works without existing diagrams, Terraform, or specific file types.
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Critical Rules
|
|
35
|
+
|
|
36
|
+
### 1. NEVER Use Diamond Shapes
|
|
37
|
+
|
|
38
|
+
Diamond arrow connections are broken in raw Excalidraw JSON. Use styled rectangles instead:
|
|
39
|
+
|
|
40
|
+
| Semantic Meaning | Rectangle Style |
|
|
41
|
+
|------------------|-----------------|
|
|
42
|
+
| Orchestrator/Hub | Coral (`#ffa8a8`/`#c92a2a`) + strokeWidth: 3 |
|
|
43
|
+
| Decision Point | Orange (`#ffd8a8`/`#e8590c`) + dashed stroke |
|
|
44
|
+
|
|
45
|
+
### 2. Labels Require TWO Elements
|
|
46
|
+
|
|
47
|
+
The `label` property does NOT work in raw JSON. Every labeled shape needs:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
// 1. Shape with boundElements reference
|
|
51
|
+
{
|
|
52
|
+
"id": "my-box",
|
|
53
|
+
"type": "rectangle",
|
|
54
|
+
"boundElements": [{ "type": "text", "id": "my-box-text" }]
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 2. Separate text element with containerId
|
|
58
|
+
{
|
|
59
|
+
"id": "my-box-text",
|
|
60
|
+
"type": "text",
|
|
61
|
+
"containerId": "my-box",
|
|
62
|
+
"text": "My Label"
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 3. Elbow Arrows Need Three Properties
|
|
67
|
+
|
|
68
|
+
For 90-degree corners (not curved):
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"type": "arrow",
|
|
73
|
+
"roughness": 0, // Clean lines
|
|
74
|
+
"roundness": null, // Sharp corners
|
|
75
|
+
"elbowed": true // 90-degree mode
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 4. Arrow Edge Calculations
|
|
80
|
+
|
|
81
|
+
Arrows must start/end at shape edges, not centers:
|
|
82
|
+
|
|
83
|
+
| Edge | Formula |
|
|
84
|
+
|------|---------|
|
|
85
|
+
| Top | `(x + width/2, y)` |
|
|
86
|
+
| Bottom | `(x + width/2, y + height)` |
|
|
87
|
+
| Left | `(x, y + height/2)` |
|
|
88
|
+
| Right | `(x + width, y + height/2)` |
|
|
89
|
+
|
|
90
|
+
**Detailed arrow routing:** See `references/arrows.md`
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Element Types
|
|
95
|
+
|
|
96
|
+
| Type | Use For |
|
|
97
|
+
|------|---------|
|
|
98
|
+
| `rectangle` | Services, databases, containers, orchestrators |
|
|
99
|
+
| `ellipse` | Users, external systems, start/end points |
|
|
100
|
+
| `text` | Labels inside shapes, titles, annotations |
|
|
101
|
+
| `arrow` | Data flow, connections, dependencies |
|
|
102
|
+
| `line` | Grouping boundaries, separators |
|
|
103
|
+
|
|
104
|
+
**Full JSON format:** See `references/json-format.md`
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
## Workflow
|
|
109
|
+
|
|
110
|
+
### Step 1: Analyze Codebase
|
|
111
|
+
|
|
112
|
+
Discover components by looking for:
|
|
113
|
+
|
|
114
|
+
| Codebase Type | What to Look For |
|
|
115
|
+
|---------------|------------------|
|
|
116
|
+
| Monorepo | `packages/*/package.json`, workspace configs |
|
|
117
|
+
| Microservices | `docker-compose.yml`, k8s manifests |
|
|
118
|
+
| IaC | Terraform/Pulumi resource definitions |
|
|
119
|
+
| Backend API | Route definitions, controllers, DB models |
|
|
120
|
+
| Frontend | Component hierarchy, API calls |
|
|
121
|
+
|
|
122
|
+
**Use tools:**
|
|
123
|
+
- `Glob` → `**/package.json`, `**/Dockerfile`, `**/*.tf`
|
|
124
|
+
- `Grep` → `app.get`, `@Controller`, `CREATE TABLE`
|
|
125
|
+
- `Read` → README, config files, entry points
|
|
126
|
+
|
|
127
|
+
### Step 2: Plan Layout
|
|
128
|
+
|
|
129
|
+
**Vertical flow (most common):**
|
|
130
|
+
```
|
|
131
|
+
Row 1: Users/Entry points (y: 100)
|
|
132
|
+
Row 2: Frontend/Gateway (y: 230)
|
|
133
|
+
Row 3: Orchestration (y: 380)
|
|
134
|
+
Row 4: Services (y: 530)
|
|
135
|
+
Row 5: Data layer (y: 680)
|
|
136
|
+
|
|
137
|
+
Columns: x = 100, 300, 500, 700, 900
|
|
138
|
+
Element size: 160-200px x 80-90px
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Other patterns:** See `references/examples.md`
|
|
142
|
+
|
|
143
|
+
### Step 3: Generate Elements
|
|
144
|
+
|
|
145
|
+
For each component:
|
|
146
|
+
1. Create shape with unique `id`
|
|
147
|
+
2. Add `boundElements` referencing text
|
|
148
|
+
3. Create text with `containerId`
|
|
149
|
+
4. Choose color based on type
|
|
150
|
+
|
|
151
|
+
**Color palettes:** See `references/colors.md`
|
|
152
|
+
|
|
153
|
+
### Step 4: Add Connections
|
|
154
|
+
|
|
155
|
+
For each relationship:
|
|
156
|
+
1. Calculate source edge point
|
|
157
|
+
2. Plan elbow route (avoid overlaps)
|
|
158
|
+
3. Create arrow with `points` array
|
|
159
|
+
4. Match stroke color to destination type
|
|
160
|
+
|
|
161
|
+
**Arrow patterns:** See `references/arrows.md`
|
|
162
|
+
|
|
163
|
+
### Step 5: Add Grouping (Optional)
|
|
164
|
+
|
|
165
|
+
For logical groupings:
|
|
166
|
+
- Large transparent rectangle with `strokeStyle: "dashed"`
|
|
167
|
+
- Standalone text label at top-left
|
|
168
|
+
|
|
169
|
+
### Step 6: Validate and Write
|
|
170
|
+
|
|
171
|
+
Run validation before writing. Save to `docs/` or user-specified path.
|
|
172
|
+
|
|
173
|
+
**Validation checklist:** See `references/validation.md`
|
|
174
|
+
|
|
175
|
+
### Step 7: Export to PNG/SVG (Optional)
|
|
176
|
+
|
|
177
|
+
After writing the `.excalidraw` file, ask the user if they want PNG, SVG, or both exports.
|
|
178
|
+
|
|
179
|
+
Uses Playwright MCP tools and `@excalidraw/utils` to programmatically render the diagram — no manual upload to excalidraw.com needed.
|
|
180
|
+
|
|
181
|
+
**Requires:** Playwright MCP tools (`browser_navigate`, `browser_run_code`, `browser_close`).
|
|
182
|
+
|
|
183
|
+
**Full export procedure:** See `references/export.md`
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Quick Arrow Reference
|
|
188
|
+
|
|
189
|
+
**Straight down:**
|
|
190
|
+
```json
|
|
191
|
+
{ "points": [[0, 0], [0, 110]], "x": 590, "y": 290 }
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**L-shape (left then down):**
|
|
195
|
+
```json
|
|
196
|
+
{ "points": [[0, 0], [-325, 0], [-325, 125]], "x": 525, "y": 420 }
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**U-turn (callback):**
|
|
200
|
+
```json
|
|
201
|
+
{ "points": [[0, 0], [50, 0], [50, -125], [20, -125]], "x": 710, "y": 440 }
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Arrow width/height** = bounding box of points:
|
|
205
|
+
```
|
|
206
|
+
points [[0,0], [-440,0], [-440,70]] → width=440, height=70
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Multiple arrows from same edge** - stagger positions:
|
|
210
|
+
```
|
|
211
|
+
5 arrows: 20%, 35%, 50%, 65%, 80% across edge width
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## Default Color Palette
|
|
217
|
+
|
|
218
|
+
| Component | Background | Stroke |
|
|
219
|
+
|-----------|------------|--------|
|
|
220
|
+
| Frontend | `#a5d8ff` | `#1971c2` |
|
|
221
|
+
| Backend/API | `#d0bfff` | `#7048e8` |
|
|
222
|
+
| Database | `#b2f2bb` | `#2f9e44` |
|
|
223
|
+
| Storage | `#ffec99` | `#f08c00` |
|
|
224
|
+
| AI/ML | `#e599f7` | `#9c36b5` |
|
|
225
|
+
| External APIs | `#ffc9c9` | `#e03131` |
|
|
226
|
+
| Orchestration | `#ffa8a8` | `#c92a2a` |
|
|
227
|
+
| Message Queue | `#fff3bf` | `#fab005` |
|
|
228
|
+
| Cache | `#ffe8cc` | `#fd7e14` |
|
|
229
|
+
| Users | `#e7f5ff` | `#1971c2` |
|
|
230
|
+
|
|
231
|
+
**Cloud-specific palettes:** See `references/colors.md`
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Quick Validation Checklist
|
|
236
|
+
|
|
237
|
+
Before writing file:
|
|
238
|
+
- [ ] Every shape with label has boundElements + text element
|
|
239
|
+
- [ ] Text elements have containerId matching shape
|
|
240
|
+
- [ ] Multi-point arrows have `elbowed: true`, `roundness: null`
|
|
241
|
+
- [ ] Arrow x,y = source shape edge point
|
|
242
|
+
- [ ] Arrow final point offset reaches target edge
|
|
243
|
+
- [ ] No diamond shapes
|
|
244
|
+
- [ ] No duplicate IDs
|
|
245
|
+
|
|
246
|
+
**Full validation algorithm:** See `references/validation.md`
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Common Issues
|
|
251
|
+
|
|
252
|
+
| Issue | Fix |
|
|
253
|
+
|-------|-----|
|
|
254
|
+
| Labels don't appear | Use TWO elements (shape + text), not `label` property |
|
|
255
|
+
| Arrows curved | Add `elbowed: true`, `roundness: null`, `roughness: 0` |
|
|
256
|
+
| Arrows floating | Calculate x,y from shape edge, not center |
|
|
257
|
+
| Arrows overlapping | Stagger start positions across edge |
|
|
258
|
+
|
|
259
|
+
**Detailed bug fixes:** See `references/validation.md`
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## Reference Files
|
|
264
|
+
|
|
265
|
+
| File | Contents |
|
|
266
|
+
|------|----------|
|
|
267
|
+
| `references/json-format.md` | Element types, required properties, text bindings |
|
|
268
|
+
| `references/arrows.md` | Routing algorithm, patterns, bindings, staggering |
|
|
269
|
+
| `references/colors.md` | Default, AWS, Azure, GCP, K8s palettes |
|
|
270
|
+
| `references/examples.md` | Complete JSON examples, layout patterns |
|
|
271
|
+
| `references/validation.md` | Checklists, validation algorithm, bug fixes |
|
|
272
|
+
| `references/export.md` | PNG/SVG export procedure via Playwright |
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Output
|
|
277
|
+
|
|
278
|
+
- **Location:** `docs/architecture/` or user-specified
|
|
279
|
+
- **Filename:** Descriptive, e.g., `system-architecture.excalidraw`
|
|
280
|
+
- **Exports (optional):** `system-architecture.svg` and/or `system-architecture.png` in same directory
|
|
281
|
+
- **Testing:** Open `.excalidraw` in https://excalidraw.com or VS Code extension; `.svg` and `.png` can be viewed directly or embedded in documentation
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
# Arrow Routing Reference
|
|
2
|
+
|
|
3
|
+
Complete guide for creating elbow arrows with proper connections.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Critical: Elbow Arrow Properties
|
|
8
|
+
|
|
9
|
+
Three required properties for 90-degree corners:
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"type": "arrow",
|
|
14
|
+
"roughness": 0, // Clean lines
|
|
15
|
+
"roundness": null, // Sharp corners (not curved)
|
|
16
|
+
"elbowed": true // Enables elbow mode
|
|
17
|
+
}
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**Without these, arrows will be curved, not 90-degree elbows.**
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Edge Calculation Formulas
|
|
25
|
+
|
|
26
|
+
| Shape Type | Edge | Formula |
|
|
27
|
+
|------------|------|---------|
|
|
28
|
+
| Rectangle | Top | `(x + width/2, y)` |
|
|
29
|
+
| Rectangle | Bottom | `(x + width/2, y + height)` |
|
|
30
|
+
| Rectangle | Left | `(x, y + height/2)` |
|
|
31
|
+
| Rectangle | Right | `(x + width, y + height/2)` |
|
|
32
|
+
| Ellipse | Top | `(x + width/2, y)` |
|
|
33
|
+
| Ellipse | Bottom | `(x + width/2, y + height)` |
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Universal Arrow Routing Algorithm
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
FUNCTION createArrow(source, target, sourceEdge, targetEdge):
|
|
41
|
+
// Step 1: Get source edge point
|
|
42
|
+
sourcePoint = getEdgePoint(source, sourceEdge)
|
|
43
|
+
|
|
44
|
+
// Step 2: Get target edge point
|
|
45
|
+
targetPoint = getEdgePoint(target, targetEdge)
|
|
46
|
+
|
|
47
|
+
// Step 3: Calculate offsets
|
|
48
|
+
dx = targetPoint.x - sourcePoint.x
|
|
49
|
+
dy = targetPoint.y - sourcePoint.y
|
|
50
|
+
|
|
51
|
+
// Step 4: Determine routing pattern
|
|
52
|
+
IF sourceEdge == "bottom" AND targetEdge == "top":
|
|
53
|
+
IF abs(dx) < 10: // Nearly aligned
|
|
54
|
+
points = [[0, 0], [0, dy]]
|
|
55
|
+
ELSE: // Need L-shape
|
|
56
|
+
points = [[0, 0], [dx, 0], [dx, dy]]
|
|
57
|
+
|
|
58
|
+
ELSE IF sourceEdge == "right" AND targetEdge == "left":
|
|
59
|
+
IF abs(dy) < 10:
|
|
60
|
+
points = [[0, 0], [dx, 0]]
|
|
61
|
+
ELSE:
|
|
62
|
+
points = [[0, 0], [0, dy], [dx, dy]]
|
|
63
|
+
|
|
64
|
+
ELSE IF sourceEdge == targetEdge: // U-turn
|
|
65
|
+
clearance = 50
|
|
66
|
+
IF sourceEdge == "right":
|
|
67
|
+
points = [[0, 0], [clearance, 0], [clearance, dy], [dx, dy]]
|
|
68
|
+
ELSE IF sourceEdge == "bottom":
|
|
69
|
+
points = [[0, 0], [0, clearance], [dx, clearance], [dx, dy]]
|
|
70
|
+
|
|
71
|
+
// Step 5: Calculate bounding box
|
|
72
|
+
width = max(abs(p[0]) for p in points)
|
|
73
|
+
height = max(abs(p[1]) for p in points)
|
|
74
|
+
|
|
75
|
+
RETURN {x: sourcePoint.x, y: sourcePoint.y, points, width, height}
|
|
76
|
+
|
|
77
|
+
FUNCTION getEdgePoint(shape, edge):
|
|
78
|
+
SWITCH edge:
|
|
79
|
+
"top": RETURN (shape.x + shape.width/2, shape.y)
|
|
80
|
+
"bottom": RETURN (shape.x + shape.width/2, shape.y + shape.height)
|
|
81
|
+
"left": RETURN (shape.x, shape.y + shape.height/2)
|
|
82
|
+
"right": RETURN (shape.x + shape.width, shape.y + shape.height/2)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Arrow Patterns Reference
|
|
88
|
+
|
|
89
|
+
| Pattern | Points | Use Case |
|
|
90
|
+
|---------|--------|----------|
|
|
91
|
+
| Down | `[[0,0], [0,h]]` | Vertical connection |
|
|
92
|
+
| Right | `[[0,0], [w,0]]` | Horizontal connection |
|
|
93
|
+
| L-left-down | `[[0,0], [-w,0], [-w,h]]` | Go left, then down |
|
|
94
|
+
| L-right-down | `[[0,0], [w,0], [w,h]]` | Go right, then down |
|
|
95
|
+
| L-down-left | `[[0,0], [0,h], [-w,h]]` | Go down, then left |
|
|
96
|
+
| L-down-right | `[[0,0], [0,h], [w,h]]` | Go down, then right |
|
|
97
|
+
| S-shape | `[[0,0], [0,h1], [w,h1], [w,h2]]` | Navigate around obstacles |
|
|
98
|
+
| U-turn | `[[0,0], [w,0], [w,-h], [0,-h]]` | Callback/return arrows |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Worked Examples
|
|
103
|
+
|
|
104
|
+
### Vertical Connection (Bottom to Top)
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
Source: x=500, y=200, width=180, height=90
|
|
108
|
+
Target: x=500, y=400, width=180, height=90
|
|
109
|
+
|
|
110
|
+
source_bottom = (500 + 180/2, 200 + 90) = (590, 290)
|
|
111
|
+
target_top = (500 + 180/2, 400) = (590, 400)
|
|
112
|
+
|
|
113
|
+
Arrow x = 590, y = 290
|
|
114
|
+
Distance = 400 - 290 = 110
|
|
115
|
+
Points = [[0, 0], [0, 110]]
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Fan-out (One to Many)
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
Orchestrator: x=570, y=400, width=140, height=80
|
|
122
|
+
Target: x=120, y=550, width=160, height=80
|
|
123
|
+
|
|
124
|
+
orchestrator_bottom = (570 + 140/2, 400 + 80) = (640, 480)
|
|
125
|
+
target_top = (120 + 160/2, 550) = (200, 550)
|
|
126
|
+
|
|
127
|
+
Arrow x = 640, y = 480
|
|
128
|
+
Horizontal offset = 200 - 640 = -440
|
|
129
|
+
Vertical offset = 550 - 480 = 70
|
|
130
|
+
|
|
131
|
+
Points = [[0, 0], [-440, 0], [-440, 70]] // Left first, then down
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### U-turn (Callback)
|
|
135
|
+
|
|
136
|
+
```
|
|
137
|
+
Source: x=570, y=400, width=140, height=80
|
|
138
|
+
Target: x=550, y=270, width=180, height=90
|
|
139
|
+
Connection: Right of source -> Right of target
|
|
140
|
+
|
|
141
|
+
source_right = (570 + 140, 400 + 80/2) = (710, 440)
|
|
142
|
+
target_right = (550 + 180, 270 + 90/2) = (730, 315)
|
|
143
|
+
|
|
144
|
+
Arrow x = 710, y = 440
|
|
145
|
+
Vertical distance = 315 - 440 = -125
|
|
146
|
+
Final x offset = 730 - 710 = 20
|
|
147
|
+
|
|
148
|
+
Points = [[0, 0], [50, 0], [50, -125], [20, -125]]
|
|
149
|
+
// Right 50px (clearance), up 125px, left 30px
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Staggering Multiple Arrows
|
|
155
|
+
|
|
156
|
+
When N arrows leave from same edge, spread evenly:
|
|
157
|
+
|
|
158
|
+
```
|
|
159
|
+
FUNCTION getStaggeredPositions(shape, edge, numArrows):
|
|
160
|
+
positions = []
|
|
161
|
+
FOR i FROM 0 TO numArrows-1:
|
|
162
|
+
percentage = 0.2 + (0.6 * i / (numArrows - 1))
|
|
163
|
+
|
|
164
|
+
IF edge == "bottom" OR edge == "top":
|
|
165
|
+
x = shape.x + shape.width * percentage
|
|
166
|
+
y = (edge == "bottom") ? shape.y + shape.height : shape.y
|
|
167
|
+
ELSE:
|
|
168
|
+
x = (edge == "right") ? shape.x + shape.width : shape.x
|
|
169
|
+
y = shape.y + shape.height * percentage
|
|
170
|
+
|
|
171
|
+
positions.append({x, y})
|
|
172
|
+
RETURN positions
|
|
173
|
+
|
|
174
|
+
// Examples:
|
|
175
|
+
// 2 arrows: 20%, 80%
|
|
176
|
+
// 3 arrows: 20%, 50%, 80%
|
|
177
|
+
// 5 arrows: 20%, 35%, 50%, 65%, 80%
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Arrow Bindings
|
|
183
|
+
|
|
184
|
+
For better visual attachment, use `startBinding` and `endBinding`:
|
|
185
|
+
|
|
186
|
+
```json
|
|
187
|
+
{
|
|
188
|
+
"id": "arrow-workflow-convert",
|
|
189
|
+
"type": "arrow",
|
|
190
|
+
"x": 525,
|
|
191
|
+
"y": 420,
|
|
192
|
+
"width": 325,
|
|
193
|
+
"height": 125,
|
|
194
|
+
"points": [[0, 0], [-325, 0], [-325, 125]],
|
|
195
|
+
"roughness": 0,
|
|
196
|
+
"roundness": null,
|
|
197
|
+
"elbowed": true,
|
|
198
|
+
"startBinding": {
|
|
199
|
+
"elementId": "cloud-workflows",
|
|
200
|
+
"focus": 0,
|
|
201
|
+
"gap": 1,
|
|
202
|
+
"fixedPoint": [0.5, 1]
|
|
203
|
+
},
|
|
204
|
+
"endBinding": {
|
|
205
|
+
"elementId": "convert-pdf-service",
|
|
206
|
+
"focus": 0,
|
|
207
|
+
"gap": 1,
|
|
208
|
+
"fixedPoint": [0.5, 0]
|
|
209
|
+
},
|
|
210
|
+
"startArrowhead": null,
|
|
211
|
+
"endArrowhead": "arrow"
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### fixedPoint Values
|
|
216
|
+
|
|
217
|
+
- Top center: `[0.5, 0]`
|
|
218
|
+
- Bottom center: `[0.5, 1]`
|
|
219
|
+
- Left center: `[0, 0.5]`
|
|
220
|
+
- Right center: `[1, 0.5]`
|
|
221
|
+
|
|
222
|
+
### Update Shape boundElements
|
|
223
|
+
|
|
224
|
+
```json
|
|
225
|
+
{
|
|
226
|
+
"id": "cloud-workflows",
|
|
227
|
+
"boundElements": [
|
|
228
|
+
{ "type": "text", "id": "cloud-workflows-text" },
|
|
229
|
+
{ "type": "arrow", "id": "arrow-workflow-convert" }
|
|
230
|
+
]
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Bidirectional Arrows
|
|
237
|
+
|
|
238
|
+
For two-way data flows:
|
|
239
|
+
|
|
240
|
+
```json
|
|
241
|
+
{
|
|
242
|
+
"type": "arrow",
|
|
243
|
+
"startArrowhead": "arrow",
|
|
244
|
+
"endArrowhead": "arrow"
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Arrowhead options: `null`, `"arrow"`, `"bar"`, `"dot"`, `"triangle"`
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Arrow Labels
|
|
253
|
+
|
|
254
|
+
Position standalone text near arrow midpoint:
|
|
255
|
+
|
|
256
|
+
```json
|
|
257
|
+
{
|
|
258
|
+
"id": "arrow-api-db-label",
|
|
259
|
+
"type": "text",
|
|
260
|
+
"x": 305, // Arrow x + offset
|
|
261
|
+
"y": 245, // Arrow midpoint
|
|
262
|
+
"text": "SQL",
|
|
263
|
+
"fontSize": 12,
|
|
264
|
+
"containerId": null,
|
|
265
|
+
"backgroundColor": "#ffffff"
|
|
266
|
+
}
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**Positioning formula:**
|
|
270
|
+
- Vertical: `label.y = arrow.y + (total_height / 2)`
|
|
271
|
+
- Horizontal: `label.x = arrow.x + (total_width / 2)`
|
|
272
|
+
- L-shaped: Position at corner or longest segment midpoint
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Width/Height Calculation
|
|
277
|
+
|
|
278
|
+
Arrow `width` and `height` = bounding box of path:
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
points = [[0, 0], [-440, 0], [-440, 70]]
|
|
282
|
+
width = abs(-440) = 440
|
|
283
|
+
height = abs(70) = 70
|
|
284
|
+
|
|
285
|
+
points = [[0, 0], [50, 0], [50, -125], [20, -125]]
|
|
286
|
+
width = max(abs(50), abs(20)) = 50
|
|
287
|
+
height = abs(-125) = 125
|
|
288
|
+
```
|