@teachinglab/omd 0.3.3 → 0.3.5

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.
@@ -7,7 +7,7 @@ import { SelectTool } from '../tools/SelectTool.js';
7
7
  import { Cursor } from '../ui/cursor.js';
8
8
  import { Toolbar } from '../ui/toolbar.js';
9
9
  import { FocusFrameManager } from '../features/focusFrameManager.js';
10
-
10
+ import {jsvgGroup} from '@teachinglab/jsvg'
11
11
  /**
12
12
  * Main OMD Canvas class
13
13
  * Provides the primary interface for creating and managing a drawing canvas
package/canvas/index.js CHANGED
@@ -27,7 +27,6 @@ export { mathUtils } from './utils/mathUtils.js';
27
27
 
28
28
  // Focus frame system
29
29
  export { FocusFrameManager } from './features/focusFrameManager.js';
30
- import { omdCanvas } from './core/omdCanvas.js';
31
30
  /**
32
31
  * Quick setup function for common use cases
33
32
  * @param {HTMLElement|string} container - Container element or selector
@@ -1,4 +1,6 @@
1
1
  import {omdColor} from '../../src/omdColor.js';
2
+ import { jsvgRect, jsvgGroup } from '@teachinglab/jsvg';
3
+ import { jsvgButton } from '@teachinglab/jsvg';
2
4
 
3
5
  export class Toolbar {
4
6
  /**
package/index.js CHANGED
@@ -13,10 +13,13 @@
13
13
 
14
14
  // Export everything from the core OMD library (equations, nodes, display, etc.)
15
15
  export * from './omd/core/index.js';
16
-
16
+ export * from './canvas/index.js';
17
17
  // Export everything from the visualization components
18
18
  export * from './src/index.js';
19
19
 
20
+ // Re-export canvas helpers/events so package consumers can import them from the package root
21
+ export { EventManager } from './canvas/events/eventManager.js';
22
+
20
23
  // Export utility components
21
24
  export { omdNodeOverlay, omdNodeOverlayPresets } from './omd/utils/omdNodeOverlay.js';
22
25
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teachinglab/omd",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "omd",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -105,11 +105,44 @@ export const tapeDiagramExample = {
105
105
  "showValues": true
106
106
  };
107
107
 
108
+ // EQUATION STACK - Complete example showing step-by-step equation solving
109
+ export const equationStackExample = {
110
+ "omdType": "equationStack",
111
+ "equations": [
112
+ "2x + 3 = 11",
113
+ "2x = 8",
114
+ "x = 4"
115
+ ]
116
+ };
117
+
118
+ // EQUATION STACK - Multi-step algebraic solution
119
+ export const equationStackMultiStepExample = {
120
+ "omdType": "equationStack",
121
+ "equations": [
122
+ "3(x + 2) = 15",
123
+ "3x + 6 = 15",
124
+ "3x = 9",
125
+ "x = 3"
126
+ ]
127
+ };
128
+
129
+ // EQUATION STACK - Quadratic equation solution
130
+ export const equationStackQuadraticExample = {
131
+ "omdType": "equationStack",
132
+ "equations": [
133
+ "x² + 5x + 6 = 0",
134
+ "(x + 2)(x + 3) = 0",
135
+ ]
136
+ };
137
+
108
138
  // Export all examples for AI reference
109
139
  export const allExamples = {
110
140
  coordinatePlane: coordinatePlaneExample,
111
141
  table: tableExample,
112
142
  tableEquation: tableEquationExample,
113
143
  balanceHanger: balanceHangerExample,
114
- tapeDiagram: tapeDiagramExample
144
+ tapeDiagram: tapeDiagramExample,
145
+ equationStack: equationStackExample,
146
+ equationStackMultiStep: equationStackMultiStepExample,
147
+ equationStackQuadratic: equationStackQuadraticExample
115
148
  };
package/src/omdShapes.js CHANGED
@@ -68,12 +68,15 @@ export class omdRightTriangle extends jsvgGroup
68
68
 
69
69
  updateLayout()
70
70
  {
71
- this.shapePath.clearPoints();
71
+ // Center the triangle within the viewBox
72
+ const offsetX = 10; // Left margin
73
+ const offsetY = this.unitScale * this.verticalLeg + 10; // Bottom margin
72
74
 
73
- this.shapePath.addPoint( 0,0 );
74
- this.shapePath.addPoint( this.unitScale*this.horizontalLeg,0 );
75
- this.shapePath.addPoint( this.unitScale*this.horizontalLeg, -1.0*this.unitScale*this.verticalLeg );
76
- this.shapePath.addPoint( 0,0 );
75
+ this.shapePath.clearPoints();
76
+ this.shapePath.addPoint(offsetX, offsetY);
77
+ this.shapePath.addPoint(offsetX + this.unitScale * this.horizontalLeg, offsetY);
78
+ this.shapePath.addPoint(offsetX + this.unitScale * this.horizontalLeg, offsetY - this.unitScale * this.verticalLeg);
79
+ this.shapePath.addPoint(offsetX, offsetY);
77
80
 
78
81
  this.shapePath.updatePath();
79
82
 
@@ -88,7 +91,7 @@ export class omdRightTriangle extends jsvgGroup
88
91
  this.labelsHolder.addChild( L );
89
92
  }
90
93
 
91
- // Set dimensions and viewBox for API compatibility
94
+ // Set viewBox to center the shape
92
95
  this.width = this.unitScale * this.horizontalLeg + 20;
93
96
  this.height = this.unitScale * this.verticalLeg + 20;
94
97
  this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
@@ -213,13 +216,16 @@ export class omdRectangle extends jsvgGroup
213
216
 
214
217
  updateLayout()
215
218
  {
216
- this.shapePath.clearPoints();
219
+ // Center the rectangle within the viewBox
220
+ const offsetX = 10;
221
+ const offsetY = this.unitScale * this.rectHeight + 10;
217
222
 
218
- this.shapePath.addPoint( 0,0 );
219
- this.shapePath.addPoint( this.unitScale*this.rectWidth, 0 );
220
- this.shapePath.addPoint( this.unitScale*this.rectWidth, -1.0*this.unitScale*this.rectHeight );
221
- this.shapePath.addPoint( 0, -1.0*this.unitScale*this.rectHeight );
222
- this.shapePath.addPoint( 0,0 );
223
+ this.shapePath.clearPoints();
224
+ this.shapePath.addPoint(offsetX, offsetY);
225
+ this.shapePath.addPoint(offsetX + this.unitScale * this.rectWidth, offsetY);
226
+ this.shapePath.addPoint(offsetX + this.unitScale * this.rectWidth, offsetY - this.unitScale * this.rectHeight);
227
+ this.shapePath.addPoint(offsetX, offsetY - this.unitScale * this.rectHeight);
228
+ this.shapePath.addPoint(offsetX, offsetY);
223
229
 
224
230
  this.shapePath.updatePath();
225
231
 
@@ -233,7 +239,7 @@ export class omdRectangle extends jsvgGroup
233
239
  this.labelsHolder.addChild( L );
234
240
  }
235
241
 
236
- // Set dimensions and viewBox for API compatibility
242
+ // Set viewBox
237
243
  this.width = this.unitScale * this.rectWidth + 20;
238
244
  this.height = this.unitScale * this.rectHeight + 20;
239
245
  this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
@@ -416,7 +422,7 @@ export class omdRegularPolygon extends jsvgGroup
416
422
  // Set dimensions and viewBox for API compatibility
417
423
  this.width = 2.0 * this.radius * this.unitScale + 20;
418
424
  this.height = 2.0 * this.radius * this.unitScale + 20;
419
- this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
425
+ this.svgObject.setAttribute('viewBox', `-${this.width/2} -${this.height/2} ${this.width} ${this.height}`);
420
426
  }
421
427
  }
422
428