jsxgraph 1.3.1 → 1.4.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.
Files changed (90) hide show
  1. package/README.md +2 -2
  2. package/distrib/README.md +2 -2
  3. package/distrib/geogebra.min.js +3 -3
  4. package/distrib/geonext.min.js +3 -3
  5. package/distrib/index.d.ts +4964 -4627
  6. package/distrib/intergeo.min.js +3 -3
  7. package/distrib/jsxgraph.css +10 -15
  8. package/distrib/jsxgraphcore.js +9 -25
  9. package/distrib/jsxgraphsrc.js +28437 -25331
  10. package/distrib/sketch.min.js +3 -3
  11. package/package.json +11 -22
  12. package/src/base/board.js +555 -427
  13. package/src/base/chart.js +1 -1
  14. package/src/base/circle.js +23 -1
  15. package/src/base/composition.js +1 -1
  16. package/src/base/constants.js +33 -11
  17. package/src/base/coords.js +4 -4
  18. package/src/base/coordselement.js +47 -20
  19. package/src/base/curve.js +308 -117
  20. package/src/base/element.js +80 -51
  21. package/src/base/foreignobject.js +463 -0
  22. package/src/base/group.js +2 -2
  23. package/src/base/image.js +12 -15
  24. package/src/base/line.js +1 -1
  25. package/src/base/point.js +20 -41
  26. package/src/base/polygon.js +75 -18
  27. package/src/base/text.js +116 -63
  28. package/src/base/ticks.js +35 -12
  29. package/src/base/transformation.js +1 -1
  30. package/src/base/turtle.js +1 -1
  31. package/src/element/arc.js +1 -1
  32. package/src/element/button.js +29 -2
  33. package/src/element/checkbox.js +31 -1
  34. package/src/element/comb.js +5 -2
  35. package/src/element/composition.js +27 -6
  36. package/src/element/conic.js +46 -5
  37. package/src/element/input.js +32 -1
  38. package/src/element/locus.js +2 -2
  39. package/src/element/measure.js +9 -4
  40. package/src/element/sector.js +46 -12
  41. package/src/element/slider.js +17 -12
  42. package/src/element/slopetriangle.js +1 -1
  43. package/src/jsxgraph.js +28 -9
  44. package/src/jxg.js +4 -3
  45. package/src/loadjsxgraph.js +3 -2
  46. package/src/math/bst.js +1 -1
  47. package/src/math/clip.js +550 -345
  48. package/src/math/complex.js +1 -1
  49. package/src/math/extrapolate.js +1 -1
  50. package/src/math/geometry.js +109 -128
  51. package/src/math/ia.js +290 -21
  52. package/src/math/math.js +30 -1
  53. package/src/math/metapost.js +1 -1
  54. package/src/math/nlp.js +25 -5
  55. package/src/math/numerics.js +183 -4
  56. package/src/math/plot.js +4 -4
  57. package/src/math/poly.js +1 -1
  58. package/src/math/probfuncs.js +2 -1
  59. package/src/math/qdt.js +68 -62
  60. package/src/math/statistics.js +58 -7
  61. package/src/math/symbolic.js +1 -1
  62. package/src/options.js +393 -115
  63. package/src/parser/ca.js +1297 -1291
  64. package/src/parser/datasource.js +1 -1
  65. package/src/parser/geonext.js +6 -6
  66. package/src/parser/jessiecode.js +378 -79
  67. package/src/parser/jessiescript.js +1 -1
  68. package/src/reader/cinderella.js +1 -1
  69. package/src/reader/file.js +1 -1
  70. package/src/reader/geogebra.js +1 -1
  71. package/src/reader/geonext.js +1 -1
  72. package/src/reader/graph.js +1 -1
  73. package/src/reader/intergeo.js +1 -1
  74. package/src/reader/sketch.js +25 -17
  75. package/src/renderer/abstract.js +25 -7
  76. package/src/renderer/canvas.js +20 -15
  77. package/src/renderer/no.js +11 -4
  78. package/src/renderer/svg.js +68 -49
  79. package/src/renderer/vml.js +36 -32
  80. package/src/server/server.js +1 -1
  81. package/src/utils/base64.js +2 -2
  82. package/src/utils/color.js +147 -3
  83. package/src/utils/dump.js +20 -14
  84. package/src/utils/env.js +26 -62
  85. package/src/utils/event.js +1 -1
  86. package/src/utils/expect.js +1 -1
  87. package/src/utils/type.js +30 -19
  88. package/src/utils/xml.js +1 -1
  89. package/src/utils/zip.js +1 -1
  90. package/CHANGELOG.md +0 -1305
