jsxgraph 1.9.1 → 1.9.2
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/CHANGELOG.md +49 -0
- package/distrib/docs.zip +0 -0
- package/distrib/geogebra.min.js +2 -2
- package/distrib/geonext.min.js +2 -2
- package/distrib/intergeo.min.js +2 -2
- package/distrib/jsxgraph.css +1 -1
- package/distrib/jsxgraph.zip +0 -0
- package/distrib/jsxgraphcore.js +3 -3
- package/distrib/jsxgraphcore.mjs +3 -3
- package/distrib/jsxgraphcore.mjs.map +1 -1
- package/distrib/jsxgraphsrc.js +2328 -1508
- package/distrib/jsxgraphsrc.mjs +2328 -1508
- package/distrib/jsxgraphsrc.mjs.map +1 -1
- package/distrib/sketch.min.js +3 -3
- package/package.json +4 -4
- package/src/3d/box3d.js +4 -1
- package/src/3d/circle3d.js +10 -9
- package/src/3d/curve3d.js +2 -0
- package/src/3d/linspace3d.js +18 -55
- package/src/3d/point3d.js +6 -0
- package/src/3d/polygon3d.js +1 -0
- package/src/3d/sphere3d.js +47 -43
- package/src/3d/surface3d.js +1 -0
- package/src/3d/view3d.js +1504 -1067
- package/src/base/board.js +176 -55
- package/src/base/circle.js +3 -1
- package/src/base/constants.js +1 -1
- package/src/base/curve.js +1 -0
- package/src/base/element.js +38 -30
- package/src/base/line.js +93 -105
- package/src/base/polygon.js +1 -1
- package/src/base/text.js +5 -1
- package/src/element/button.js +62 -12
- package/src/element/checkbox.js +6 -2
- package/src/element/grid.js +6 -6
- package/src/element/input.js +9 -6
- package/src/element/slider.js +42 -39
- package/src/jsxgraph.js +5 -3
- package/src/math/geometry.js +86 -64
- package/src/math/math.js +47 -5
- package/src/options.js +45 -0
- package/src/options3d.js +82 -5
- package/src/parser/jessiecode.js +2 -1
- package/src/parser/prefix.js +8 -1
- package/src/reader/sketch.js +106 -0
- package/src/renderer/svg.js +16 -6
- package/src/utils/env.js +2 -2
- package/src/utils/type.js +27 -15
package/src/reader/sketch.js
CHANGED
|
@@ -36,6 +36,112 @@
|
|
|
36
36
|
(function () {
|
|
37
37
|
"use strict";
|
|
38
38
|
|
|
39
|
+
JXG.extendConstants(JXG, {
|
|
40
|
+
GENTYPE_ABC: 1, // unused
|
|
41
|
+
GENTYPE_AXIS: 2,
|
|
42
|
+
GENTYPE_MID: 3,
|
|
43
|
+
|
|
44
|
+
GENTYPE_REFLECTION: 4,
|
|
45
|
+
GENTYPE_MIRRORELEMENT: 5,
|
|
46
|
+
|
|
47
|
+
GENTYPE_REFLECTION_ON_LINE: 4,
|
|
48
|
+
GENTYPE_REFLECTION_ON_POINT: 5,
|
|
49
|
+
GENTYPE_TANGENT: 6,
|
|
50
|
+
GENTYPE_PARALLEL: 7,
|
|
51
|
+
GENTYPE_BISECTORLINES: 8,
|
|
52
|
+
GENTYPE_BOARDIMG: 9,
|
|
53
|
+
GENTYPE_BISECTOR: 10,
|
|
54
|
+
GENTYPE_NORMAL: 11,
|
|
55
|
+
GENTYPE_POINT: 12,
|
|
56
|
+
GENTYPE_GLIDER: 13,
|
|
57
|
+
GENTYPE_INTERSECTION: 14,
|
|
58
|
+
GENTYPE_CIRCLE: 15,
|
|
59
|
+
/**
|
|
60
|
+
* @ignore @deprecated NOT USED ANY MORE SINCE SKETCHOMETRY 2.0 (only for old constructions needed)
|
|
61
|
+
*/
|
|
62
|
+
GENTYPE_CIRCLE2POINTS: 16,
|
|
63
|
+
|
|
64
|
+
GENTYPE_LINE: 17,
|
|
65
|
+
GENTYPE_TRIANGLE: 18,
|
|
66
|
+
GENTYPE_QUADRILATERAL: 19,
|
|
67
|
+
GENTYPE_TEXT: 20,
|
|
68
|
+
GENTYPE_POLYGON: 21,
|
|
69
|
+
GENTYPE_REGULARPOLYGON: 22,
|
|
70
|
+
GENTYPE_SECTOR: 23,
|
|
71
|
+
GENTYPE_ANGLE: 24,
|
|
72
|
+
GENTYPE_PLOT: 25,
|
|
73
|
+
GENTYPE_SLIDER: 26,
|
|
74
|
+
GENTYPE_TRUNCATE: 27,
|
|
75
|
+
GENTYPE_JCODE: 28,
|
|
76
|
+
GENTYPE_MOVEMENT: 29,
|
|
77
|
+
GENTYPE_COMBINED: 30,
|
|
78
|
+
GENTYPE_RULER: 31,
|
|
79
|
+
GENTYPE_SLOPETRIANGLE: 32,
|
|
80
|
+
GENTYPE_PERPSEGMENT: 33,
|
|
81
|
+
GENTYPE_LABELMOVEMENT: 34,
|
|
82
|
+
GENTYPE_VECTOR: 35,
|
|
83
|
+
GENTYPE_NONREFLEXANGLE: 36,
|
|
84
|
+
GENTYPE_REFLEXANGLE: 37,
|
|
85
|
+
GENTYPE_PATH: 38,
|
|
86
|
+
GENTYPE_DERIVATIVE: 39,
|
|
87
|
+
// 40 // unused ...
|
|
88
|
+
GENTYPE_DELETE: 41,
|
|
89
|
+
GENTYPE_COPY: 42,
|
|
90
|
+
GENTYPE_MIRROR: 43,
|
|
91
|
+
GENTYPE_ROTATE: 44,
|
|
92
|
+
GENTYPE_ABLATION: 45,
|
|
93
|
+
GENTYPE_MIGRATE: 46,
|
|
94
|
+
GENTYPE_VECTORCOPY: 47,
|
|
95
|
+
GENTYPE_POLYGONCOPY: 48,
|
|
96
|
+
// GENTYPE_TRANSFORM: 48, // unused
|
|
97
|
+
// 49 ... 50 // unused ...
|
|
98
|
+
|
|
99
|
+
// IMPORTANT:
|
|
100
|
+
// ----------
|
|
101
|
+
// For being able to differentiate between the (GUI-specific) CTX and
|
|
102
|
+
// (CORE-specific) non-CTX steps, the non-CTX steps MUST NOT be changed
|
|
103
|
+
// to values > 50.
|
|
104
|
+
|
|
105
|
+
GENTYPE_CTX_TYPE_G: 51,
|
|
106
|
+
GENTYPE_CTX_TYPE_P: 52,
|
|
107
|
+
GENTYPE_CTX_TRACE: 53,
|
|
108
|
+
GENTYPE_CTX_VISIBILITY: 54,
|
|
109
|
+
GENTYPE_CTX_CCVISIBILITY: 55, // unused
|
|
110
|
+
GENTYPE_CTX_MPVISIBILITY: 56,
|
|
111
|
+
GENTYPE_CTX_WITHLABEL: 57,
|
|
112
|
+
GENTYPE_CTX_LABEL: 58,
|
|
113
|
+
GENTYPE_CTX_FIXED: 59,
|
|
114
|
+
GENTYPE_CTX_STROKEWIDTH: 60,
|
|
115
|
+
GENTYPE_CTX_LABELSIZE: 61,
|
|
116
|
+
GENTYPE_CTX_SIZE: 62,
|
|
117
|
+
GENTYPE_CTX_FACE: 63,
|
|
118
|
+
GENTYPE_CTX_STRAIGHT: 64,
|
|
119
|
+
GENTYPE_CTX_ARROW: 65,
|
|
120
|
+
GENTYPE_CTX_COLOR: 66,
|
|
121
|
+
GENTYPE_CTX_RADIUS: 67,
|
|
122
|
+
GENTYPE_CTX_COORDS: 68,
|
|
123
|
+
GENTYPE_CTX_TEXT: 69,
|
|
124
|
+
GENTYPE_CTX_ANGLERADIUS: 70,
|
|
125
|
+
GENTYPE_CTX_DOTVISIBILITY: 71,
|
|
126
|
+
GENTYPE_CTX_FILLOPACITY: 72,
|
|
127
|
+
GENTYPE_CTX_PLOT: 73,
|
|
128
|
+
GENTYPE_CTX_SCALE: 74,
|
|
129
|
+
GENTYPE_CTX_SLIDER_BOUND: 75,
|
|
130
|
+
GENTYPE_CTX_POINT1: 76,
|
|
131
|
+
GENTYPE_CTX_POINT2: 77,
|
|
132
|
+
GENTYPE_CTX_LABELSTICKY: 78,
|
|
133
|
+
GENTYPE_CTX_TYPE_I: 79,
|
|
134
|
+
GENTYPE_CTX_HASINNERPOINTS: 80,
|
|
135
|
+
GENTYPE_CTX_SLIDER_STEP: 81,
|
|
136
|
+
GENTYPE_CTX_SNAPTOGRID: 82,
|
|
137
|
+
GENTYPE_CTX_SNAPTOPOINTS: 83,
|
|
138
|
+
GENTYPE_CTX_STROKEDASH: 84,
|
|
139
|
+
GENTYPE_CTX_SLIDER_VALUE: 85,
|
|
140
|
+
GENTYPE_CTX_SECTORBORDERS: 86,
|
|
141
|
+
GENTYPE_CTX_CURVETAU: 87,
|
|
142
|
+
GENTYPE_CTX_SLIDER_POS: 88
|
|
143
|
+
});
|
|
144
|
+
|
|
39
145
|
// this is a small workaround to adapt the SketchReader to our new file API
|
|
40
146
|
// we don't have to change anything in sketchometry.
|
|
41
147
|
JXG.SketchReader = function (board, str) {
|
package/src/renderer/svg.js
CHANGED
|
@@ -889,6 +889,8 @@ JXG.extend(
|
|
|
889
889
|
node2 = el.rendNodeTriangleStart;
|
|
890
890
|
if (ev_fa) {
|
|
891
891
|
str = this.toStr(this.container.id, '_', el.id, 'TriangleStart', a.typeFirst);
|
|
892
|
+
|
|
893
|
+
// If we try to set the same arrow head as is already set, we can bail out now
|
|
892
894
|
if (!Type.exists(node2) || node2.id !== str) {
|
|
893
895
|
node2 = this.container.ownerDocument.getElementById(str);
|
|
894
896
|
// Check if the marker already exists.
|
|
@@ -900,14 +902,19 @@ JXG.extend(
|
|
|
900
902
|
el.rendNodeTriangleStart = node2;
|
|
901
903
|
el.rendNode.setAttributeNS(null, "marker-start", this.toURL(str));
|
|
902
904
|
}
|
|
903
|
-
} else
|
|
904
|
-
|
|
905
|
-
|
|
905
|
+
} else {
|
|
906
|
+
if (Type.exists(node2)) {
|
|
907
|
+
this.remove(node2);
|
|
908
|
+
el.rendNodeTriangleStart = null;
|
|
909
|
+
}
|
|
910
|
+
el.rendNode.setAttributeNS(null, "marker-start", null);
|
|
906
911
|
}
|
|
907
912
|
|
|
908
913
|
node2 = el.rendNodeTriangleEnd;
|
|
909
914
|
if (ev_la) {
|
|
910
915
|
str = this.toStr(this.container.id, '_', el.id, 'TriangleEnd', a.typeLast);
|
|
916
|
+
|
|
917
|
+
// If we try to set the same arrow head as is already set, we can bail out now
|
|
911
918
|
if (!Type.exists(node2) || node2.id !== str) {
|
|
912
919
|
node2 = this.container.ownerDocument.getElementById(str);
|
|
913
920
|
// Check if the marker already exists.
|
|
@@ -919,9 +926,12 @@ JXG.extend(
|
|
|
919
926
|
el.rendNodeTriangleEnd = node2;
|
|
920
927
|
el.rendNode.setAttributeNS(null, "marker-end", this.toURL(str));
|
|
921
928
|
}
|
|
922
|
-
} else
|
|
923
|
-
|
|
924
|
-
|
|
929
|
+
} else {
|
|
930
|
+
if (Type.exists(node2)) {
|
|
931
|
+
this.remove(node2);
|
|
932
|
+
el.rendNodeTriangleEnd = null;
|
|
933
|
+
}
|
|
934
|
+
el.rendNode.setAttributeNS(null, "marker-end", null);
|
|
925
935
|
}
|
|
926
936
|
},
|
|
927
937
|
|
package/src/utils/env.js
CHANGED
|
@@ -532,7 +532,7 @@ JXG.extend(
|
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
if (!Type.exists(owner["x_internal" + type])) {
|
|
535
|
-
JXG.debug("no such type: " + type);
|
|
535
|
+
JXG.debug("removeEvent: no such type: " + type);
|
|
536
536
|
return;
|
|
537
537
|
}
|
|
538
538
|
|
|
@@ -559,7 +559,7 @@ JXG.extend(
|
|
|
559
559
|
obj.detachEvent("on" + type, owner["x_internal" + type][i]);
|
|
560
560
|
}
|
|
561
561
|
} catch (e) {
|
|
562
|
-
JXG.debug("event not registered in browser: (" + type + " -- " + fn + ")");
|
|
562
|
+
JXG.debug("removeEvent: event not registered in browser: (" + type + " -- " + fn + ")");
|
|
563
563
|
}
|
|
564
564
|
|
|
565
565
|
owner["x_internal" + type].splice(i, 1);
|
package/src/utils/type.js
CHANGED
|
@@ -194,8 +194,8 @@ JXG.extend(
|
|
|
194
194
|
* @returns {Boolean} True, if v is of type JXG.Point3D.
|
|
195
195
|
*/
|
|
196
196
|
isPoint3D: function (v) {
|
|
197
|
-
if (v !== null && typeof v === "object" && this.exists(v.
|
|
198
|
-
return v.
|
|
197
|
+
if (v !== null && typeof v === "object" && this.exists(v.type)) {
|
|
198
|
+
return v.type === Const.OBJECT_TYPE_POINT3D;
|
|
199
199
|
}
|
|
200
200
|
|
|
201
201
|
return false;
|
|
@@ -437,7 +437,7 @@ JXG.extend(
|
|
|
437
437
|
f = board.jc.snippet(term, true, variableName, false);
|
|
438
438
|
} else if (this.isFunction(term)) {
|
|
439
439
|
f = term;
|
|
440
|
-
f.deps = {};
|
|
440
|
+
f.deps = (this.isObject(term.deps)) ? term.deps : {};
|
|
441
441
|
} else if (this.isNumber(term)) {
|
|
442
442
|
/** @ignore */
|
|
443
443
|
f = function () { return term; };
|
|
@@ -1364,7 +1364,7 @@ JXG.extend(
|
|
|
1364
1364
|
* @returns {Object} The resulting attributes object
|
|
1365
1365
|
*/
|
|
1366
1366
|
copyAttributes: function (attributes, options, s) {
|
|
1367
|
-
var a, i, len, o, isAvail,
|
|
1367
|
+
var a, arg, i, len, o, isAvail,
|
|
1368
1368
|
primitives = {
|
|
1369
1369
|
circle: 1,
|
|
1370
1370
|
curve: 1,
|
|
@@ -1392,12 +1392,15 @@ JXG.extend(
|
|
|
1392
1392
|
}
|
|
1393
1393
|
|
|
1394
1394
|
// Default options from the specific element like 'line' in
|
|
1395
|
-
//
|
|
1395
|
+
// copyAttribute(attributes, board.options, 'line')
|
|
1396
|
+
// but also like in
|
|
1397
|
+
// Type.copyAttributes(attributes, board.options, 'view3d', 'az', 'slider');
|
|
1396
1398
|
o = options;
|
|
1397
1399
|
isAvail = true;
|
|
1398
1400
|
for (i = 2; i < len; i++) {
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
+
arg = arguments[i];
|
|
1402
|
+
if (this.exists(o[arg])) {
|
|
1403
|
+
o = o[arg];
|
|
1401
1404
|
} else {
|
|
1402
1405
|
isAvail = false;
|
|
1403
1406
|
break;
|
|
@@ -1409,14 +1412,16 @@ JXG.extend(
|
|
|
1409
1412
|
|
|
1410
1413
|
// Merge the specific options given in the parameter 'attributes'
|
|
1411
1414
|
// into the default options.
|
|
1412
|
-
// Additionally, we step into a
|
|
1413
|
-
//
|
|
1415
|
+
// Additionally, we step into a sub-element of attribute like line.point1 -
|
|
1416
|
+
// in case it is supplied as in
|
|
1417
|
+
// copyAttribute(attributes, board.options, 'line', 'point1')
|
|
1414
1418
|
// In this case we would merge attributes.point1 into the global line.point1 attributes.
|
|
1415
1419
|
o = (typeof attributes === 'object') ? this.keysToLowerCase(attributes) : {};
|
|
1416
1420
|
isAvail = true;
|
|
1417
1421
|
for (i = 3; i < len; i++) {
|
|
1418
|
-
|
|
1419
|
-
|
|
1422
|
+
arg = arguments[i].toLowerCase();
|
|
1423
|
+
if (this.exists(o[arg])) {
|
|
1424
|
+
o = o[arg];
|
|
1420
1425
|
} else {
|
|
1421
1426
|
isAvail = false;
|
|
1422
1427
|
break;
|
|
@@ -1435,8 +1440,9 @@ JXG.extend(
|
|
|
1435
1440
|
o = options;
|
|
1436
1441
|
isAvail = true;
|
|
1437
1442
|
for (i = 2; i < len; i++) {
|
|
1438
|
-
|
|
1439
|
-
|
|
1443
|
+
arg = arguments[i];
|
|
1444
|
+
if (this.exists(o[arg])) {
|
|
1445
|
+
o = o[arg];
|
|
1440
1446
|
} else {
|
|
1441
1447
|
isAvail = false;
|
|
1442
1448
|
break;
|
|
@@ -1734,6 +1740,7 @@ JXG.extend(
|
|
|
1734
1740
|
str = '';
|
|
1735
1741
|
|
|
1736
1742
|
if (arr[1] === 0 && arr[2] === 0) {
|
|
1743
|
+
// 0
|
|
1737
1744
|
str += '0';
|
|
1738
1745
|
} else {
|
|
1739
1746
|
// Sign
|
|
@@ -1741,12 +1748,15 @@ JXG.extend(
|
|
|
1741
1748
|
str += '-';
|
|
1742
1749
|
}
|
|
1743
1750
|
if (arr[2] === 0) {
|
|
1751
|
+
// Integer
|
|
1744
1752
|
str += arr[1];
|
|
1745
1753
|
} else if (!(arr[2] === 1 && arr[3] === 1)) {
|
|
1746
|
-
//
|
|
1754
|
+
// Proper fraction
|
|
1747
1755
|
if (arr[1] !== 0) {
|
|
1748
|
-
|
|
1756
|
+
// Absolute value larger than 1
|
|
1757
|
+
str += arr[1] + ' ';
|
|
1749
1758
|
}
|
|
1759
|
+
// Add fractional part
|
|
1750
1760
|
if (useTeX === true) {
|
|
1751
1761
|
str += '\\frac{' + arr[2] + '}{' + arr[3] + '}';
|
|
1752
1762
|
} else {
|
|
@@ -1819,6 +1829,8 @@ JXG.extend(
|
|
|
1819
1829
|
/**
|
|
1820
1830
|
* Convert a string containing a MAXIMA /STACK expression into a JSXGraph / JessieCode string
|
|
1821
1831
|
* or an array of JSXGraph / JessieCode strings.
|
|
1832
|
+
* <p>
|
|
1833
|
+
* This function is meanwhile superseded by stack_jxg.stack2jsxgraph.
|
|
1822
1834
|
*
|
|
1823
1835
|
* @example
|
|
1824
1836
|
* console.log( JXG.stack2jsxgraph("%e**x") );
|