figureone 1.7.0 → 1.7.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/index.js CHANGED
@@ -81845,8 +81845,8 @@ var tools = {
81845
81845
  */
81846
81846
 
81847
81847
  var Fig = {
81848
- version: "1.7.0",
81849
- gitHash: "8c04ba173",
81848
+ version: "1.7.1",
81849
+ gitHash: "501b3a1fb",
81850
81850
  tools: tools,
81851
81851
  Figure: _js_figure_Figure__WEBPACK_IMPORTED_MODULE_5__["default"],
81852
81852
  Recorder: _js_figure_Recorder_Recorder__WEBPACK_IMPORTED_MODULE_7__.Recorder,
package/llms-full.txt CHANGED
@@ -20,6 +20,10 @@ Colors are `[r, g, b, a]` with values 0-1. Default scene is `[-1, -1, 2, 2]` (x,
20
20
  | lineWidth | number | | Default line width |
21
21
  | length | number | | Default primary dimension |
22
22
  | backgroundColor | TypeColor | | Background color |
23
+ | textStyle | `'italic'` \| `'normal'` | `'italic'` | Default equation text style (also settable on FigurePrimitives and Equation) |
24
+ | antialias | boolean | `true` | Enable WebGL anti-aliasing |
25
+ | atlasScale | number | `2` | GL text atlas texture resolution relative to 1:1 pixel mapping |
26
+ | onWebGLUnavailable | () => void | | Callback fired once during construction if no WebGL context is available (figure is still created but renders nothing) |
23
27
 
24
28
  ### Key Figure Methods
25
29
 
@@ -45,6 +49,11 @@ figure.resize(); // Resize after container change
45
49
  figure.animateNextFrame(); // Request next animation frame
46
50
  figure.isAnimating(); // Check if any animation running
47
51
 
52
+ // WebGL context state
53
+ figure.webglAvailable; // false if no live WebGL context (e.g. context lost)
54
+ figure.notifications.add('contextLost', () => { /* context removed by browser */ });
55
+ figure.notifications.add('contextRestored', () => { /* context returned */ });
56
+
48
57
  // Coordinate transforms
49
58
  figure.transformPoint(point, fromSpace, toSpace);
50
59
  figure.spaceTransformMatrix(fromSpace, toSpace);
@@ -92,6 +101,7 @@ Path to figure element(s) within a collection. Supports multiple formats:
92
101
  | underline | boolean \| object | `false` | Underline options |
93
102
  | outline | boolean \| object | `false` | Outline options |
94
103
  | render | `'gl'` \| `'2d'` \| `'html'` | `'gl'` | Render target |
104
+ | atlasId | string | | Share a single GL atlas texture across text elements with different sizes (elements with the same `atlasId` reuse one atlas) |
95
105
 
96
106
  ### OBJ_Texture
97
107
 
@@ -119,6 +129,11 @@ Path to figure element(s) within a collection. Supports multiple formats:
119
129
  | defaultColor | TypeColor | | Color when undimmed |
120
130
  | scenarios | OBJ_Scenarios | | Named presets |
121
131
  | scene | Scene \| OBJ_Scene | | Custom scene |
132
+ | isFormIgnored | boolean | `false` | Exclude from equation form changes — skipped by form layout, show/hide, transform/color sets, and `elementMods`, so its user-applied transform, color, and visibility persist across `showForm` / `goToForm` (contributes zero size to layout) |
133
+ | allowSetColor | `'all'` \| `'opacity'` \| `'none'` | `'all'` | Freeze color: `'opacity'` allows only the alpha channel to change; `'none'` blocks all `setColor` |
134
+ | ignoreSetColor | string \| string[] | `[]` | Source label(s) whose tagged `setColor` commands are ignored (e.g. the equation's default `'form'` color cascade), while explicit/untagged commands (`dim`/`undim`, direct `setColor`) are still honored |
135
+
136
+ These element properties are also settable at runtime; `setColor(color, setDefault?, from?)` takes an optional `from` source label that is matched against `ignoreSetColor`.
122
137
 
123
138
  ### OBJ_Collection
124
139
 
@@ -1252,6 +1267,26 @@ Array: `{ color: [content, [r, g, b, a]] }`
1252
1267
  | color | TypeColor | | Color to apply |
1253
1268
  | fullContentBounds | boolean | `false` | Use full bounds |
1254
1269
 
1270
+ #### EQN_Opacity (`opacity`)
1271
+ Array: `{ opacity: [content, opacity_value] }`. Wraps a phrase in an opacity multiplier that cascades multiplicatively through nested `opacity` wrappers (outer `0.5` × inner `0.5` = `0.25` on inner content). The cascaded opacity is assigned to each wrapped element whenever the form is shown, overriding externally-set element opacity — set `ignoreOpacity: true` on the form to suppress this and preserve external opacities.
1272
+
1273
+ | Property | Type | Default | Description |
1274
+ |---|---|---|---|
1275
+ | content | TypeEquationPhrase | | Content |
1276
+ | opacity | number | | Opacity multiplier in range `[0, 1]` |
1277
+ | fullContentBounds | boolean | `false` | Use full bounds |
1278
+
1279
+ #### EQN_Front (`front`) / EQN_Back (`back`)
1280
+ Array: `{ front: [content, num] }` / `{ back: [content, num] }`. Reorder a phrase's elements within the equation's draw stack, per-form. All elements in `content` move together as a group, keeping their relative draw order. Applied whenever the form is shown, relative to the equation's natural definition order, so each form deterministically defines its own stacking. The same operations are available as `front` / `back` element mods (e.g. `elementMods: { a: { back: {} } }`).
1281
+
1282
+ | Property | Type | Default | Description |
1283
+ |---|---|---|---|
1284
+ | content | TypeEquationPhrase | | Content |
1285
+ | num | number | | `front`: places to move forward (positive) or `\|num\|` places behind the front (negative). `back`: places to move back (positive) or `\|num\|` places ahead of the back (negative). With `before`/`after`, it's the offset from the anchor (default `0`). If omitted with no anchor, moves fully to front/back |
1286
+ | before | string \| string[] | | Anchor element name(s) — position the group just before (behind) the most-back anchor |
1287
+ | after | string \| string[] | | Anchor element name(s) — position the group just after (in front of) the most-front anchor |
1288
+ | fullContentBounds | boolean | `false` | Use full bounds |
1289
+
1255
1290
  #### EQN_Container (`container`)
1256
1291
  Array: `{ container: [content, width] }`
1257
1292
 
@@ -1452,10 +1487,17 @@ forms: {
1452
1487
  scale: { elementName: 1.5 }, // Per-element target scales during animation
1453
1488
  fromPrev: { elementName: 'otherElement' }, // Animate from another element's position
1454
1489
  fromNext: { elementName: 'otherElement' }, // Animate from another element's position (reverse)
1490
+ ignoreColor: false, // true preserves externally-set element colors (suppresses color cascade)
1491
+ ignoreOpacity: false, // true preserves externally-set element opacities (suppresses opacity cascade)
1492
+ elementMods: { // Per-element property mods applied when form shows
1493
+ elementName: { back: {} }, // e.g. front/back reorder mods (see EQN_Front/EQN_Back)
1494
+ },
1455
1495
  },
1456
1496
  }
1457
1497
  ```
1458
1498
 
1499
+ Every equation layout function (container, frac, matrix, brac, annotate, color, opacity, front, back, etc.) also accepts an optional `name` property — purely a label with no layout effect, used to address the function's sub-tree via `eqn.getFunctionElements(name)`.
1500
+
1459
1501
  ### Forms and Animation
1460
1502
 
1461
1503
  ```js
@@ -1474,9 +1516,24 @@ const eqn = figure.add({
1474
1516
  });
1475
1517
 
1476
1518
  eqn.showForm('1');
1519
+ eqn.showForm('1', false); // notify=false suppresses the formChanged event for this call
1477
1520
  eqn.goToForm({ form: '2', delay: 1, duration: 1.5, animate: 'move' });
1478
1521
  eqn.nextForm(); // Navigate formSeries
1479
1522
  eqn.prevForm();
1523
+
1524
+ // Element lookup within forms
1525
+ eqn.getFormElements(formName, includeHidden?); // All elements in a form
1526
+ eqn.getPhraseElements(phrase); // All elements in a phrase
1527
+ // Elements inside a named layout function (any function tagged with `name`).
1528
+ // (name, formName? = current, mode? = 'all', includeHidden? = false).
1529
+ // mode 'first' = first match; 'all' = de-duplicated union across all matches.
1530
+ eqn.getFunctionElements('myFrac');
1531
+ ```
1532
+
1533
+ `Equation` publishes a `formChanged` notification whenever the displayed form may have changed, with payload `{ phase, form, fromForm?, progress? }`. `phase` is one of: `'showForm'` (form set via `showForm`; suppress with `notify: false`), `'goToFormStart'`, `'goToFormStep'` (per animation frame, with `progress` 0–1; a final step with `progress: 1` precedes the end), `'goToFormEnd'`. `fromForm` is present only on the `goToForm*` phases.
1534
+
1535
+ ```js
1536
+ eqn.notifications.add('formChanged', ({ phase, form, progress }) => { /* drive UI */ });
1480
1537
  ```
1481
1538
 
1482
1539
  ### Phrases (reusable sub-expressions)
@@ -1488,6 +1545,14 @@ eqn.prevForm();
1488
1545
  }
1489
1546
  ```
1490
1547
 
1548
+ ### LaTeX Parsing
1549
+ `Fig.latexToFigureOne(latex)` converts a LaTeX math expression into `{ elements, form }` for use in an equation definition (basic support).
1550
+
1551
+ ```js
1552
+ const { elements, form } = Fig.latexToFigureOne('\\frac{a}{b} = c');
1553
+ figure.add({ make: 'equation', elements, forms: { base: form } });
1554
+ ```
1555
+
1491
1556
  ---
1492
1557
 
1493
1558
  ## 7. Animation System
package/llms.txt CHANGED
@@ -24,6 +24,8 @@ figure.add({ make: 'triangle', width: 0.5, height: 0.5, color: [1, 0, 0, 1] });
24
24
 
25
25
  Colors are `[r, g, b, a]` with values 0-1. Coordinates default to a scene of `[-1, -1, 2, 2]` (x, y, width, height). Override with `new Fig.Figure({ scene: [-2, -2, 4, 4] })`.
26
26
 
27
+ Other `Fig.Figure` options: `textStyle` (`'italic'` default | `'normal'` — default equation text style), `antialias` (default `true`), `atlasScale` (GL text atlas resolution, default `2`), `onWebGLUnavailable` (callback if no WebGL context). Check `figure.webglAvailable` and subscribe to `contextLost` / `contextRestored` notifications for runtime WebGL context transitions.
28
+
27
29
  ## Core Concepts
28
30
 
29
31
  - **Figure** — top-level container that manages all elements and rendering
@@ -105,6 +107,9 @@ All elements accept these common options alongside shape-specific ones:
105
107
  - `color` — `[r, g, b, a]`
106
108
  - `position` — `[x, y]` shorthand for translation
107
109
  - `rotation` — rotation in radians
110
+ - `isFormIgnored` — exclude from equation form changes (its transform/color/visibility persist across `showForm`/`goToForm`)
111
+ - `allowSetColor` — `'all'` (default), `'opacity'` (alpha only), or `'none'` to freeze color
112
+ - `ignoreSetColor` — source label(s) whose tagged `setColor` is ignored (e.g. the equation's `'form'` color cascade), while explicit commands still apply
108
113
 
109
114
  When `options` is used, shape-specific properties go inside it:
110
115
 
@@ -256,9 +261,14 @@ Any element type can be created inline in forms using `make`:
256
261
  | `prodOf` | `{ prodOf: { symbol, content, from, to } }` | Product |
257
262
  | `scale` | `{ scale: [content, scale_factor] }` | Scale content |
258
263
  | `color` | `{ color: [content, [r,g,b,a]] }` | Color content |
264
+ | `opacity` | `{ opacity: [content, 0.3] }` | Opacity multiplier (cascades multiplicatively through nesting) |
265
+ | `front` | `{ front: [content, num] }` | Bring content forward in draw stack (per-form); supports `before`/`after` anchors |
266
+ | `back` | `{ back: [content, num] }` | Send content back in draw stack (per-form); supports `before`/`after` anchors |
259
267
  | `container` | `{ container: { content, width, ... } }` | Fixed-size container |
260
268
  | `lines` | `{ lines: { content: [...], justify } }` | Multi-line layout |
261
269
 
270
+ Any layout function also accepts a `name` label to address its elements via `eqn.getFunctionElements(name)`. Form objects accept `ignoreColor` / `ignoreOpacity` to preserve externally-set element color/opacity (suppress the cascade).
271
+
262
272
  ### Symbols
263
273
 
264
274
  Define symbols in `elements` with `{ symbol: 'type' }`:
@@ -302,9 +312,12 @@ const eqn = figure.add({
302
312
  });
303
313
 
304
314
  eqn.showForm('1');
315
+ eqn.showForm('1', false); // notify=false suppresses the formChanged event
305
316
  eqn.goToForm({ form: '2', delay: 1, duration: 1.5, animate: 'move' });
306
317
  ```
307
318
 
319
+ Equation publishes a `formChanged` notification with payload `{ phase, form, fromForm?, progress? }`, where `phase` is `'showForm'`, `'goToFormStart'`, `'goToFormStep'` (with `progress` 0–1), or `'goToFormEnd'`. Use `eqn.getFunctionElements(name)` to fetch elements inside a named layout function.
320
+
308
321
  Use `formSeries` to define an ordered list of forms, then navigate with `eqn.nextForm()` and `eqn.prevForm()`.
309
322
 
310
323
  Use `phrases` to define reusable sub-expressions:
@@ -529,6 +542,10 @@ new Fig.Transform() // Transform builder
529
542
  .scale(sx, sy)
530
543
  Fig.round(value, precision) // Round to N decimal places
531
544
 
545
+ // Convert a LaTeX math expression to an equation form (basic support)
546
+ const { elements, form } = Fig.latexToFigureOne('\\frac{a}{b} = c');
547
+ figure.add({ make: 'equation', elements, forms: { base: form } });
548
+
532
549
  // Color format: [r, g, b, a] with values 0 to 1
533
550
  // [1, 0, 0, 1] = red, [0, 0, 1, 0.5] = semi-transparent blue
534
551
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "figureone",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Draw, animate and interact with shapes, text, plots and equations in Javascript. Create interactive slide shows, and interactive videos.",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",