@teachinglab/omd 0.6.1 → 0.6.3

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.
Files changed (198) hide show
  1. package/README.md +257 -251
  2. package/README.old.md +137 -137
  3. package/canvas/core/canvasConfig.js +202 -202
  4. package/canvas/drawing/segment.js +167 -167
  5. package/canvas/drawing/stroke.js +385 -385
  6. package/canvas/events/eventManager.js +444 -444
  7. package/canvas/events/pointerEventHandler.js +262 -262
  8. package/canvas/index.js +48 -48
  9. package/canvas/tools/PointerTool.js +71 -71
  10. package/canvas/tools/tool.js +222 -222
  11. package/canvas/utils/boundingBox.js +377 -377
  12. package/canvas/utils/mathUtils.js +258 -258
  13. package/docs/api/configuration-options.md +198 -198
  14. package/docs/api/eventManager.md +82 -82
  15. package/docs/api/focusFrameManager.md +144 -144
  16. package/docs/api/index.md +105 -105
  17. package/docs/api/main.md +62 -62
  18. package/docs/api/omdBinaryExpressionNode.md +86 -86
  19. package/docs/api/omdCanvas.md +83 -83
  20. package/docs/api/omdConfigManager.md +112 -112
  21. package/docs/api/omdConstantNode.md +52 -52
  22. package/docs/api/omdDisplay.md +87 -87
  23. package/docs/api/omdEquationNode.md +174 -174
  24. package/docs/api/omdEquationSequenceNode.md +258 -258
  25. package/docs/api/omdEquationStack.md +192 -192
  26. package/docs/api/omdFunctionNode.md +82 -82
  27. package/docs/api/omdGroupNode.md +78 -78
  28. package/docs/api/omdHelpers.md +87 -87
  29. package/docs/api/omdLeafNode.md +85 -85
  30. package/docs/api/omdNode.md +201 -201
  31. package/docs/api/omdOperationDisplayNode.md +117 -117
  32. package/docs/api/omdOperatorNode.md +91 -91
  33. package/docs/api/omdParenthesisNode.md +133 -133
  34. package/docs/api/omdPopup.md +191 -191
  35. package/docs/api/omdPowerNode.md +131 -131
  36. package/docs/api/omdRationalNode.md +144 -144
  37. package/docs/api/omdSequenceNode.md +128 -128
  38. package/docs/api/omdSimplification.md +78 -78
  39. package/docs/api/omdSqrtNode.md +144 -144
  40. package/docs/api/omdStepVisualizer.md +146 -146
  41. package/docs/api/omdStepVisualizerHighlighting.md +65 -65
  42. package/docs/api/omdStepVisualizerInteractiveSteps.md +108 -108
  43. package/docs/api/omdStepVisualizerLayout.md +70 -70
  44. package/docs/api/omdStepVisualizerNodeUtils.md +140 -140
  45. package/docs/api/omdStepVisualizerTextBoxes.md +76 -76
  46. package/docs/api/omdToolbar.md +130 -130
  47. package/docs/api/omdTranscriptionService.md +95 -95
  48. package/docs/api/omdTreeDiff.md +169 -169
  49. package/docs/api/omdUnaryExpressionNode.md +137 -137
  50. package/docs/api/omdUtilities.md +82 -82
  51. package/docs/api/omdVariableNode.md +123 -123
  52. package/docs/api/selectTool.md +74 -74
  53. package/docs/api/simplificationEngine.md +97 -97
  54. package/docs/api/simplificationRules.md +76 -76
  55. package/docs/api/simplificationUtils.md +64 -64
  56. package/docs/api/transcribe.md +43 -43
  57. package/docs/api-reference.md +85 -85
  58. package/docs/index.html +453 -453
  59. package/docs/index.md +38 -38
  60. package/docs/omd-objects.md +258 -258
  61. package/index.js +79 -79
  62. package/jsvg/index.js +3 -0
  63. package/jsvg/jsvg.js +898 -898
  64. package/jsvg/jsvgComponents.js +357 -358
  65. package/npm-docs/DOCUMENTATION_SUMMARY.md +220 -220
  66. package/npm-docs/README.md +251 -251
  67. package/npm-docs/api/api-reference.md +85 -85
  68. package/npm-docs/api/configuration-options.md +198 -198
  69. package/npm-docs/api/eventManager.md +82 -82
  70. package/npm-docs/api/expression-nodes.md +561 -561
  71. package/npm-docs/api/focusFrameManager.md +144 -144
  72. package/npm-docs/api/index.md +105 -105
  73. package/npm-docs/api/main.md +62 -62
  74. package/npm-docs/api/omdBinaryExpressionNode.md +86 -86
  75. package/npm-docs/api/omdCanvas.md +83 -83
  76. package/npm-docs/api/omdConfigManager.md +112 -112
  77. package/npm-docs/api/omdConstantNode.md +52 -52
  78. package/npm-docs/api/omdDisplay.md +87 -87
  79. package/npm-docs/api/omdEquationNode.md +174 -174
  80. package/npm-docs/api/omdEquationSequenceNode.md +258 -258
  81. package/npm-docs/api/omdEquationStack.md +192 -192
  82. package/npm-docs/api/omdFunctionNode.md +82 -82
  83. package/npm-docs/api/omdGroupNode.md +78 -78
  84. package/npm-docs/api/omdHelpers.md +87 -87
  85. package/npm-docs/api/omdLeafNode.md +85 -85
  86. package/npm-docs/api/omdNode.md +201 -201
  87. package/npm-docs/api/omdOperationDisplayNode.md +117 -117
  88. package/npm-docs/api/omdOperatorNode.md +91 -91
  89. package/npm-docs/api/omdParenthesisNode.md +133 -133
  90. package/npm-docs/api/omdPopup.md +191 -191
  91. package/npm-docs/api/omdPowerNode.md +131 -131
  92. package/npm-docs/api/omdRationalNode.md +144 -144
  93. package/npm-docs/api/omdSequenceNode.md +128 -128
  94. package/npm-docs/api/omdSimplification.md +78 -78
  95. package/npm-docs/api/omdSqrtNode.md +144 -144
  96. package/npm-docs/api/omdStepVisualizer.md +146 -146
  97. package/npm-docs/api/omdStepVisualizerHighlighting.md +65 -65
  98. package/npm-docs/api/omdStepVisualizerInteractiveSteps.md +108 -108
  99. package/npm-docs/api/omdStepVisualizerLayout.md +70 -70
  100. package/npm-docs/api/omdStepVisualizerNodeUtils.md +140 -140
  101. package/npm-docs/api/omdStepVisualizerTextBoxes.md +76 -76
  102. package/npm-docs/api/omdToolbar.md +130 -130
  103. package/npm-docs/api/omdTranscriptionService.md +95 -95
  104. package/npm-docs/api/omdTreeDiff.md +169 -169
  105. package/npm-docs/api/omdUnaryExpressionNode.md +137 -137
  106. package/npm-docs/api/omdUtilities.md +82 -82
  107. package/npm-docs/api/omdVariableNode.md +123 -123
  108. package/npm-docs/api/selectTool.md +74 -74
  109. package/npm-docs/api/simplificationEngine.md +97 -97
  110. package/npm-docs/api/simplificationRules.md +76 -76
  111. package/npm-docs/api/simplificationUtils.md +64 -64
  112. package/npm-docs/api/transcribe.md +43 -43
  113. package/npm-docs/guides/equations.md +854 -854
  114. package/npm-docs/guides/factory-functions.md +354 -354
  115. package/npm-docs/guides/getting-started.md +318 -318
  116. package/npm-docs/guides/quick-examples.md +525 -525
  117. package/npm-docs/guides/visualizations.md +682 -682
  118. package/npm-docs/index.html +12 -0
  119. package/npm-docs/json-schemas.md +826 -826
  120. package/omd/config/omdConfigManager.js +279 -267
  121. package/omd/core/index.js +158 -158
  122. package/omd/core/omdEquationStack.js +606 -547
  123. package/omd/core/omdUtilities.js +113 -113
  124. package/omd/display/omdDisplay.js +1045 -963
  125. package/omd/display/omdToolbar.js +501 -501
  126. package/omd/nodes/omdBinaryExpressionNode.js +459 -459
  127. package/omd/nodes/omdConstantNode.js +141 -141
  128. package/omd/nodes/omdEquationNode.js +1327 -1327
  129. package/omd/nodes/omdFunctionNode.js +351 -351
  130. package/omd/nodes/omdGroupNode.js +67 -67
  131. package/omd/nodes/omdLeafNode.js +76 -76
  132. package/omd/nodes/omdNode.js +556 -556
  133. package/omd/nodes/omdOperationDisplayNode.js +321 -321
  134. package/omd/nodes/omdOperatorNode.js +108 -108
  135. package/omd/nodes/omdParenthesisNode.js +292 -292
  136. package/omd/nodes/omdPowerNode.js +235 -235
  137. package/omd/nodes/omdRationalNode.js +295 -295
  138. package/omd/nodes/omdSqrtNode.js +307 -307
  139. package/omd/nodes/omdUnaryExpressionNode.js +227 -227
  140. package/omd/nodes/omdVariableNode.js +122 -122
  141. package/omd/simplification/omdSimplification.js +140 -140
  142. package/omd/simplification/omdSimplificationEngine.js +887 -887
  143. package/omd/simplification/package.json +5 -5
  144. package/omd/simplification/rules/binaryRules.js +1037 -1037
  145. package/omd/simplification/rules/functionRules.js +111 -111
  146. package/omd/simplification/rules/index.js +48 -48
  147. package/omd/simplification/rules/parenthesisRules.js +19 -19
  148. package/omd/simplification/rules/powerRules.js +143 -143
  149. package/omd/simplification/rules/rationalRules.js +725 -725
  150. package/omd/simplification/rules/sqrtRules.js +48 -48
  151. package/omd/simplification/rules/unaryRules.js +37 -37
  152. package/omd/simplification/simplificationRules.js +31 -31
  153. package/omd/simplification/simplificationUtils.js +1055 -1055
  154. package/omd/step-visualizer/omdStepVisualizer.js +947 -947
  155. package/omd/step-visualizer/omdStepVisualizerHighlighting.js +246 -246
  156. package/omd/step-visualizer/omdStepVisualizerLayout.js +892 -892
  157. package/omd/step-visualizer/omdStepVisualizerTextBoxes.js +200 -200
  158. package/omd/utils/aiNextEquationStep.js +106 -106
  159. package/omd/utils/omdNodeOverlay.js +638 -638
  160. package/omd/utils/omdPopup.js +1203 -1203
  161. package/omd/utils/omdStepVisualizerInteractiveSteps.js +684 -684
  162. package/omd/utils/omdStepVisualizerNodeUtils.js +267 -267
  163. package/omd/utils/omdTranscriptionService.js +123 -123
  164. package/omd/utils/omdTreeDiff.js +733 -733
  165. package/package.json +59 -57
  166. package/readme.html +184 -120
  167. package/src/index.js +74 -74
  168. package/src/json-schemas.md +576 -576
  169. package/src/omd-json-samples.js +147 -147
  170. package/src/omdApp.js +391 -391
  171. package/src/omdAppCanvas.js +335 -335
  172. package/src/omdBalanceHanger.js +199 -199
  173. package/src/omdColor.js +13 -13
  174. package/src/omdCoordinatePlane.js +541 -541
  175. package/src/omdExpression.js +115 -115
  176. package/src/omdFactory.js +150 -150
  177. package/src/omdFunction.js +114 -114
  178. package/src/omdMetaExpression.js +290 -290
  179. package/src/omdNaturalExpression.js +563 -563
  180. package/src/omdNode.js +383 -383
  181. package/src/omdNumber.js +52 -52
  182. package/src/omdNumberLine.js +114 -112
  183. package/src/omdNumberTile.js +118 -118
  184. package/src/omdOperator.js +72 -72
  185. package/src/omdPowerExpression.js +91 -91
  186. package/src/omdProblem.js +259 -259
  187. package/src/omdRatioChart.js +251 -251
  188. package/src/omdRationalExpression.js +114 -114
  189. package/src/omdSampleData.js +215 -215
  190. package/src/omdShapes.js +512 -512
  191. package/src/omdSpinner.js +151 -151
  192. package/src/omdString.js +49 -49
  193. package/src/omdTable.js +498 -498
  194. package/src/omdTapeDiagram.js +244 -244
  195. package/src/omdTerm.js +91 -91
  196. package/src/omdTileEquation.js +349 -349
  197. package/src/omdUtils.js +84 -84
  198. package/src/omdVariable.js +51 -51
