@visualli/core 0.1.5 → 0.1.6
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/dist/animations/index.cjs +146 -0
- package/dist/animations/index.cjs.map +1 -0
- package/dist/animations/index.d.cts +81 -0
- package/dist/animations/index.d.ts +81 -0
- package/dist/animations/index.js +35 -0
- package/dist/animations/index.js.map +1 -0
- package/dist/chunk-6NXADJK2.js +562 -0
- package/dist/chunk-6NXADJK2.js.map +1 -0
- package/dist/chunk-F36SMC3K.js +106 -0
- package/dist/chunk-F36SMC3K.js.map +1 -0
- package/dist/chunk-G5H3P4YZ.js +273 -0
- package/dist/chunk-G5H3P4YZ.js.map +1 -0
- package/dist/chunk-GQMFBYLK.js +81 -0
- package/dist/chunk-GQMFBYLK.js.map +1 -0
- package/dist/chunk-I75TMOE4.js +108 -0
- package/dist/chunk-I75TMOE4.js.map +1 -0
- package/dist/chunk-LDJRGT2Q.js +163 -0
- package/dist/chunk-LDJRGT2Q.js.map +1 -0
- package/dist/chunk-LI3BVD6H.js +98 -0
- package/dist/chunk-LI3BVD6H.js.map +1 -0
- package/dist/chunk-LJYSKSCE.js +95 -0
- package/dist/chunk-LJYSKSCE.js.map +1 -0
- package/dist/chunk-LNTJTDB2.js +349 -0
- package/dist/chunk-LNTJTDB2.js.map +1 -0
- package/dist/chunk-PDP5CVUL.js +139 -0
- package/dist/chunk-PDP5CVUL.js.map +1 -0
- package/dist/chunk-VLGR5PZX.js +1 -0
- package/dist/chunk-VLGR5PZX.js.map +1 -0
- package/dist/config/index.cjs +391 -0
- package/dist/config/index.cjs.map +1 -0
- package/dist/config/index.d.cts +77 -0
- package/dist/config/index.d.ts +77 -0
- package/dist/config/index.js +38 -0
- package/dist/config/index.js.map +1 -0
- package/dist/constants/index.cjs +642 -0
- package/dist/constants/index.cjs.map +1 -0
- package/dist/constants/index.d.cts +448 -0
- package/dist/constants/index.d.ts +448 -0
- package/dist/constants/index.js +183 -0
- package/dist/constants/index.js.map +1 -0
- package/dist/document-B3hnNr-F.d.cts +73 -0
- package/dist/document-B3hnNr-F.d.ts +73 -0
- package/dist/index.cjs +32 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -1044
- package/dist/index.d.ts +15 -1044
- package/dist/index.js +179 -1747
- package/dist/index.js.map +1 -1
- package/dist/layout/index.cjs +210 -0
- package/dist/layout/index.cjs.map +1 -0
- package/dist/layout/index.d.cts +80 -0
- package/dist/layout/index.d.ts +80 -0
- package/dist/layout/index.js +25 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/mindmap-DWS0WZT_.d.cts +118 -0
- package/dist/mindmap-DWS0WZT_.d.ts +118 -0
- package/dist/parser/index.cjs +739 -0
- package/dist/parser/index.cjs.map +1 -0
- package/dist/parser/index.d.cts +87 -0
- package/dist/parser/index.d.ts +87 -0
- package/dist/parser/index.js +43 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/performance/index.cjs +167 -0
- package/dist/performance/index.cjs.map +1 -0
- package/dist/performance/index.d.cts +40 -0
- package/dist/performance/index.d.ts +40 -0
- package/dist/performance/index.js +12 -0
- package/dist/performance/index.js.map +1 -0
- package/dist/types/index.cjs +19 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.d.cts +8 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/dist/viewport/index.cjs +131 -0
- package/dist/viewport/index.cjs.map +1 -0
- package/dist/viewport/index.d.cts +56 -0
- package/dist/viewport/index.d.ts +56 -0
- package/dist/viewport/index.js +26 -0
- package/dist/viewport/index.js.map +1 -0
- package/package.json +6 -1
- package/src/config/README.md +59 -0
- package/src/config/USAGE_EXAMPLES.md +285 -0
- package/src/config/index.ts +7 -0
- package/src/index.ts +1 -2
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
# Blob Shapes Usage Examples
|
|
2
|
+
|
|
3
|
+
## Import Options
|
|
4
|
+
|
|
5
|
+
### Option 1: Import from main package
|
|
6
|
+
```typescript
|
|
7
|
+
import { ALL_BLOB_SHAPES, BlobShape, getBlobTypeForLayer } from '@visualli/core';
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
### Option 2: Import from config sub-path (recommended)
|
|
11
|
+
```typescript
|
|
12
|
+
import { ALL_BLOB_SHAPES, BlobShape, getBlobTypeForLayer } from '@visualli/core/config';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage Examples
|
|
16
|
+
|
|
17
|
+
### Example 1: Access All Shapes
|
|
18
|
+
```typescript
|
|
19
|
+
import { ALL_BLOB_SHAPES, BlobShape } from '@visualli/core/config';
|
|
20
|
+
|
|
21
|
+
// Get total number of available shapes
|
|
22
|
+
console.log(`Available shapes: ${ALL_BLOB_SHAPES.length}`); // 6
|
|
23
|
+
|
|
24
|
+
// Access a specific shape
|
|
25
|
+
const shape0: BlobShape = ALL_BLOB_SHAPES[0];
|
|
26
|
+
console.log(`Shape 0 has ${shape0.length} points`); // 10 points
|
|
27
|
+
|
|
28
|
+
// Iterate through all shapes
|
|
29
|
+
ALL_BLOB_SHAPES.forEach((shape, index) => {
|
|
30
|
+
console.log(`Shape ${index}: ${shape.length} points`);
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Example 2: Use Shape Points
|
|
35
|
+
```typescript
|
|
36
|
+
import { ALL_BLOB_SHAPES, BlobPoint } from '@visualli/core/config';
|
|
37
|
+
|
|
38
|
+
const shape = ALL_BLOB_SHAPES[1]; // Use Shape 1 (Blob 2)
|
|
39
|
+
|
|
40
|
+
// Access individual points
|
|
41
|
+
shape.forEach((point: BlobPoint) => {
|
|
42
|
+
console.log(`Point: (${point.x}, ${point.y})`);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Scale the shape to your desired size
|
|
46
|
+
const radiusX = 100;
|
|
47
|
+
const radiusY = 80;
|
|
48
|
+
const scaledPoints = shape.map(p => ({
|
|
49
|
+
x: p.x * radiusX,
|
|
50
|
+
y: p.y * radiusY
|
|
51
|
+
}));
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Example 3: Render to Canvas
|
|
55
|
+
```typescript
|
|
56
|
+
import { drawBlobPath } from '@visualli/core/config';
|
|
57
|
+
|
|
58
|
+
const canvas = document.createElement('canvas');
|
|
59
|
+
const ctx = canvas.getContext('2d')!;
|
|
60
|
+
|
|
61
|
+
// Center the canvas context
|
|
62
|
+
ctx.translate(canvas.width / 2, canvas.height / 2);
|
|
63
|
+
|
|
64
|
+
// Draw blob shape 2 with custom radius
|
|
65
|
+
const radiusX = 150;
|
|
66
|
+
const radiusY = 120;
|
|
67
|
+
const blobType = 2;
|
|
68
|
+
|
|
69
|
+
drawBlobPath(ctx, radiusX, radiusY, blobType);
|
|
70
|
+
|
|
71
|
+
// Style and render
|
|
72
|
+
ctx.fillStyle = '#4CAF50';
|
|
73
|
+
ctx.fill();
|
|
74
|
+
ctx.strokeStyle = '#2E7D32';
|
|
75
|
+
ctx.lineWidth = 3;
|
|
76
|
+
ctx.stroke();
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Example 4: Render to SVG
|
|
80
|
+
```typescript
|
|
81
|
+
import { ALL_BLOB_SHAPES } from '@visualli/core/config';
|
|
82
|
+
|
|
83
|
+
function blobShapeToSVGPath(
|
|
84
|
+
shape: BlobShape,
|
|
85
|
+
radiusX: number,
|
|
86
|
+
radiusY: number
|
|
87
|
+
): string {
|
|
88
|
+
const points = shape.map(p => ({
|
|
89
|
+
x: p.x * radiusX,
|
|
90
|
+
y: p.y * radiusY
|
|
91
|
+
}));
|
|
92
|
+
|
|
93
|
+
let path = '';
|
|
94
|
+
const last = points[points.length - 1];
|
|
95
|
+
const first = points[0];
|
|
96
|
+
|
|
97
|
+
// Start at midpoint between last and first
|
|
98
|
+
path += `M ${(last.x + first.x) / 2} ${(last.y + first.y) / 2}`;
|
|
99
|
+
|
|
100
|
+
// Quadratic bezier curves through each control point
|
|
101
|
+
for (let i = 0; i < points.length; i++) {
|
|
102
|
+
const curr = points[i];
|
|
103
|
+
const next = points[(i + 1) % points.length];
|
|
104
|
+
path += ` Q ${curr.x} ${curr.y} ${(curr.x + next.x) / 2} ${(curr.y + next.y) / 2}`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
path += ' Z'; // Close path
|
|
108
|
+
return path;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Use it
|
|
112
|
+
const shape = ALL_BLOB_SHAPES[3];
|
|
113
|
+
const pathData = blobShapeToSVGPath(shape, 100, 100);
|
|
114
|
+
|
|
115
|
+
const svg = `
|
|
116
|
+
<svg width="300" height="300" xmlns="http://www.w3.org/2000/svg">
|
|
117
|
+
<g transform="translate(150, 150)">
|
|
118
|
+
<path d="${pathData}" fill="#4CAF50" stroke="#2E7D32" stroke-width="3"/>
|
|
119
|
+
</g>
|
|
120
|
+
</svg>
|
|
121
|
+
`;
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Example 5: Render to PDF (using pdf-lib)
|
|
125
|
+
```typescript
|
|
126
|
+
import { PDFDocument, rgb } from 'pdf-lib';
|
|
127
|
+
import { ALL_BLOB_SHAPES } from '@visualli/core/config';
|
|
128
|
+
|
|
129
|
+
async function addBlobToPDF(blobType: number) {
|
|
130
|
+
const pdfDoc = await PDFDocument.create();
|
|
131
|
+
const page = pdfDoc.addPage([600, 400]);
|
|
132
|
+
|
|
133
|
+
const shape = ALL_BLOB_SHAPES[blobType];
|
|
134
|
+
const radiusX = 80;
|
|
135
|
+
const radiusY = 60;
|
|
136
|
+
const centerX = 300;
|
|
137
|
+
const centerY = 200;
|
|
138
|
+
|
|
139
|
+
// Scale points
|
|
140
|
+
const points = shape.map(p => ({
|
|
141
|
+
x: centerX + p.x * radiusX,
|
|
142
|
+
y: centerY + p.y * radiusY
|
|
143
|
+
}));
|
|
144
|
+
|
|
145
|
+
// Draw path using quadratic bezier curves
|
|
146
|
+
const last = points[points.length - 1];
|
|
147
|
+
const first = points[0];
|
|
148
|
+
|
|
149
|
+
page.moveTo((last.x + first.x) / 2, (last.y + first.y) / 2);
|
|
150
|
+
|
|
151
|
+
for (let i = 0; i < points.length; i++) {
|
|
152
|
+
const curr = points[i];
|
|
153
|
+
const next = points[(i + 1) % points.length];
|
|
154
|
+
|
|
155
|
+
// Note: pdf-lib uses quadraticCurveTo
|
|
156
|
+
page.drawQuadraticCurve({
|
|
157
|
+
controlPoint: { x: curr.x, y: curr.y },
|
|
158
|
+
endPoint: { x: (curr.x + next.x) / 2, y: (curr.y + next.y) / 2 },
|
|
159
|
+
color: rgb(0.3, 0.69, 0.31),
|
|
160
|
+
thickness: 3,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const pdfBytes = await pdfDoc.save();
|
|
165
|
+
return pdfBytes;
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### Example 6: Dynamic Level-based Shape Selection
|
|
170
|
+
```typescript
|
|
171
|
+
import { getBlobTypeForLayer, ALL_BLOB_SHAPES } from '@visualli/core/config';
|
|
172
|
+
|
|
173
|
+
// Get appropriate shape for different tree levels
|
|
174
|
+
function renderNodeAtLevel(level: number) {
|
|
175
|
+
const blobType = getBlobTypeForLayer(level);
|
|
176
|
+
const shape = ALL_BLOB_SHAPES[blobType];
|
|
177
|
+
|
|
178
|
+
console.log(`Level ${level} uses shape ${blobType} with ${shape.length} points`);
|
|
179
|
+
|
|
180
|
+
// Render the shape...
|
|
181
|
+
return shape;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Example: render a tree
|
|
185
|
+
for (let level = 0; level < 5; level++) {
|
|
186
|
+
renderNodeAtLevel(level);
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Example 7: Custom Shape Processor
|
|
191
|
+
```typescript
|
|
192
|
+
import { ALL_BLOB_SHAPES, BlobShape, BlobPoint } from '@visualli/core/config';
|
|
193
|
+
|
|
194
|
+
class BlobShapeRenderer {
|
|
195
|
+
private shapes: ReadonlyArray<BlobShape>;
|
|
196
|
+
|
|
197
|
+
constructor() {
|
|
198
|
+
this.shapes = ALL_BLOB_SHAPES;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
getShape(index: number): BlobShape {
|
|
202
|
+
return this.shapes[index] || this.shapes[0];
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
getAllShapes(): ReadonlyArray<BlobShape> {
|
|
206
|
+
return this.shapes;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
getShapeCount(): number {
|
|
210
|
+
return this.shapes.length;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
getScaledPoints(
|
|
214
|
+
shapeIndex: number,
|
|
215
|
+
scaleX: number,
|
|
216
|
+
scaleY: number
|
|
217
|
+
): BlobPoint[] {
|
|
218
|
+
const shape = this.getShape(shapeIndex);
|
|
219
|
+
return shape.map(p => ({
|
|
220
|
+
x: p.x * scaleX,
|
|
221
|
+
y: p.y * scaleY
|
|
222
|
+
}));
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
getBoundingBox(shapeIndex: number): {
|
|
226
|
+
minX: number;
|
|
227
|
+
maxX: number;
|
|
228
|
+
minY: number;
|
|
229
|
+
maxY: number;
|
|
230
|
+
} {
|
|
231
|
+
const shape = this.getShape(shapeIndex);
|
|
232
|
+
|
|
233
|
+
return shape.reduce((bbox, point) => ({
|
|
234
|
+
minX: Math.min(bbox.minX, point.x),
|
|
235
|
+
maxX: Math.max(bbox.maxX, point.x),
|
|
236
|
+
minY: Math.min(bbox.minY, point.y),
|
|
237
|
+
maxY: Math.max(bbox.maxY, point.y)
|
|
238
|
+
}), {
|
|
239
|
+
minX: Infinity,
|
|
240
|
+
maxX: -Infinity,
|
|
241
|
+
minY: Infinity,
|
|
242
|
+
maxY: -Infinity
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Usage
|
|
248
|
+
const renderer = new BlobShapeRenderer();
|
|
249
|
+
console.log(`Total shapes available: ${renderer.getShapeCount()}`);
|
|
250
|
+
|
|
251
|
+
const bbox = renderer.getBoundingBox(0);
|
|
252
|
+
console.log('Shape 0 bounding box:', bbox);
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Available Shape Types
|
|
256
|
+
|
|
257
|
+
- **Shape 0 (Blob 1)**: 10 points - Simple, rounded blob
|
|
258
|
+
- **Shape 1 (Blob 2)**: 62 points - Complex, highly detailed organic shape
|
|
259
|
+
- **Shape 2 (Blob 3)**: 40 points - Moderate complexity
|
|
260
|
+
- **Shape 3 (Blob 4)**: 40 points - Moderate complexity
|
|
261
|
+
- **Shape 4 (Blob 5)**: 40 points - Vertically flipped version of Shape 3
|
|
262
|
+
- **Shape 5 (Blob 6)**: 44 points - Complex with specific offset
|
|
263
|
+
|
|
264
|
+
## Configuration Constants
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
import {
|
|
268
|
+
BLOB_LAYER_CONFIG,
|
|
269
|
+
NODE_LAYER_CONFIG,
|
|
270
|
+
BLOB_TEXT_OFFSETS,
|
|
271
|
+
ACTIVE_BLOB_TYPES
|
|
272
|
+
} from '@visualli/core/config';
|
|
273
|
+
|
|
274
|
+
// Layer configurations for rendering multiple blob layers
|
|
275
|
+
console.log(BLOB_LAYER_CONFIG); // 3 layers with opacity, rotation, scale, etc.
|
|
276
|
+
|
|
277
|
+
// Node layer configuration
|
|
278
|
+
console.log(NODE_LAYER_CONFIG); // Main node rendering config
|
|
279
|
+
|
|
280
|
+
// Text offsets for each shape
|
|
281
|
+
console.log(BLOB_TEXT_OFFSETS); // [0, 0, 0, 0, 0, -0.10]
|
|
282
|
+
|
|
283
|
+
// Active shape indices
|
|
284
|
+
console.log(ACTIVE_BLOB_TYPES); // [0, 1, 2, 3, 4, 5]
|
|
285
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// ─── Config Barrel Export ────────────────────────────────────────────────────
|
|
2
|
+
//
|
|
3
|
+
// Automatically exports all configuration modules.
|
|
4
|
+
// Add new config files here to make them available via `@visualli/core/config`.
|
|
5
|
+
|
|
6
|
+
export * from './blobShapes.js';
|
|
7
|
+
export * from './textScaling.js';
|
package/src/index.ts
CHANGED
|
@@ -14,5 +14,4 @@ export * from './spatial/index.js';
|
|
|
14
14
|
export * from './stores/index.js';
|
|
15
15
|
export * from './utils/navigation.js';
|
|
16
16
|
export * from './rendering/culling.js';
|
|
17
|
-
export * from './config/
|
|
18
|
-
export * from './config/blobShapes.js';
|
|
17
|
+
export * from './config/index.js';
|