@teachinglab/omd 0.7.16 → 0.7.18
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/canvas/core/canvasConfig.js +28 -17
- package/canvas/core/omdCanvas.js +46 -6
- package/canvas/features/resizeHandleManager.js +86 -23
- package/canvas/index.js +0 -1
- package/canvas/tools/PointerTool.js +51 -96
- package/canvas/ui/cursor.js +2 -4
- package/package.json +3 -3
- package/src/json-schemas.md +225 -25
- package/src/omdCoordinatePlane.js +12 -0
- package/canvas/tools/SelectTool.js +0 -1320
package/src/json-schemas.md
CHANGED
|
@@ -216,7 +216,12 @@ This document provides schemas and examples for the `loadFromJSON` method used i
|
|
|
216
216
|
"backgroundCornerRadius": "number",
|
|
217
217
|
"backgroundOpacity": "number",
|
|
218
218
|
"showBackground": "boolean",
|
|
219
|
-
"alternatingRowColors": ["array"]
|
|
219
|
+
"alternatingRowColors": ["array - e.g. ['#EEEEEE', '#FFFFFF']; index 0 used for header row"],
|
|
220
|
+
"headerBackgroundColor": "string (used when alternatingRowColors is not set)",
|
|
221
|
+
"cellBackgroundColor": "string (used when alternatingRowColors is not set)",
|
|
222
|
+
"evenRowColor": "string (legacy)",
|
|
223
|
+
"oddRowColor": "string (legacy)",
|
|
224
|
+
"alternatingRowOpacity": "number (legacy)"
|
|
220
225
|
}
|
|
221
226
|
```
|
|
222
227
|
|
|
@@ -243,7 +248,7 @@ This document provides schemas and examples for the `loadFromJSON` method used i
|
|
|
243
248
|
"backgroundCornerRadius": 15,
|
|
244
249
|
"backgroundOpacity": 1.0,
|
|
245
250
|
"showBackground": true,
|
|
246
|
-
"alternatingRowColors": ["#
|
|
251
|
+
"alternatingRowColors": ["#EEEEEE", "#FFFFFF"]
|
|
247
252
|
}
|
|
248
253
|
```
|
|
249
254
|
|
|
@@ -295,23 +300,149 @@ This document provides schemas and examples for the `loadFromJSON` method used i
|
|
|
295
300
|
|
|
296
301
|
## 8. `omdShapes`
|
|
297
302
|
|
|
298
|
-
`omdShapes`
|
|
303
|
+
`omdShapes` is a module containing several individual geometric shape classes. Each is used by `omdCoordinatePlane`'s `shapeSet` array (via the `omdType` field) and can also be instantiated independently.
|
|
299
304
|
|
|
300
|
-
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
### 8a. `omdRightTriangle`
|
|
308
|
+
|
|
309
|
+
#### Schema
|
|
301
310
|
```json
|
|
302
311
|
{
|
|
303
|
-
"
|
|
304
|
-
"
|
|
305
|
-
"
|
|
312
|
+
"horizontalLeg": "number (default: 5)",
|
|
313
|
+
"verticalLeg": "number (default: 10)",
|
|
314
|
+
"angleA": "number (optional) - angle in degrees; used with hypotenuse to compute legs",
|
|
315
|
+
"hypotenuse": "number (optional)",
|
|
316
|
+
"unitScale": "number (default: 10) - pixels per unit",
|
|
317
|
+
"showLabels": "boolean (default: false)"
|
|
306
318
|
}
|
|
307
319
|
```
|
|
308
320
|
|
|
309
|
-
|
|
321
|
+
#### Example
|
|
310
322
|
```json
|
|
311
323
|
{
|
|
312
|
-
"
|
|
313
|
-
"
|
|
314
|
-
"
|
|
324
|
+
"omdType": "rightTriangle",
|
|
325
|
+
"horizontalLeg": 3,
|
|
326
|
+
"verticalLeg": 4,
|
|
327
|
+
"unitScale": 20,
|
|
328
|
+
"showLabels": true
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
---
|
|
333
|
+
|
|
334
|
+
### 8b. `omdIsoscelesTriangle`
|
|
335
|
+
|
|
336
|
+
#### Schema
|
|
337
|
+
```json
|
|
338
|
+
{
|
|
339
|
+
"base": "number (default: 5)",
|
|
340
|
+
"height": "number (default: 10)",
|
|
341
|
+
"unitScale": "number (default: 10)",
|
|
342
|
+
"showLabels": "boolean (default: false)"
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
#### Example
|
|
347
|
+
```json
|
|
348
|
+
{
|
|
349
|
+
"omdType": "isoscelesTriangle",
|
|
350
|
+
"base": 6,
|
|
351
|
+
"height": 8,
|
|
352
|
+
"unitScale": 15
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
### 8c. `omdRectangle`
|
|
359
|
+
|
|
360
|
+
#### Schema
|
|
361
|
+
```json
|
|
362
|
+
{
|
|
363
|
+
"width": "number (default: 10)",
|
|
364
|
+
"height": "number (default: 10)",
|
|
365
|
+
"unitScale": "number (default: 10)",
|
|
366
|
+
"showLabels": "boolean (default: false)"
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
#### Example
|
|
371
|
+
```json
|
|
372
|
+
{
|
|
373
|
+
"omdType": "rectangle",
|
|
374
|
+
"width": 5,
|
|
375
|
+
"height": 3,
|
|
376
|
+
"unitScale": 20,
|
|
377
|
+
"showLabels": true
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
### 8d. `omdEllipse`
|
|
384
|
+
|
|
385
|
+
#### Schema
|
|
386
|
+
```json
|
|
387
|
+
{
|
|
388
|
+
"width": "number (default: 10)",
|
|
389
|
+
"height": "number (default: 5)",
|
|
390
|
+
"unitScale": "number (default: 10)"
|
|
391
|
+
}
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
#### Example
|
|
395
|
+
```json
|
|
396
|
+
{
|
|
397
|
+
"omdType": "ellipse",
|
|
398
|
+
"width": 8,
|
|
399
|
+
"height": 4,
|
|
400
|
+
"unitScale": 12
|
|
401
|
+
}
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
### 8e. `omdCircle`
|
|
407
|
+
|
|
408
|
+
#### Schema
|
|
409
|
+
```json
|
|
410
|
+
{
|
|
411
|
+
"radius": "number (default: 5)",
|
|
412
|
+
"unitScale": "number (default: 10)"
|
|
413
|
+
}
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
#### Example
|
|
417
|
+
```json
|
|
418
|
+
{
|
|
419
|
+
"omdType": "circle",
|
|
420
|
+
"radius": 4,
|
|
421
|
+
"unitScale": 15
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
### 8f. `omdRegularPolygon`
|
|
428
|
+
|
|
429
|
+
#### Schema
|
|
430
|
+
```json
|
|
431
|
+
{
|
|
432
|
+
"radius": "number (default: 5)",
|
|
433
|
+
"numberOfSides": "number (default: 5)",
|
|
434
|
+
"unitScale": "number (default: 10)",
|
|
435
|
+
"showLabels": "boolean (default: false)"
|
|
436
|
+
}
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
#### Example
|
|
440
|
+
```json
|
|
441
|
+
{
|
|
442
|
+
"omdType": "regularPolygon",
|
|
443
|
+
"radius": 5,
|
|
444
|
+
"numberOfSides": 6,
|
|
445
|
+
"unitScale": 18
|
|
315
446
|
}
|
|
316
447
|
```
|
|
317
448
|
|
|
@@ -346,14 +477,16 @@ This document provides schemas and examples for the `loadFromJSON` method used i
|
|
|
346
477
|
### Schema
|
|
347
478
|
```json
|
|
348
479
|
{
|
|
349
|
-
"valueA": "number",
|
|
350
|
-
"valueB": "number",
|
|
351
|
-
"
|
|
352
|
-
"
|
|
480
|
+
"valueA": "number - filled/first portion (alias: numerator)",
|
|
481
|
+
"valueB": "number - unfilled/second portion",
|
|
482
|
+
"numerator": "number (optional alias for valueA)",
|
|
483
|
+
"denominator": "number (optional) - when provided with numerator, sets valueA=numerator and valueB=denominator-numerator",
|
|
484
|
+
"renderType": "string - 'pie' | 'dots' | 'dot' | 'tile' | 'bar' (default: 'pie')",
|
|
485
|
+
"size": "string - 'small' | 'medium' | 'large' (default: 'large')"
|
|
353
486
|
}
|
|
354
487
|
```
|
|
355
488
|
|
|
356
|
-
### Example
|
|
489
|
+
### Example (basic)
|
|
357
490
|
```json
|
|
358
491
|
{
|
|
359
492
|
"valueA": 3,
|
|
@@ -363,6 +496,16 @@ This document provides schemas and examples for the `loadFromJSON` method used i
|
|
|
363
496
|
}
|
|
364
497
|
```
|
|
365
498
|
|
|
499
|
+
### Example (fraction form)
|
|
500
|
+
```json
|
|
501
|
+
{
|
|
502
|
+
"numerator": 2,
|
|
503
|
+
"denominator": 5,
|
|
504
|
+
"renderType": "dots",
|
|
505
|
+
"size": "medium"
|
|
506
|
+
}
|
|
507
|
+
```
|
|
508
|
+
|
|
366
509
|
---
|
|
367
510
|
|
|
368
511
|
## 11. `omdProblem`
|
|
@@ -465,6 +608,7 @@ This document provides schemas and examples for the `loadFromJSON` method used i
|
|
|
465
608
|
```json
|
|
466
609
|
{
|
|
467
610
|
"title": "string (optional)",
|
|
611
|
+
"label": "string (optional) - secondary label text",
|
|
468
612
|
"min": "number (required)",
|
|
469
613
|
"max": "number (required)",
|
|
470
614
|
"increment": "number (optional, default: 1)",
|
|
@@ -618,10 +762,14 @@ This document provides schemas and examples for the `loadFromJSON` method used i
|
|
|
618
762
|
### Schema
|
|
619
763
|
```json
|
|
620
764
|
{
|
|
621
|
-
"graphEquations": [
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
"
|
|
765
|
+
"graphEquations": [
|
|
766
|
+
"array of objects: { equation, color, strokeWidth, domain: { min, max }, label, labelAtX, labelPosition: 'above'|'below'|'left'|'right' }"
|
|
767
|
+
],
|
|
768
|
+
"lineSegments": [
|
|
769
|
+
"array of objects: { point1: [x, y], point2: [x, y], color, strokeWidth }"
|
|
770
|
+
],
|
|
771
|
+
"dotValues": ["array of [x, y] or [x, y, color] tuples"],
|
|
772
|
+
"shapeSet": ["array of shape objects with omdType (see omdShapes)"],
|
|
625
773
|
"xMin": "number",
|
|
626
774
|
"xMax": "number",
|
|
627
775
|
"yMin": "number",
|
|
@@ -629,7 +777,7 @@ This document provides schemas and examples for the `loadFromJSON` method used i
|
|
|
629
777
|
"xLabel": "string",
|
|
630
778
|
"yLabel": "string",
|
|
631
779
|
"axisLabelOffsetPx": "number",
|
|
632
|
-
"size": "string",
|
|
780
|
+
"size": "string - 'small' | 'medium' | 'large'",
|
|
633
781
|
"tickInterval": "number",
|
|
634
782
|
"forceAllTickLabels": "boolean",
|
|
635
783
|
"tickLabelOffsetPx": "number",
|
|
@@ -645,14 +793,22 @@ This document provides schemas and examples for the `loadFromJSON` method used i
|
|
|
645
793
|
```json
|
|
646
794
|
{
|
|
647
795
|
"graphEquations": [
|
|
648
|
-
{
|
|
796
|
+
{
|
|
797
|
+
"equation": "y = x^2",
|
|
798
|
+
"color": "blue",
|
|
799
|
+
"strokeWidth": 2,
|
|
800
|
+
"domain": { "min": -5, "max": 5 },
|
|
801
|
+
"label": "f(x) = x²",
|
|
802
|
+
"labelAtX": 2,
|
|
803
|
+
"labelPosition": "above"
|
|
804
|
+
}
|
|
649
805
|
],
|
|
650
806
|
"lineSegments": [
|
|
651
807
|
{ "point1": [0, 0], "point2": [1, 1], "color": "red", "strokeWidth": 2 }
|
|
652
808
|
],
|
|
653
809
|
"dotValues": [[0, 0, "green"], [1, 1, "blue"]],
|
|
654
810
|
"shapeSet": [
|
|
655
|
-
{ "omdType": "circle", "radius":
|
|
811
|
+
{ "omdType": "circle", "radius": 1, "unitScale": 15 }
|
|
656
812
|
],
|
|
657
813
|
"xMin": -5,
|
|
658
814
|
"xMax": 5,
|
|
@@ -682,7 +838,8 @@ This document provides schemas and examples for the `loadFromJSON` method used i
|
|
|
682
838
|
### Preferred schema (string form)
|
|
683
839
|
```json
|
|
684
840
|
{
|
|
685
|
-
"equation": "sin(x) + 2 = 3"
|
|
841
|
+
"equation": "sin(x) + 2 = 3",
|
|
842
|
+
"fontSize": "number (optional) - font size for the rendered equation"
|
|
686
843
|
}
|
|
687
844
|
```
|
|
688
845
|
|
|
@@ -700,5 +857,48 @@ This document provides schemas and examples for the `loadFromJSON` method used i
|
|
|
700
857
|
{ "equation": "sin(x) + 2 = 3" }
|
|
701
858
|
```
|
|
702
859
|
```json
|
|
703
|
-
{ "equation": "(x^2 + 3x - 4)/(2x) = 5" }
|
|
860
|
+
{ "equation": "(x^2 + 3x - 4)/(2x) = 5", "fontSize": 20 }
|
|
861
|
+
```
|
|
862
|
+
|
|
863
|
+
---
|
|
864
|
+
|
|
865
|
+
## 21. `omdBalanceHanger`
|
|
866
|
+
|
|
867
|
+
`omdBalanceHanger` is a visual balance/scale with values stacked on each arm. Variable values (strings) render as ellipse pills; numeric values render as rounded rectangles. The `tilt` property visually tips the beam left or right.
|
|
868
|
+
|
|
869
|
+
### Schema
|
|
870
|
+
```json
|
|
871
|
+
{
|
|
872
|
+
"leftValues": ["array - strings or numbers to stack on the left arm (default: [])"],
|
|
873
|
+
"rightValues": ["array - strings or numbers to stack on the right arm (default: [])"],
|
|
874
|
+
"tilt": "string - 'none' | 'left' | 'right' (default: 'none')",
|
|
875
|
+
"fontFamily": "string (default: 'Albert Sans')",
|
|
876
|
+
"fontSize": "number (default: 18)",
|
|
877
|
+
"backgroundColor": "string (default: lightGray)",
|
|
878
|
+
"backgroundCornerRadius": "number (default: 5)",
|
|
879
|
+
"backgroundOpacity": "number (default: 1.0)",
|
|
880
|
+
"showBackground": "boolean (default: true)"
|
|
881
|
+
}
|
|
882
|
+
```
|
|
883
|
+
|
|
884
|
+
### Example
|
|
885
|
+
```json
|
|
886
|
+
{
|
|
887
|
+
"leftValues": ["x", "x", "3"],
|
|
888
|
+
"rightValues": ["9"],
|
|
889
|
+
"tilt": "none",
|
|
890
|
+
"fontFamily": "Albert Sans",
|
|
891
|
+
"fontSize": 18
|
|
892
|
+
}
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
### Example (tilted)
|
|
896
|
+
```json
|
|
897
|
+
{
|
|
898
|
+
"leftValues": [5, 3],
|
|
899
|
+
"rightValues": [4],
|
|
900
|
+
"tilt": "left",
|
|
901
|
+
"backgroundColor": "#E0F0FF",
|
|
902
|
+
"backgroundCornerRadius": 8
|
|
903
|
+
}
|
|
704
904
|
```
|
|
@@ -12,6 +12,18 @@ import {
|
|
|
12
12
|
export class omdCoordinatePlane extends jsvgGroup {
|
|
13
13
|
constructor() {
|
|
14
14
|
super();
|
|
15
|
+
|
|
16
|
+
// Replace the default <g> element with an <svg> element so that
|
|
17
|
+
// overflow:hidden is respected and getBBox() returns the correct
|
|
18
|
+
// clipped dimensions (fixing the oversized selection box bug).
|
|
19
|
+
const svgNS = "http://www.w3.org/2000/svg";
|
|
20
|
+
const svgEl = document.createElementNS(svgNS, "svg");
|
|
21
|
+
if (this.svgObject && this.svgObject.parentNode) {
|
|
22
|
+
this.svgObject.parentNode.replaceChild(svgEl, this.svgObject);
|
|
23
|
+
}
|
|
24
|
+
this.svgObject = svgEl;
|
|
25
|
+
this.svgObject.setAttribute("overflow", "hidden");
|
|
26
|
+
|
|
15
27
|
this.graphEquations = [];
|
|
16
28
|
this.lineSegments = [];
|
|
17
29
|
this.dotValues = [];
|