@teachinglab/omd 0.3.2 → 0.3.4
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/omd/core/omdEquationStack.js +8 -0
- package/omd/display/omdDisplay.js +8 -0
- package/package.json +1 -1
- package/src/omd-json-samples.js +34 -1
- package/src/omdEquation.js +5 -0
- package/src/omdExpression.js +5 -0
- package/src/omdShapes.js +47 -11
- package/src/omdSpinner.js +4 -1
|
@@ -536,4 +536,12 @@ export class omdEquationStack extends jsvgGroup {
|
|
|
536
536
|
this.updateLayout();
|
|
537
537
|
return true;
|
|
538
538
|
}
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Returns the SVG element for the entire equation stack.
|
|
542
|
+
* @returns {SVGElement} The SVG element representing the equation stack.
|
|
543
|
+
*/
|
|
544
|
+
getSvg() {
|
|
545
|
+
return this.svgObject;
|
|
546
|
+
}
|
|
539
547
|
}
|
|
@@ -952,4 +952,12 @@ export class omdDisplay {
|
|
|
952
952
|
getCurrentNode() {
|
|
953
953
|
return this.node;
|
|
954
954
|
}
|
|
955
|
+
|
|
956
|
+
/**
|
|
957
|
+
* Returns the SVG element for the entire display.
|
|
958
|
+
* @returns {SVGElement} The SVG element representing the display.
|
|
959
|
+
*/
|
|
960
|
+
getSVG() {
|
|
961
|
+
return this.svg.svgObject;
|
|
962
|
+
}
|
|
955
963
|
}
|
package/package.json
CHANGED
package/src/omd-json-samples.js
CHANGED
|
@@ -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/omdEquation.js
CHANGED
|
@@ -114,6 +114,11 @@ export class omdEquation extends omdMetaExpression
|
|
|
114
114
|
|
|
115
115
|
this.setWidthAndHeight( this.backRect.width, this.backRect.height );
|
|
116
116
|
|
|
117
|
+
// Set individual width/height properties and viewBox for API compatibility
|
|
118
|
+
this.width = this.backRect.width;
|
|
119
|
+
this.height = this.backRect.height;
|
|
120
|
+
this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
|
|
121
|
+
|
|
117
122
|
if ( this.centerEquation )
|
|
118
123
|
{
|
|
119
124
|
var leftShift = this.leftExpression.width + this.equalSign.width*0.50;
|
package/src/omdExpression.js
CHANGED
|
@@ -100,5 +100,10 @@ export class omdExpression extends omdMetaExpression
|
|
|
100
100
|
this.backRect.setWidthAndHeight( W + this.inset*2, 30 );
|
|
101
101
|
|
|
102
102
|
this.setWidthAndHeight( this.backRect.width, this.backRect.height );
|
|
103
|
+
|
|
104
|
+
// Set individual width/height properties and viewBox for API compatibility
|
|
105
|
+
this.width = this.backRect.width;
|
|
106
|
+
this.height = this.backRect.height;
|
|
107
|
+
this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
|
|
103
108
|
}
|
|
104
109
|
}
|
package/src/omdShapes.js
CHANGED
|
@@ -68,12 +68,15 @@ export class omdRightTriangle extends jsvgGroup
|
|
|
68
68
|
|
|
69
69
|
updateLayout()
|
|
70
70
|
{
|
|
71
|
-
|
|
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.
|
|
74
|
-
this.shapePath.addPoint(
|
|
75
|
-
this.shapePath.addPoint( this.unitScale*this.horizontalLeg,
|
|
76
|
-
this.shapePath.addPoint(
|
|
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
|
|
|
@@ -87,6 +90,11 @@ export class omdRightTriangle extends jsvgGroup
|
|
|
87
90
|
L.initializeWithShapePath( this.shapePath, [A,B,C] );
|
|
88
91
|
this.labelsHolder.addChild( L );
|
|
89
92
|
}
|
|
93
|
+
|
|
94
|
+
// Set viewBox to center the shape
|
|
95
|
+
this.width = this.unitScale * this.horizontalLeg + 20;
|
|
96
|
+
this.height = this.unitScale * this.verticalLeg + 20;
|
|
97
|
+
this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
|
|
90
98
|
}
|
|
91
99
|
}
|
|
92
100
|
|
|
@@ -154,6 +162,11 @@ export class omdIsoscelesTriangle extends jsvgGroup
|
|
|
154
162
|
L.initializeWithShapePath( this.shapePath );
|
|
155
163
|
this.labelsHolder.addChild( L );
|
|
156
164
|
}
|
|
165
|
+
|
|
166
|
+
// Set dimensions and viewBox for API compatibility
|
|
167
|
+
this.width = this.unitScale * this.triangleBase + 20;
|
|
168
|
+
this.height = this.unitScale * this.triangleHeight + 20;
|
|
169
|
+
this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
|
|
157
170
|
}
|
|
158
171
|
}
|
|
159
172
|
|
|
@@ -203,13 +216,16 @@ export class omdRectangle extends jsvgGroup
|
|
|
203
216
|
|
|
204
217
|
updateLayout()
|
|
205
218
|
{
|
|
206
|
-
|
|
219
|
+
// Center the rectangle within the viewBox
|
|
220
|
+
const offsetX = 10;
|
|
221
|
+
const offsetY = this.unitScale * this.rectHeight + 10;
|
|
207
222
|
|
|
208
|
-
this.shapePath.
|
|
209
|
-
this.shapePath.addPoint(
|
|
210
|
-
this.shapePath.addPoint( this.unitScale*this.rectWidth,
|
|
211
|
-
this.shapePath.addPoint(
|
|
212
|
-
this.shapePath.addPoint(
|
|
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);
|
|
213
229
|
|
|
214
230
|
this.shapePath.updatePath();
|
|
215
231
|
|
|
@@ -222,6 +238,11 @@ export class omdRectangle extends jsvgGroup
|
|
|
222
238
|
L.initializeWithShapePath( this.shapePath, [A,B,"",""] );
|
|
223
239
|
this.labelsHolder.addChild( L );
|
|
224
240
|
}
|
|
241
|
+
|
|
242
|
+
// Set viewBox
|
|
243
|
+
this.width = this.unitScale * this.rectWidth + 20;
|
|
244
|
+
this.height = this.unitScale * this.rectHeight + 20;
|
|
245
|
+
this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
|
|
225
246
|
}
|
|
226
247
|
}
|
|
227
248
|
|
|
@@ -266,6 +287,11 @@ export class omdEllipse extends jsvgGroup
|
|
|
266
287
|
updateLayout()
|
|
267
288
|
{
|
|
268
289
|
this.shapePath.setWidthAndHeight( this.rectWidth*this.unitScale, this.rectHeight*this.unitScale );
|
|
290
|
+
|
|
291
|
+
// Set dimensions and viewBox for API compatibility
|
|
292
|
+
this.width = this.rectWidth * this.unitScale + 20;
|
|
293
|
+
this.height = this.rectHeight * this.unitScale + 20;
|
|
294
|
+
this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
|
|
269
295
|
}
|
|
270
296
|
}
|
|
271
297
|
|
|
@@ -305,6 +331,11 @@ export class omdCircle extends jsvgGroup
|
|
|
305
331
|
updateLayout()
|
|
306
332
|
{
|
|
307
333
|
this.shapePath.setWidthAndHeight( 2.0*this.radius*this.unitScale, 2.0*this.radius*this.unitScale );
|
|
334
|
+
|
|
335
|
+
// Set dimensions and viewBox for API compatibility
|
|
336
|
+
this.width = 2.0 * this.radius * this.unitScale + 20;
|
|
337
|
+
this.height = 2.0 * this.radius * this.unitScale + 20;
|
|
338
|
+
this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
|
|
308
339
|
}
|
|
309
340
|
}
|
|
310
341
|
|
|
@@ -387,6 +418,11 @@ export class omdRegularPolygon extends jsvgGroup
|
|
|
387
418
|
L.initializeWithShapePath( this.shapePath, [ A ] );
|
|
388
419
|
this.labelsHolder.addChild( L );
|
|
389
420
|
}
|
|
421
|
+
|
|
422
|
+
// Set dimensions and viewBox for API compatibility
|
|
423
|
+
this.width = 2.0 * this.radius * this.unitScale + 20;
|
|
424
|
+
this.height = 2.0 * this.radius * this.unitScale + 20;
|
|
425
|
+
this.svgObject.setAttribute('viewBox', `-${this.width/2} -${this.height/2} ${this.width} ${this.height}`);
|
|
390
426
|
}
|
|
391
427
|
}
|
|
392
428
|
|
package/src/omdSpinner.js
CHANGED
|
@@ -136,7 +136,10 @@ export class omdSpinner extends jsvgGroup
|
|
|
136
136
|
var A = -90 + 360.0 / this.divisions * (this.arrowPosition-0.5);
|
|
137
137
|
this.arrow.setRotation( A );
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
// Set dimensions and viewBox for API compatibility
|
|
140
|
+
this.width = circleSize;
|
|
141
|
+
this.height = circleSize;
|
|
142
|
+
this.svgObject.setAttribute('viewBox', `0 0 ${this.width} ${this.height}`);
|
|
140
143
|
|
|
141
144
|
// var L = new jsvgLine();
|
|
142
145
|
// var lineLength = circleSize*0.4;
|