@fieldnotes/core 0.37.0 → 0.38.1
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 +19 -0
- package/dist/index.cjs +564 -509
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -18
- package/dist/index.d.ts +16 -18
- package/dist/index.js +564 -509
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -104,6 +104,25 @@ viewport.addImage('/assets/map.png', { x: 0, y: 0 }, { w: 800, h: 600 });
|
|
|
104
104
|
|
|
105
105
|
> **Important: Use URLs, not base64 data URLs.** Images are stored inline in the serialized state. A single base64-encoded photo can be 2-5MB, which will blow past the `localStorage` ~5MB quota and make JSON exports impractical. Upload images to your server or CDN and use the URL. For offline/local-first apps, store blobs in IndexedDB and reference them by URL.
|
|
106
106
|
|
|
107
|
+
## Adding Shapes
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
// Default: a centered 100×100 rectangle
|
|
111
|
+
const id = viewport.addShape();
|
|
112
|
+
|
|
113
|
+
// Override shape, size, position, and colors
|
|
114
|
+
viewport.addShape({
|
|
115
|
+
shape: 'ellipse',
|
|
116
|
+
size: { w: 200, h: 120 },
|
|
117
|
+
position: { x: 0, y: 0 },
|
|
118
|
+
strokeColor: '#1d4ed8',
|
|
119
|
+
fillColor: '#dbeafe',
|
|
120
|
+
strokeWidth: 2,
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`addShape(opts?): string` creates a shape in a single undo step, selects the new shape, and returns its id. With no options it places a 100×100 rectangle centered in the current viewport — a keyboard-friendly path to shape creation.
|
|
125
|
+
|
|
107
126
|
## Grids
|
|
108
127
|
|
|
109
128
|
Add square or hex grid overlays — useful for D&D combat maps, alignment, or graph paper backgrounds. Grids always render on top of images and other layer elements.
|