@@ -1,826 +1,826 @@
1
- # JSON Schemas for OMD Components
2
-
3
- This document provides complete JSON schemas and examples for all OMD visual components. Use these with the `loadFromJSON()` method.
4
-
5
- ## Table of Contents
6
-
7
- 1. [Global Context & Configuration](#global-context--configuration)
8
- 2. [Visualizations](#visualizations)
9
- - [Number & Ratio Visualizations](#number--ratio-visualizations)
10
- - [Graphing & Geometry](#graphing--geometry)
11
- - [Data Display](#data-display)
12
- 3. [Equations & Expressions](#equations--expressions)
13
- - [Core Components](#core-components)
14
- - [Advanced Expressions](#advanced-expressions)
15
-
16
- ---
17
-
18
- ## Global Context & Configuration
19
-
20
- ### Common Expression Format
21
-
22
- Many components accept expressions in multiple formats:
23
-
24
- **String Format** (simplest):
25
- ```javascript
26
- "2x + 3"
27
- ```
28
-
29
- **Structured Format** (programmatic):
30
- ```json
31
- {
32
- "termsAndOpers": [
33
- { "omdType": "term", "coefficient": 2, "variable": "x", "exponent": 1 },
34
- { "omdType": "operator", "operator": "+" },
35
- { "omdType": "number", "value": 3 }
36
- ]
37
- }
38
- ```
39
-
40
- ### Primitive Types
41
-
42
- #### `omdNumber`
43
- ```json
44
- {
45
- "omdType": "number",
46
- "value": 42
47
- }
48
- ```
49
-
50
- #### `omdVariable`
51
- ```json
52
- {
53
- "omdType": "variable",
54
- "name": "x"
55
- }
56
- ```
57
-
58
- #### `omdOperator`
59
- ```json
60
- {
61
- "omdType": "operator",
62
- "operator": "+"
63
- }
64
- ```
65
- Supported operators: `+`, `-`, `/`, `÷`, `x`, `*`, `•`, `×`, `=`
66
-
67
- #### `omdTerm`
68
- ```json
69
- {
70
- "omdType": "term",
71
- "coefficient": 3,
72
- "variable": "x",
73
- "exponent": 2
74
- }
75
- ```
76
-
77
- ---
78
-
79
- ## Visualizations
80
-
81
- ### Number & Ratio Visualizations
82
-
83
- #### `omdNumberLine`
84
-
85
- Interactive number line with labeled ticks and optional dots.
86
-
87
- **Schema:**
88
- ```typescript
89
- {
90
- min: number,
91
- max: number,
92
- dotValues?: number[],
93
- label?: string
94
- }
95
- ```
96
-
97
- **Example:**
98
- ```json
99
- {
100
- "min": 0,
101
- "max": 10,
102
- "dotValues": [2, 5, 8],
103
- "label": "Number Line Example"
104
- }
105
- ```
106
-
107
- **Usage:**
108
- ```javascript
109
- const numberLine = new omdNumberLine();
110
- numberLine.loadFromJSON({
111
- min: 0,
112
- max: 10,
113
- dotValues: [2, 5, 8],
114
- label: "Number Line Example"
115
- });
116
- ```
117
-
118
- ---
119
-
120
- #### `omdNumberTile`
121
-
122
- Visual tile with dots for counting and grouping activities.
123
-
124
- **Schema:**
125
- ```typescript
126
- {
127
- value: number,
128
- size?: "small" | "medium" | "large",
129
- dotsPerColumn?: number,
130
- backgroundColor?: string,
131
- dotColor?: string
132
- }
133
- ```
134
-
135
- **Example:**
136
- ```json
137
- {
138
- "value": 10,
139
- "size": "medium",
140
- "dotsPerColumn": 5,
141
- "backgroundColor": "#FFFFFF",
142
- "dotColor": "#000000"
143
- }
144
- ```
145
-
146
- ---
147
-
148
- #### `omdTapeDiagram`
149
-
150
- Part-whole relationship diagrams with labeled sections.
151
-
152
- **Schema:**
153
- ```typescript
154
- {
155
- values: number[],
156
- showValues?: boolean,
157
- colors?: string[],
158
- labelSet?: Array<{
159
- startIndex: number,
160
- endIndex: number,
161
- label: string,
162
- showBelow?: boolean
163
- }>,
164
- unitWidth?: number
165
- }
166
- ```
167
-
168
- **Example:**
169
- ```json
170
- {
171
- "values": [1, 2, 3],
172
- "showValues": true,
173
- "colors": ["#FF0000", "#00FF00", "#0000FF"],
174
- "labelSet": [
175
- {
176
- "startIndex": 0,
177
- "endIndex": 2,
178
- "label": "Total: 6",
179
- "showBelow": true
180
- }
181
- ],
182
- "unitWidth": 30
183
- }
184
- ```
185
-
186
- ---
187
-
188
- #### `omdRatioChart`
189
-
190
- Pie and bar chart ratio visualizations.
191
-
192
- **Schema:**
193
- ```typescript
194
- {
195
- valueA: number,
196
- valueB: number,
197
- renderType?: "pie" | "bar",
198
- size?: "small" | "medium" | "large"
199
- }
200
- ```
201
-
202
- **Example:**
203
- ```json
204
- {
205
- "valueA": 3,
206
- "valueB": 2,
207
- "renderType": "pie",
208
- "size": "medium"
209
- }
210
- ```
211
-
212
- ---
213
-
214
- #### `omdBalanceHanger`
215
-
216
- Balance scale visualizations.
217
-
218
- **Schema:**
219
- ```typescript
220
- {
221
- leftValues: number[],
222
- rightValues: number[],
223
- tilt?: "left" | "right" | "balanced"
224
- }
225
- ```
226
-
227
- **Example:**
228
- ```json
229
- {
230
- "leftValues": [5, 3],
231
- "rightValues": [4, 4],
232
- "tilt": "balanced"
233
- }
234
- ```
235
-
236
- ---
237
-
238
- ### Graphing & Geometry
239
-
240
- #### `omdCoordinatePlane`
241
-
242
- 2D coordinate plane with axes, gridlines, functions, shapes, and plots.
243
-
244
- **Schema:**
245
- ```typescript
246
- {
247
- graphEquations?: Array<{
248
- equation: string,
249
- color?: string,
250
- strokeWidth?: number,
251
- domain?: { min: number, max: number }
252
- }>,
253
- lineSegments?: Array<{
254
- point1: [number, number],
255
- point2: [number, number],
256
- color?: string,
257
- strokeWidth?: number
258
- }>,
259
- dotValues?: Array<[number, number, string?]>,
260
- shapeSet?: Array<ShapeObject>,
261
- xMin?: number,
262
- xMax?: number,
263
- yMin?: number,
264
- yMax?: number,
265
- xLabel?: string,
266
- yLabel?: string,
267
- axisLabelOffsetPx?: number,
268
- size?: "small" | "medium" | "large",
269
- tickInterval?: number,
270
- forceAllTickLabels?: boolean,
271
- tickLabelOffsetPx?: number,
272
- showTickLabels?: boolean,
273
- backgroundColor?: string,
274
- backgroundCornerRadius?: number,
275
- backgroundOpacity?: number,
276
- showBackground?: boolean
277
- }
278
- ```
279
-
280
- **Example:**
281
- ```json
282
- {
283
- "graphEquations": [
284
- {
285
- "equation": "y = x^2 - 4",
286
- "color": "#e11d48",
287
- "strokeWidth": 2,
288
- "domain": { "min": -5, "max": 5 }
289
- }
290
- ],
291
- "lineSegments": [
292
- {
293
- "point1": [0, 0],
294
- "point2": [1, 1],
295
- "color": "red",
296
- "strokeWidth": 2
297
- }
298
- ],
299
- "dotValues": [[0, 0, "green"], [1, 1, "blue"]],
300
- "xMin": -5,
301
- "xMax": 5,
302
- "yMin": -5,
303
- "yMax": 5,
304
- "xLabel": "X-Axis",
305
- "yLabel": "Y-Axis",
306
- "tickInterval": 1,
307
- "showTickLabels": true,
308
- "backgroundColor": "#FFFFFF",
309
- "showBackground": true
310
- }
311
- ```
312
-
313
- ---
314
-
315
- #### `omdShapes`
316
-
317
- Geometric shapes for visualization.
318
-
319
- **Circle:**
320
- ```json
321
- {
322
- "omdType": "circle",
323
- "radius": 10,
324
- "color": "#FF0000"
325
- }
326
- ```
327
-
328
- **Rectangle:**
329
- ```json
330
- {
331
- "omdType": "rectangle",
332
- "width": 20,
333
- "height": 10,
334
- "color": "#00FF00"
335
- }
336
- ```
337
-
338
- **Regular Polygon:**
339
- ```json
340
- {
341
- "omdType": "regularPolygon",
342
- "sides": 6,
343
- "radius": 15,
344
- "color": "#0000FF"
345
- }
346
- ```
347
-
348
- **Ellipse:**
349
- ```json
350
- {
351
- "omdType": "ellipse",
352
- "radiusX": 20,
353
- "radiusY": 10,
354
- "color": "#FFFF00"
355
- }
356
- ```
357
-
358
- **Right Triangle:**
359
- ```json
360
- {
361
- "omdType": "rightTriangle",
362
- "base": 10,
363
- "height": 15,
364
- "color": "#FF00FF"
365
- }
366
- ```
367
-
368
- **Isosceles Triangle:**
369
- ```json
370
- {
371
- "omdType": "isoscelesTriangle",
372
- "base": 10,
373
- "height": 15,
374
- "color": "#00FFFF"
375
- }
376
- ```
377
-
378
- ---
379
-
380
- #### `omdSpinner`
381
-
382
- Circular spinner for divisions and selections.
383
-
384
- **Schema:**
385
- ```typescript
386
- {
387
- divisions: number,
388
- arrowPosition: number,
389
- size?: "small" | "medium" | "large"
390
- }
391
- ```
392
-
393
- **Example:**
394
- ```json
395
- {
396
- "divisions": 8,
397
- "arrowPosition": 3,
398
- "size": "medium"
399
- }
400
- ```
401
-
402
- ---
403
-
404
- ### Data Display
405
-
406
- #### `omdTable`
407
-
408
- Tabular data display with customizable styling.
409
-
410
- **Schema:**
411
- ```typescript
412
- {
413
- equation?: string,
414
- data?: Array<[number, number]>,
415
- headers?: string[],
416
- xMin?: number,
417
- xMax?: number,
418
- stepSize?: number,
419
- title?: string,
420
- fontSize?: number,
421
- headerFontSize?: number,
422
- fontFamily?: string,
423
- headerFontFamily?: string,
424
- cellHeight?: number,
425
- headerHeight?: number,
426
- minCellWidth?: number,
427
- maxCellWidth?: number,
428
- padding?: number,
429
- backgroundColor?: string,
430
- backgroundCornerRadius?: number,
431
- backgroundOpacity?: number,
432
- showBackground?: boolean,
433
- alternatingRowColors?: string[]
434
- }
435
- ```
436
-
437
- **Example:**
438
- ```json
439
- {
440
- "equation": "y = x^2",
441
- "headers": ["x", "y"],
442
- "xMin": -5,
443
- "xMax": 5,
444
- "stepSize": 1,
445
- "title": "Quadratic Table",
446
- "fontSize": 14,
447
- "headerFontSize": 16,
448
- "fontFamily": "Albert Sans",
449
- "cellHeight": 35,
450
- "backgroundColor": "#FFFFFF",
451
- "alternatingRowColors": ["#F0F0F0", "#FFFFFF"]
452
- }
453
- ```
454
-
455
- ---
456
-
457
- ## Equations & Expressions
458
-
459
- ### Core Components
460
-
461
- #### `omdEquation`
462
-
463
- Complete mathematical equations with left and right sides.
464
-
465
- **Schema (String Form):**
466
- ```json
467
- {
468
- "equation": "2x + 3 = 11"
469
- }
470
- ```
471
-
472
- **Schema (Structured Form):**
473
- ```typescript
474
- {
475
- leftExpression: Expression | string,
476
- rightExpression: Expression | string,
477
- equation?: string
478
- }
479
- ```
480
-
481
- **Examples:**
482
- ```json
483
- {
484
- "equation": "2x + 3 = 11"
485
- }
486
- ```
487
-
488
- ```json
489
- {
490
- "leftExpression": {
491
- "termsAndOpers": [
492
- { "omdType": "term", "coefficient": 2, "variable": "x" },
493
- { "omdType": "operator", "operator": "+" },
494
- { "omdType": "number", "value": 3 }
495
- ]
496
- },
497
- "rightExpression": {
498
- "omdType": "number",
499
- "value": 11
500
- }
501
- }
502
- ```
503
-
504
- **Usage:**
505
- ```javascript
506
- // Simple string form
507
- const eq = new omdEquation();
508
- eq.loadFromJSON({ equation: '2x + 3 = 11' });
509
-
510
- // Structured form
511
- eq.loadFromJSON({
512
- leftExpression: { omdType: 'term', coefficient: 2, variable: 'x' },
513
- rightExpression: { omdType: 'number', value: 11 }
514
- });
515
- ```
516
-
517
- ---
518
-
519
- #### `omdExpression`
520
-
521
- Mathematical expressions (terms and operators).
522
-
523
- **Schema (String Form):**
524
- ```javascript
525
- "3x^2 + 5x - 2"
526
- ```
527
-
528
- **Schema (Structured Form):**
529
- ```typescript
530
- {
531
- termsAndOpers: Array<Term | Number | Variable | Operator>
532
- }
533
- ```
534
-
535
- **Example:**
536
- ```json
537
- {
538
- "termsAndOpers": [
539
- { "omdType": "term", "coefficient": 3, "variable": "x", "exponent": 2 },
540
- { "omdType": "operator", "operator": "+" },
541
- { "omdType": "term", "coefficient": 5, "variable": "x", "exponent": 1 },
542
- { "omdType": "operator", "operator": "-" },
543
- { "omdType": "number", "value": 2 }
544
- ]
545
- }
546
- ```
547
-
548
- ---
549
-
550
- #### `omdString`
551
-
552
- Simple string value for labels or annotations.
553
-
554
- **Schema:**
555
- ```typescript
556
- {
557
- name: string
558
- }
559
- ```
560
-
561
- **Example:**
562
- ```json
563
- {
564
- "name": "Example Label"
565
- }
566
- ```
567
-
568
- ---
569
-
570
- ### Advanced Expressions
571
-
572
- #### `omdPowerExpression`
573
-
574
- Expressions raised to a power (exponentiation).
575
-
576
- **Schema:**
577
- ```typescript
578
- {
579
- baseExpression: Expression | string,
580
- exponentExpression: Expression | string
581
- }
582
- ```
583
-
584
- **Example:**
585
- ```json
586
- {
587
- "baseExpression": {
588
- "termsAndOpers": [
589
- { "omdType": "variable", "name": "x" },
590
- { "omdType": "operator", "operator": "+" },
591
- { "omdType": "number", "value": 1 }
592
- ]
593
- },
594
- "exponentExpression": {
595
- "omdType": "number",
596
- "value": 2
597
- }
598
- }
599
- ```
600
-
601
- **Renders as:** `(x + 1)²`
602
-
603
- ---
604
-
605
- #### `omdRationalExpression`
606
-
607
- Fractions and rational expressions.
608
-
609
- **Schema:**
610
- ```typescript
611
- {
612
- numeratorExpression: Expression | string,
613
- denominatorExpression: Expression | string
614
- }
615
- ```
616
-
617
- **Example:**
618
- ```json
619
- {
620
- "numeratorExpression": {
621
- "termsAndOpers": [
622
- { "omdType": "variable", "name": "x" },
623
- { "omdType": "operator", "operator": "+" },
624
- { "omdType": "number", "value": 1 }
625
- ]
626
- },
627
- "denominatorExpression": {
628
- "termsAndOpers": [
629
- { "omdType": "variable", "name": "x" },
630
- { "omdType": "operator", "operator": "-" },
631
- { "omdType": "number", "value": 1 }
632
- ]
633
- }
634
- }
635
- ```
636
-
637
- **Renders as:** `(x + 1)/(x - 1)`
638
-
639
- ---
640
-
641
- #### `omdFunction`
642
-
643
- Mathematical functions with named inputs.
644
-
645
- **Schema:**
646
- ```typescript
647
- {
648
- name: string,
649
- inputVariables: string[],
650
- expression: Expression | string
651
- }
652
- ```
653
-
654
- **Example:**
655
- ```json
656
- {
657
- "name": "f",
658
- "inputVariables": ["x"],
659
- "expression": {
660
- "termsAndOpers": [
661
- { "omdType": "term", "coefficient": 2, "variable": "x" },
662
- { "omdType": "operator", "operator": "+" },
663
- { "omdType": "number", "value": 1 }
664
- ]
665
- }
666
- }
667
- ```
668
-
669
- **Renders as:** `f(x) = 2x + 1`
670
-
671
- ---
672
-
673
- #### `omdTileEquation`
674
-
675
- Visual tile-based equations.
676
-
677
- **Schema:**
678
- ```typescript
679
- {
680
- left: Array<TileSpec>,
681
- right: Array<TileSpec>,
682
- equation?: string,
683
- tileSize?: number,
684
- tileGap?: number,
685
- equalGap?: number,
686
- tileRadius?: number,
687
- showLabels?: boolean,
688
- fontFamily?: string,
689
- fontSize?: number,
690
- plusColor?: string,
691
- equalsColor?: string,
692
- xPillColor?: string,
693
- numberTileDefaults?: {
694
- backgroundColor?: string,
695
- dotColor?: string
696
- }
697
- }
698
- ```
699
-
700
- **Example:**
701
- ```json
702
- {
703
- "left": ["x", "x", 3],
704
- "right": [11],
705
- "equation": "2x + 3 = 11",
706
- "tileSize": 28,
707
- "tileGap": 6,
708
- "showLabels": true,
709
- "fontFamily": "Albert Sans",
710
- "fontSize": 16
711
- }
712
- ```
713
-
714
- ---
715
-
716
- #### `omdProblem`
717
-
718
- Problem statement with associated visualization.
719
-
720
- **Schema:**
721
- ```typescript
722
- {
723
- problemText: string,
724
- visualization: any
725
- }
726
- ```
727
-
728
- **Example:**
729
- ```json
730
- {
731
- "problemText": "Solve for x:",
732
- "visualization": {
733
- "omdType": "equation",
734
- "equation": "2x + 3 = 11"
735
- }
736
- }
737
- ```
738
-
739
- ---
740
-
741
- ## Usage Patterns
742
-
743
- ### Loading from JSON
744
-
745
- All components follow the same pattern:
746
-
747
- ```javascript
748
- const component = new ComponentClass();
749
- component.loadFromJSON(jsonData);
750
- ```
751
-
752
- ### String vs. Structured
753
-
754
- Many components accept both:
755
-
756
- ```javascript
757
- // String form (simple)
758
- equation.loadFromJSON({ equation: '2x + 3 = 11' });
759
-
760
- // Structured form (programmatic)
761
- equation.loadFromJSON({
762
- leftExpression: { termsAndOpers: [...] },
763
- rightExpression: { termsAndOpers: [...] }
764
- });
765
- ```
766
-
767
- ### Nested Components
768
-
769
- Components can be nested:
770
-
771
- ```javascript
772
- const plane = new omdCoordinatePlane();
773
- plane.loadFromJSON({
774
- xMin: -10,
775
- xMax: 10,
776
- yMin: -10,
777
- yMax: 10,
778
- shapeSet: [
779
- { omdType: 'circle', radius: 5, color: 'blue' },
780
- { omdType: 'rectangle', width: 10, height: 5, color: 'red' }
781
- ]
782
- });
783
- ```
784
-
785
- ---
786
-
787
- ## Type Definitions
788
-
789
- For TypeScript users, the general pattern is:
790
-
791
- ```typescript
792
- type Expression = string | {
793
- termsAndOpers: Array<Term | Number | Variable | Operator>
794
- };
795
-
796
- type Term = {
797
- omdType: 'term',
798
- coefficient: number,
799
- variable?: string,
800
- exponent?: number
801
- };
802
-
803
- type Number = {
804
- omdType: 'number',
805
- value: number
806
- };
807
-
808
- type Variable = {
809
- omdType: 'variable',
810
- name: string
811
- };
812
-
813
- type Operator = {
814
- omdType: 'operator',
815
- operator: '+' | '-' | '/' | '÷' | 'x' | '*' | '•' | '×' | '='
816
- };
817
- ```
818
-
819
- ---
820
-
821
- ## See Also
822
-
823
- - **[API Reference](./api/api-reference.md)** - Detailed API documentation
824
- - **[Getting Started](./guides/getting-started.md)** - Installation and basic usage
825
- - **[Visualizations Guide](./guides/visualizations.md)** - Visual component examples
826
- - **[Equations Guide](./guides/equations.md)** - Equation and expression examples
1
+ # JSON Schemas for OMD Components
2
+
3
+ This document provides complete JSON schemas and examples for all OMD visual components. Use these with the `loadFromJSON()` method.
4
+
5
+ ## Table of Contents
6
+
7
+ 1. [Global Context & Configuration](#global-context--configuration)
8
+ 2. [Visualizations](#visualizations)
9
+ - [Number & Ratio Visualizations](#number--ratio-visualizations)
10
+ - [Graphing & Geometry](#graphing--geometry)
11
+ - [Data Display](#data-display)
12
+ 3. [Equations & Expressions](#equations--expressions)
13
+ - [Core Components](#core-components)
14
+ - [Advanced Expressions](#advanced-expressions)
15
+
16
+ ---
17
+
18
+ ## Global Context & Configuration
19
+
20
+ ### Common Expression Format
21
+
22
+ Many components accept expressions in multiple formats:
23
+
24
+ **String Format** (simplest):
25
+ ```javascript
26
+ "2x + 3"
27
+ ```
28
+
29
+ **Structured Format** (programmatic):
30
+ ```json
31
+ {
32
+ "termsAndOpers": [
33
+ { "omdType": "term", "coefficient": 2, "variable": "x", "exponent": 1 },
34
+ { "omdType": "operator", "operator": "+" },
35
+ { "omdType": "number", "value": 3 }
36
+ ]
37
+ }
38
+ ```
39
+
40
+ ### Primitive Types
41
+
42
+ #### `omdNumber`
43
+ ```json
44
+ {
45
+ "omdType": "number",
46
+ "value": 42
47
+ }
48
+ ```
49
+
50
+ #### `omdVariable`
51
+ ```json
52
+ {
53
+ "omdType": "variable",
54
+ "name": "x"
55
+ }
56
+ ```
57
+
58
+ #### `omdOperator`
59
+ ```json
60
+ {
61
+ "omdType": "operator",
62
+ "operator": "+"
63
+ }
64
+ ```
65
+ Supported operators: `+`, `-`, `/`, `÷`, `x`, `*`, `•`, `×`, `=`
66
+
67
+ #### `omdTerm`
68
+ ```json
69
+ {
70
+ "omdType": "term",
71
+ "coefficient": 3,
72
+ "variable": "x",
73
+ "exponent": 2
74
+ }
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Visualizations
80
+
81
+ ### Number & Ratio Visualizations
82
+
83
+ #### `omdNumberLine`
84
+
85
+ Interactive number line with labeled ticks and optional dots.
86
+
87
+ **Schema:**
88
+ ```typescript
89
+ {
90
+ min: number,
91
+ max: number,
92
+ dotValues?: number[],
93
+ label?: string
94
+ }
95
+ ```
96
+
97
+ **Example:**
98
+ ```json
99
+ {
100
+ "min": 0,
101
+ "max": 10,
102
+ "dotValues": [2, 5, 8],
103
+ "label": "Number Line Example"
104
+ }
105
+ ```
106
+
107
+ **Usage:**
108
+ ```javascript
109
+ const numberLine = new omdNumberLine();
110
+ numberLine.loadFromJSON({
111
+ min: 0,
112
+ max: 10,
113
+ dotValues: [2, 5, 8],
114
+ label: "Number Line Example"
115
+ });
116
+ ```
117
+
118
+ ---
119
+
120
+ #### `omdNumberTile`
121
+
122
+ Visual tile with dots for counting and grouping activities.
123
+
124
+ **Schema:**
125
+ ```typescript
126
+ {
127
+ value: number,
128
+ size?: "small" | "medium" | "large",
129
+ dotsPerColumn?: number,
130
+ backgroundColor?: string,
131
+ dotColor?: string
132
+ }
133
+ ```
134
+
135
+ **Example:**
136
+ ```json
137
+ {
138
+ "value": 10,
139
+ "size": "medium",
140
+ "dotsPerColumn": 5,
141
+ "backgroundColor": "#FFFFFF",
142
+ "dotColor": "#000000"
143
+ }
144
+ ```
145
+
146
+ ---
147
+
148
+ #### `omdTapeDiagram`
149
+
150
+ Part-whole relationship diagrams with labeled sections.
151
+
152
+ **Schema:**
153
+ ```typescript
154
+ {
155
+ values: number[],
156
+ showValues?: boolean,
157
+ colors?: string[],
158
+ labelSet?: Array<{
159
+ startIndex: number,
160
+ endIndex: number,
161
+ label: string,
162
+ showBelow?: boolean
163
+ }>,
164
+ unitWidth?: number
165
+ }
166
+ ```
167
+
168
+ **Example:**
169
+ ```json
170
+ {
171
+ "values": [1, 2, 3],
172
+ "showValues": true,
173
+ "colors": ["#FF0000", "#00FF00", "#0000FF"],
174
+ "labelSet": [
175
+ {
176
+ "startIndex": 0,
177
+ "endIndex": 2,
178
+ "label": "Total: 6",
179
+ "showBelow": true
180
+ }
181
+ ],
182
+ "unitWidth": 30
183
+ }
184
+ ```
185
+
186
+ ---
187
+
188
+ #### `omdRatioChart`
189
+
190
+ Pie and bar chart ratio visualizations.
191
+
192
+ **Schema:**
193
+ ```typescript
194
+ {
195
+ valueA: number,
196
+ valueB: number,
197
+ renderType?: "pie" | "bar",
198
+ size?: "small" | "medium" | "large"
199
+ }
200
+ ```
201
+
202
+ **Example:**
203
+ ```json
204
+ {
205
+ "valueA": 3,
206
+ "valueB": 2,
207
+ "renderType": "pie",
208
+ "size": "medium"
209
+ }
210
+ ```
211
+
212
+ ---
213
+
214
+ #### `omdBalanceHanger`
215
+
216
+ Balance scale visualizations.
217
+
218
+ **Schema:**
219
+ ```typescript
220
+ {
221
+ leftValues: number[],
222
+ rightValues: number[],
223
+ tilt?: "left" | "right" | "balanced"
224
+ }
225
+ ```
226
+
227
+ **Example:**
228
+ ```json
229
+ {
230
+ "leftValues": [5, 3],
231
+ "rightValues": [4, 4],
232
+ "tilt": "balanced"
233
+ }
234
+ ```
235
+
236
+ ---
237
+
238
+ ### Graphing & Geometry
239
+
240
+ #### `omdCoordinatePlane`
241
+
242
+ 2D coordinate plane with axes, gridlines, functions, shapes, and plots.
243
+
244
+ **Schema:**
245
+ ```typescript
246
+ {
247
+ graphEquations?: Array<{
248
+ equation: string,
249
+ color?: string,
250
+ strokeWidth?: number,
251
+ domain?: { min: number, max: number }
252
+ }>,
253
+ lineSegments?: Array<{
254
+ point1: [number, number],
255
+ point2: [number, number],
256
+ color?: string,
257
+ strokeWidth?: number
258
+ }>,
259
+ dotValues?: Array<[number, number, string?]>,
260
+ shapeSet?: Array<ShapeObject>,
261
+ xMin?: number,
262
+ xMax?: number,
263
+ yMin?: number,
264
+ yMax?: number,
265
+ xLabel?: string,
266
+ yLabel?: string,
267
+ axisLabelOffsetPx?: number,
268
+ size?: "small" | "medium" | "large",
269
+ tickInterval?: number,
270
+ forceAllTickLabels?: boolean,
271
+ tickLabelOffsetPx?: number,
272
+ showTickLabels?: boolean,
273
+ backgroundColor?: string,
274
+ backgroundCornerRadius?: number,
275
+ backgroundOpacity?: number,
276
+ showBackground?: boolean
277
+ }
278
+ ```
279
+
280
+ **Example:**
281
+ ```json
282
+ {
283
+ "graphEquations": [
284
+ {
285
+ "equation": "y = x^2 - 4",
286
+ "color": "#e11d48",
287
+ "strokeWidth": 2,
288
+ "domain": { "min": -5, "max": 5 }
289
+ }
290
+ ],
291
+ "lineSegments": [
292
+ {
293
+ "point1": [0, 0],
294
+ "point2": [1, 1],
295
+ "color": "red",
296
+ "strokeWidth": 2
297
+ }
298
+ ],
299
+ "dotValues": [[0, 0, "green"], [1, 1, "blue"]],
300
+ "xMin": -5,
301
+ "xMax": 5,
302
+ "yMin": -5,
303
+ "yMax": 5,
304
+ "xLabel": "X-Axis",
305
+ "yLabel": "Y-Axis",
306
+ "tickInterval": 1,
307
+ "showTickLabels": true,
308
+ "backgroundColor": "#FFFFFF",
309
+ "showBackground": true
310
+ }
311
+ ```
312
+
313
+ ---
314
+
315
+ #### `omdShapes`
316
+
317
+ Geometric shapes for visualization.
318
+
319
+ **Circle:**
320
+ ```json
321
+ {
322
+ "omdType": "circle",
323
+ "radius": 10,
324
+ "color": "#FF0000"
325
+ }
326
+ ```
327
+
328
+ **Rectangle:**
329
+ ```json
330
+ {
331
+ "omdType": "rectangle",
332
+ "width": 20,
333
+ "height": 10,
334
+ "color": "#00FF00"
335
+ }
336
+ ```
337
+
338
+ **Regular Polygon:**
339
+ ```json
340
+ {
341
+ "omdType": "regularPolygon",
342
+ "sides": 6,
343
+ "radius": 15,
344
+ "color": "#0000FF"
345
+ }
346
+ ```
347
+
348
+ **Ellipse:**
349
+ ```json
350
+ {
351
+ "omdType": "ellipse",
352
+ "radiusX": 20,
353
+ "radiusY": 10,
354
+ "color": "#FFFF00"
355
+ }
356
+ ```
357
+
358
+ **Right Triangle:**
359
+ ```json
360
+ {
361
+ "omdType": "rightTriangle",
362
+ "base": 10,
363
+ "height": 15,
364
+ "color": "#FF00FF"
365
+ }
366
+ ```
367
+
368
+ **Isosceles Triangle:**
369
+ ```json
370
+ {
371
+ "omdType": "isoscelesTriangle",
372
+ "base": 10,
373
+ "height": 15,
374
+ "color": "#00FFFF"
375
+ }
376
+ ```
377
+
378
+ ---
379
+
380
+ #### `omdSpinner`
381
+
382
+ Circular spinner for divisions and selections.
383
+
384
+ **Schema:**
385
+ ```typescript
386
+ {
387
+ divisions: number,
388
+ arrowPosition: number,
389
+ size?: "small" | "medium" | "large"
390
+ }
391
+ ```
392
+
393
+ **Example:**
394
+ ```json
395
+ {
396
+ "divisions": 8,
397
+ "arrowPosition": 3,
398
+ "size": "medium"
399
+ }
400
+ ```
401
+
402
+ ---
403
+
404
+ ### Data Display
405
+
406
+ #### `omdTable`
407
+
408
+ Tabular data display with customizable styling.
409
+
410
+ **Schema:**
411
+ ```typescript
412
+ {
413
+ equation?: string,
414
+ data?: Array<[number, number]>,
415
+ headers?: string[],
416
+ xMin?: number,
417
+ xMax?: number,
418
+ stepSize?: number,
419
+ title?: string,
420
+ fontSize?: number,
421
+ headerFontSize?: number,
422
+ fontFamily?: string,
423
+ headerFontFamily?: string,
424
+ cellHeight?: number,
425
+ headerHeight?: number,
426
+ minCellWidth?: number,
427
+ maxCellWidth?: number,
428
+ padding?: number,
429
+ backgroundColor?: string,
430
+ backgroundCornerRadius?: number,
431
+ backgroundOpacity?: number,
432
+ showBackground?: boolean,
433
+ alternatingRowColors?: string[]
434
+ }
435
+ ```
436
+
437
+ **Example:**
438
+ ```json
439
+ {
440
+ "equation": "y = x^2",
441
+ "headers": ["x", "y"],
442
+ "xMin": -5,
443
+ "xMax": 5,
444
+ "stepSize": 1,
445
+ "title": "Quadratic Table",
446
+ "fontSize": 14,
447
+ "headerFontSize": 16,
448
+ "fontFamily": "Albert Sans",
449
+ "cellHeight": 35,
450
+ "backgroundColor": "#FFFFFF",
451
+ "alternatingRowColors": ["#F0F0F0", "#FFFFFF"]
452
+ }
453
+ ```
454
+
455
+ ---
456
+
457
+ ## Equations & Expressions
458
+
459
+ ### Core Components
460
+
461
+ #### `omdEquation`
462
+
463
+ Complete mathematical equations with left and right sides.
464
+
465
+ **Schema (String Form):**
466
+ ```json
467
+ {
468
+ "equation": "2x + 3 = 11"
469
+ }
470
+ ```
471
+
472
+ **Schema (Structured Form):**
473
+ ```typescript
474
+ {
475
+ leftExpression: Expression | string,
476
+ rightExpression: Expression | string,
477
+ equation?: string
478
+ }
479
+ ```
480
+
481
+ **Examples:**
482
+ ```json
483
+ {
484
+ "equation": "2x + 3 = 11"
485
+ }
486
+ ```
487
+
488
+ ```json
489
+ {
490
+ "leftExpression": {
491
+ "termsAndOpers": [
492
+ { "omdType": "term", "coefficient": 2, "variable": "x" },
493
+ { "omdType": "operator", "operator": "+" },
494
+ { "omdType": "number", "value": 3 }
495
+ ]
496
+ },
497
+ "rightExpression": {
498
+ "omdType": "number",
499
+ "value": 11
500
+ }
501
+ }
502
+ ```
503
+
504
+ **Usage:**
505
+ ```javascript
506
+ // Simple string form
507
+ const eq = new omdEquation();
508
+ eq.loadFromJSON({ equation: '2x + 3 = 11' });
509
+
510
+ // Structured form
511
+ eq.loadFromJSON({
512
+ leftExpression: { omdType: 'term', coefficient: 2, variable: 'x' },
513
+ rightExpression: { omdType: 'number', value: 11 }
514
+ });
515
+ ```
516
+
517
+ ---
518
+
519
+ #### `omdExpression`
520
+
521
+ Mathematical expressions (terms and operators).
522
+
523
+ **Schema (String Form):**
524
+ ```javascript
525
+ "3x^2 + 5x - 2"
526
+ ```
527
+
528
+ **Schema (Structured Form):**
529
+ ```typescript
530
+ {
531
+ termsAndOpers: Array<Term | Number | Variable | Operator>
532
+ }
533
+ ```
534
+
535
+ **Example:**
536
+ ```json
537
+ {
538
+ "termsAndOpers": [
539
+ { "omdType": "term", "coefficient": 3, "variable": "x", "exponent": 2 },
540
+ { "omdType": "operator", "operator": "+" },
541
+ { "omdType": "term", "coefficient": 5, "variable": "x", "exponent": 1 },
542
+ { "omdType": "operator", "operator": "-" },
543
+ { "omdType": "number", "value": 2 }
544
+ ]
545
+ }
546
+ ```
547
+
548
+ ---
549
+
550
+ #### `omdString`
551
+
552
+ Simple string value for labels or annotations.
553
+
554
+ **Schema:**
555
+ ```typescript
556
+ {
557
+ name: string
558
+ }
559
+ ```
560
+
561
+ **Example:**
562
+ ```json
563
+ {
564
+ "name": "Example Label"
565
+ }
566
+ ```
567
+
568
+ ---
569
+
570
+ ### Advanced Expressions
571
+
572
+ #### `omdPowerExpression`
573
+
574
+ Expressions raised to a power (exponentiation).
575
+
576
+ **Schema:**
577
+ ```typescript
578
+ {
579
+ baseExpression: Expression | string,
580
+ exponentExpression: Expression | string
581
+ }
582
+ ```
583
+
584
+ **Example:**
585
+ ```json
586
+ {
587
+ "baseExpression": {
588
+ "termsAndOpers": [
589
+ { "omdType": "variable", "name": "x" },
590
+ { "omdType": "operator", "operator": "+" },
591
+ { "omdType": "number", "value": 1 }
592
+ ]
593
+ },
594
+ "exponentExpression": {
595
+ "omdType": "number",
596
+ "value": 2
597
+ }
598
+ }
599
+ ```
600
+
601
+ **Renders as:** `(x + 1)²`
602
+
603
+ ---
604
+
605
+ #### `omdRationalExpression`
606
+
607
+ Fractions and rational expressions.
608
+
609
+ **Schema:**
610
+ ```typescript
611
+ {
612
+ numeratorExpression: Expression | string,
613
+ denominatorExpression: Expression | string
614
+ }
615
+ ```
616
+
617
+ **Example:**
618
+ ```json
619
+ {
620
+ "numeratorExpression": {
621
+ "termsAndOpers": [
622
+ { "omdType": "variable", "name": "x" },
623
+ { "omdType": "operator", "operator": "+" },
624
+ { "omdType": "number", "value": 1 }
625
+ ]
626
+ },
627
+ "denominatorExpression": {
628
+ "termsAndOpers": [
629
+ { "omdType": "variable", "name": "x" },
630
+ { "omdType": "operator", "operator": "-" },
631
+ { "omdType": "number", "value": 1 }
632
+ ]
633
+ }
634
+ }
635
+ ```
636
+
637
+ **Renders as:** `(x + 1)/(x - 1)`
638
+
639
+ ---
640
+
641
+ #### `omdFunction`
642
+
643
+ Mathematical functions with named inputs.
644
+
645
+ **Schema:**
646
+ ```typescript
647
+ {
648
+ name: string,
649
+ inputVariables: string[],
650
+ expression: Expression | string
651
+ }
652
+ ```
653
+
654
+ **Example:**
655
+ ```json
656
+ {
657
+ "name": "f",
658
+ "inputVariables": ["x"],
659
+ "expression": {
660
+ "termsAndOpers": [
661
+ { "omdType": "term", "coefficient": 2, "variable": "x" },
662
+ { "omdType": "operator", "operator": "+" },
663
+ { "omdType": "number", "value": 1 }
664
+ ]
665
+ }
666
+ }
667
+ ```
668
+
669
+ **Renders as:** `f(x) = 2x + 1`
670
+
671
+ ---
672
+
673
+ #### `omdTileEquation`
674
+
675
+ Visual tile-based equations.
676
+
677
+ **Schema:**
678
+ ```typescript
679
+ {
680
+ left: Array<TileSpec>,
681
+ right: Array<TileSpec>,
682
+ equation?: string,
683
+ tileSize?: number,
684
+ tileGap?: number,
685
+ equalGap?: number,
686
+ tileRadius?: number,
687
+ showLabels?: boolean,
688
+ fontFamily?: string,
689
+ fontSize?: number,
690
+ plusColor?: string,
691
+ equalsColor?: string,
692
+ xPillColor?: string,
693
+ numberTileDefaults?: {
694
+ backgroundColor?: string,
695
+ dotColor?: string
696
+ }
697
+ }
698
+ ```
699
+
700
+ **Example:**
701
+ ```json
702
+ {
703
+ "left": ["x", "x", 3],
704
+ "right": [11],
705
+ "equation": "2x + 3 = 11",
706
+ "tileSize": 28,
707
+ "tileGap": 6,
708
+ "showLabels": true,
709
+ "fontFamily": "Albert Sans",
710
+ "fontSize": 16
711
+ }
712
+ ```
713
+
714
+ ---
715
+
716
+ #### `omdProblem`
717
+
718
+ Problem statement with associated visualization.
719
+
720
+ **Schema:**
721
+ ```typescript
722
+ {
723
+ problemText: string,
724
+ visualization: any
725
+ }
726
+ ```
727
+
728
+ **Example:**
729
+ ```json
730
+ {
731
+ "problemText": "Solve for x:",
732
+ "visualization": {
733
+ "omdType": "equation",
734
+ "equation": "2x + 3 = 11"
735
+ }
736
+ }
737
+ ```
738
+
739
+ ---
740
+
741
+ ## Usage Patterns
742
+
743
+ ### Loading from JSON
744
+
745
+ All components follow the same pattern:
746
+
747
+ ```javascript
748
+ const component = new ComponentClass();
749
+ component.loadFromJSON(jsonData);
750
+ ```
751
+
752
+ ### String vs. Structured
753
+
754
+ Many components accept both:
755
+
756
+ ```javascript
757
+ // String form (simple)
758
+ equation.loadFromJSON({ equation: '2x + 3 = 11' });
759
+
760
+ // Structured form (programmatic)
761
+ equation.loadFromJSON({
762
+ leftExpression: { termsAndOpers: [...] },
763
+ rightExpression: { termsAndOpers: [...] }
764
+ });
765
+ ```
766
+
767
+ ### Nested Components
768
+
769
+ Components can be nested:
770
+
771
+ ```javascript
772
+ const plane = new omdCoordinatePlane();
773
+ plane.loadFromJSON({
774
+ xMin: -10,
775
+ xMax: 10,
776
+ yMin: -10,
777
+ yMax: 10,
778
+ shapeSet: [
779
+ { omdType: 'circle', radius: 5, color: 'blue' },
780
+ { omdType: 'rectangle', width: 10, height: 5, color: 'red' }
781
+ ]
782
+ });
783
+ ```
784
+
785
+ ---
786
+
787
+ ## Type Definitions
788
+
789
+ For TypeScript users, the general pattern is:
790
+
791
+ ```typescript
792
+ type Expression = string | {
793
+ termsAndOpers: Array<Term | Number | Variable | Operator>
794
+ };
795
+
796
+ type Term = {
797
+ omdType: 'term',
798
+ coefficient: number,
799
+ variable?: string,
800
+ exponent?: number
801
+ };
802
+
803
+ type Number = {
804
+ omdType: 'number',
805
+ value: number
806
+ };
807
+
808
+ type Variable = {
809
+ omdType: 'variable',
810
+ name: string
811
+ };
812
+
813
+ type Operator = {
814
+ omdType: 'operator',
815
+ operator: '+' | '-' | '/' | '÷' | 'x' | '*' | '•' | '×' | '='
816
+ };
817
+ ```
818
+
819
+ ---
820
+
821
+ ## See Also
822
+
823
+ - **[API Reference](./api/api-reference.md)** - Detailed API documentation
824
+ - **[Getting Started](./guides/getting-started.md)** - Installation and basic usage
825
+ - **[Visualizations Guide](./guides/visualizations.md)** - Visual component examples
826
+ - **[Equations Guide](./guides/equations.md)** - Equation and expression examples