package/src/base/chart.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -141,6 +141,8 @@ define([
141
141
  */
142
142
  this.circle = null;
143
143
 
144
+ this.points = [];
145
+
144
146
  if (method === 'twoPoints') {
145
147
  this.point2 = board.select(par2);
146
148
  this.radius = this.Radius();
@@ -344,6 +346,8 @@ define([
344
346
  * Uses the boards renderer to update the circle.
345
347
  */
346
348
  update: function () {
349
+ var x, y, z, r, c, i;
350
+
347
351
  if (this.needsUpdate) {
348
352
  if (Type.evaluate(this.visProp.trace)) {
349
353
  this.cloneToBackground(true);
@@ -359,6 +363,24 @@ define([
359
363
 
360
364
  this.updateStdform();
361
365
  this.updateQuadraticform();
366
+
367
+ // Approximate the circle by 4 Bezier segments
368
+ // This will be used for intersections of type curve / circle.
369
+ // See https://spencermortensen.com/articles/bezier-circle/
370
+ z = this.center.coords.usrCoords[0];
371
+ x = this.center.coords.usrCoords[1] / z;
372
+ y = this.center.coords.usrCoords[2] / z;
373
+ z /= z;
374
+ r = this.Radius();
375
+ c = 0.551915024494;
376
+
377
+ this.numberPoints = 13;
378
+ this.dataX = [x + r, x + r, x + r * c, x, x - r * c, x - r, x - r, x - r, x - r * c, x, x + r * c, x + r, x + r];
379
+ this.dataY = [y, y + r * c, y + r, y + r, y + r, y + r * c, y, y - r * c, y - r, y - r, y - r, y - r * c, y];
380
+ this.bezierDegree = 3;
381
+ for (i = 0; i < this.numberPoints; i++) {
382
+ this.points[i] = new Coords(Const.COORDS_BY_USER, [this.dataX[i], this.dataY[i]], this.board);
383
+ }
362
384
  }
363
385
 
364
386
  return this;
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -41,8 +41,8 @@ define(['jxg'], function (JXG) {
41
41
  'use strict';
42
42
 
43
43
  var major = 1,
44
- minor = 3,
45
- patch = 1,
44
+ minor = 4,
45
+ patch = 2,
46
46
  add = '', //'dev'
47
47
  version = major + '.' + minor + '.' + patch + (add ? '-' + add : ''),
48
48
  constants;
@@ -52,7 +52,7 @@ define(['jxg'], function (JXG) {
52
52
  * Constant: the currently used JSXGraph version.
53
53
  *
54
54
  * @name JXG.version
55
- * @type {String}
55
+ * @type String
56
56
  */
57
57
  version: version,
58
58
 
@@ -61,21 +61,21 @@ define(['jxg'], function (JXG) {
61
61
  * showCopyright is not set to false on board creation).
62
62
  *
63
63
  * @name JXG.licenseText
64
- * @type {String}
64
+ * @type String
65
65
  */
66
66
  licenseText: 'JSXGraph v' + version + ' Copyright (C) see https://jsxgraph.org',
67
67
 
68
68
  /**
69
69
  * Constant: user coordinates relative to the coordinates system defined by the bounding box.
70
70
  * @name JXG.COORDS_BY_USER
71
- * @type {Number}
71
+ * @type Number
72
72
  */
73
73
  COORDS_BY_USER: 0x0001,
74
74
 
75
75
  /**
76
76
  * Constant: screen coordinates in pixel relative to the upper left corner of the div element.
77
77
  * @name JXG.COORDS_BY_SCREEN
78
- * @type {Number}
78
+ * @type Number
79
79
  */
80
80
  COORDS_BY_SCREEN: 0x0002,
81
81
 
@@ -110,6 +110,8 @@ define(['jxg'], function (JXG) {
110
110
  OBJECT_TYPE_INPUT: 28,
111
111
  OBJECT_TYPE_BUTTON: 29,
112
112
  OBJECT_TYPE_TRANSFORMATION: 30,
113
+ OBJECT_TYPE_FOREIGNOBJECT: 31,
114
+ OBJECT_TYPE_VIEW3D: 32,
113
115
 
114
116
  // IMPORTANT:
115
117
  // ----------
@@ -130,8 +132,19 @@ define(['jxg'], function (JXG) {
130
132
  GENTYPE_ABC: 1, // unused
131
133
  GENTYPE_AXIS: 2,
132
134
  GENTYPE_MID: 3,
133
- /** @deprecated, now use {@link JXG.GENTYPE_REFLECTION_ON_LINE} */ GENTYPE_REFLECTION: 4,
134
- /** @deprecated, now use {@link JXG.GENTYPE_REFLECTION_ON_POINT} */ GENTYPE_MIRRORELEMENT: 5,
135
+
136
+ /**
137
+ * @ignore
138
+ * @deprecated, now use {@link JXG.GENTYPE_REFLECTION_ON_LINE}
139
+ *
140
+ */
141
+ GENTYPE_REFLECTION: 4,
142
+ /**
143
+ * @ignore
144
+ * @deprecated, now use {@link JXG.GENTYPE_REFLECTION_ON_POINT}
145
+ */
146
+ GENTYPE_MIRRORELEMENT: 5,
147
+
135
148
  GENTYPE_REFLECTION_ON_LINE: 4,
136
149
  GENTYPE_REFLECTION_ON_POINT: 5,
137
150
  GENTYPE_TANGENT: 6,
@@ -144,7 +157,11 @@ define(['jxg'], function (JXG) {
144
157
  GENTYPE_GLIDER: 13,
145
158
  GENTYPE_INTERSECTION: 14,
146
159
  GENTYPE_CIRCLE: 15,
147
- /** @deprecated NOT USED ANY MORE SINCE SKETCHOMETRY 2.0 (only for old constructions needed) */ GENTYPE_CIRCLE2POINTS: 16,
160
+ /**
161
+ * @ignore @deprecated NOT USED ANY MORE SINCE SKETCHOMETRY 2.0 (only for old constructions needed)
162
+ */
163
+ GENTYPE_CIRCLE2POINTS: 16,
164
+
148
165
  GENTYPE_LINE: 17,
149
166
  GENTYPE_TRIANGLE: 18,
150
167
  GENTYPE_QUADRILATERAL: 19,
@@ -176,7 +193,12 @@ define(['jxg'], function (JXG) {
176
193
  GENTYPE_ABLATION: 45,
177
194
  GENTYPE_MIGRATE: 46,
178
195
  GENTYPE_VECTORCOPY: 47,
179
- GENTYPE_POLYGONCOPY: 48,
196
+ GENTYPE_POLYGONCOPY: 48, /**
197
+ * Constants
198
+ * @name Constants
199
+ * @namespace
200
+ */
201
+
180
202
  // GENTYPE_TRANSFORM: 48, // unused
181
203
  // 49 ... 50 // unused ...
182
204
 
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -90,7 +90,7 @@ define([
90
90
  /**
91
91
  * If true, this coordinates object will emit update events every time
92
92
  * the coordinates are set.
93
- * @type {boolean}
93
+ * @type boolean
94
94
  * @default true
95
95
  */
96
96
  this.emitter = !Type.exists(emitter) || emitter;
@@ -234,11 +234,11 @@ define([
234
234
  },
235
235
 
236
236
  /**
237
- * Copy array, either srcCoords or usrCoords
237
+ * Copy array, either scrCoords or usrCoords
238
238
  * Uses slice() in case of standard arrays and set() in case of
239
239
  * typed arrays.
240
240
  * @private
241
- * @param {String} obj Either 'srcCoords' or 'usrCoords'
241
+ * @param {String} obj Either 'scrCoords' or 'usrCoords'
242
242
  * @param {Number} offset Offset, defaults to 0 if not given
243
243
  * @returns {Array} Returns copy of the coords array either as standard array or as
244
244
  * typed array.
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright 2008-2021
2
+ Copyright 2008-2022
3
3
  Matthias Ehmann,
4
4
  Michael Gerhaeuser,
5
5
  Carsten Miller,
@@ -94,6 +94,17 @@ define([
94
94
  */
95
95
  this.position = null;
96
96
 
97
+ /**
98
+ * True if there the method this.updateConstraint() has been set. It is
99
+ * probably different from the prototype function() {return this;}.
100
+ * Used in updateCoords fo glider elements.
101
+ *
102
+ * @see JXG.CoordsElement#updateCoords
103
+ * @type Boolean
104
+ * @private
105
+ */
106
+ this.isConstrained = false;
107
+
97
108
  /**
98
109
  * Determines whether the element slides on a polygon if point is a glider.
99
110
  * @type Boolean
@@ -125,18 +136,10 @@ define([
125
136
  * To prevent double updates, {@link JXG.CoordsElement#needsUpdateFromParent}
126
137
  * is set to false in updateGlider() and reset to true in the following call to
127
138
  * {@link JXG.CoordsElement#updateGliderFromParent}
128
- * @type {Boolean}
139
+ * @type Boolean
129
140
  */
130
141
  this.needsUpdateFromParent = true;
131
142
 
132
- /**
133
- * Dummy function for unconstrained points or gliders.
134
- * @private
135
- */
136
- this.updateConstraint = function () {
137
- return this;
138
- };
139
-
140
143
  /**
141
144
  * Stores the groups of this element in an array of Group.
142
145
  * @type Array
@@ -182,11 +185,21 @@ define([
182
185
  };
183
186
 
184
187
  JXG.extend(JXG.CoordsElement.prototype, /** @lends JXG.CoordsElement.prototype */ {
188
+ /**
189
+ * Dummy function for unconstrained points or gliders.
190
+ * @private
191
+ */
192
+ updateConstraint: function () {
193
+ return this;
194
+ },
195
+
185
196
  /**
186
197
  * Updates the coordinates of the element.
187
198
  * @private
188
199
  */
189
200
  updateCoords: function (fromParent) {
201
+ var i;
202
+
190
203
  if (!this.needsUpdate) {
191
204
  return this;
192
205
  }
@@ -195,6 +208,10 @@ define([
195
208
  fromParent = false;
196
209
  }
197
210
 
211
+ if (!Type.evaluate(this.visProp.frozen)) {
212
+ this.updateConstraint();
213
+ }
214
+
198
215
  /*
199
216
  * We need to calculate the new coordinates no matter of the elements visibility because
200
217
  * a child could be visible and depend on the coordinates of the element/point (e.g. perpendicular).
@@ -204,6 +221,10 @@ define([
204
221
  * the defining elements of the line or circle have been changed.
205
222
  */
206
223
  if (this.type === Const.OBJECT_TYPE_GLIDER) {
224
+ if (this.isConstrained) {
225
+ fromParent = false;
226
+ }
227
+
207
228
  if (fromParent) {
208
229
  this.updateGliderFromParent();
209
230
  } else {
@@ -211,9 +232,6 @@ define([
211
232
  }
212
233
  }
213
234
 
214
- if (!Type.evaluate(this.visProp.frozen)) {
215
- this.updateConstraint();
216
- }
217
235
  this.updateTransform(fromParent);
218
236
 
219
237
  return this;
@@ -242,7 +260,7 @@ define([
242
260
  ev_sw,
243
261
  slide = this.slideObject,
244
262
  res, cu,
245
- slides = [],
263
+ slides = [],
246
264
  isTransformed;
247
265
 
248
266
  this.needsUpdateFromParent = false;
@@ -787,7 +805,7 @@ define([
787
805
  /**
788
806
  * Alias for {@link JXG.Element#handleSnapToGrid}
789
807
  * @param {Boolean} force force snapping independent from what the snaptogrid attribute says
790
- * @returns {JXG.Point} Reference to this element
808
+ * @returns {JXG.CoordsElement} Reference to this element
791
809
  */
792
810
  snapToGrid: function (force) {
793
811
  return this.handleSnapToGrid(force);
@@ -1080,8 +1098,8 @@ define([
1080
1098
  slide = slideobj.borders[i];
1081
1099
  }
1082
1100
  }
1083
- slideobj = this.board.select(slide);
1084
- onPolygon = true;
1101
+ slideobj = this.board.select(slide);
1102
+ onPolygon = true;
1085
1103
  }
1086
1104
 
1087
1105
  /* Gliders on Ticks are forbidden */
@@ -1137,6 +1155,8 @@ define([
1137
1155
  this.elType = 'text';
1138
1156
  } else if (this.type === Const.OBJECT_TYPE_IMAGE) {
1139
1157
  this.elType = 'image';
1158
+ } else if (this.type === Const.OBJECT_TYPE_FOREIGNOBJECT) {
1159
+ this.elType = 'foreignobject';
1140
1160
  }
1141
1161
 
1142
1162
  this.slideObject = null;
@@ -1159,9 +1179,11 @@ define([
1159
1179
  // remove all transformations
1160
1180
  this.transformations.length = 0;
1161
1181
 
1162
- this.updateConstraint = function () {
1163
- return this;
1164
- };
1182
+ delete this.updateConstraint;
1183
+ this.isConstrained = false;
1184
+ // this.updateConstraint = function () {
1185
+ // return this;
1186
+ // };
1165
1187
 
1166
1188
  if (!this.isDraggable) {
1167
1189
  this.isDraggable = true;
@@ -1301,6 +1323,7 @@ define([
1301
1323
  } else {
1302
1324
  this.coords = c;
1303
1325
  }
1326
+ return this;
1304
1327
  };
1305
1328
  // Euclidean coordinates
1306
1329
  } else if (terms.length === 2) {
@@ -1311,6 +1334,7 @@ define([
1311
1334
 
1312
1335
  this.updateConstraint = function () {
1313
1336
  this.coords.setCoordinates(Const.COORDS_BY_USER, [this.XEval(), this.YEval()]);
1337
+ return this;
1314
1338
  };
1315
1339
  // Homogeneous coordinates
1316
1340
  } else {
@@ -1322,8 +1346,10 @@ define([
1322
1346
 
1323
1347
  this.updateConstraint = function () {
1324
1348
  this.coords.setCoordinates(Const.COORDS_BY_USER, [this.ZEval(), this.XEval(), this.YEval()]);
1349
+ return this;
1325
1350
  };
1326
1351
  }
1352
+ this.isConstrained = true;
1327
1353
 
1328
1354
  /**
1329
1355
  * We have to do an update. Otherwise, elements relying on this point will receive NaN.
@@ -1399,6 +1425,7 @@ define([
1399
1425
  this.updateConstraint = function () {
1400
1426
  this.coords.setCoordinates(Const.COORDS_BY_USER, [this.ZEval(), this.XEval(), this.YEval()]);
1401
1427
  };
1428
+ this.isConstrained = true;
1402
1429
 
1403
1430
  this.updateConstraint();
1404
1431
  //this.coords = new Coords(Const.COORDS_BY_SCREEN, [0, 0], this.board);