jsxgraph 1.4.0 → 1.4.3

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 (98) hide show
  1. package/README.md +1 -1
  2. package/distrib/README.md +1 -1
  3. package/distrib/geogebra.min.js +3 -3
  4. package/distrib/geonext.min.js +3 -3
  5. package/distrib/index.d.ts +5205 -4629
  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 +4497 -2180
  10. package/distrib/sketch.min.js +3 -3
  11. package/package.json +3 -2
  12. package/src/3d/box3d.js +264 -0
  13. package/src/3d/curve3d.js +97 -0
  14. package/src/3d/linspace3d.js +375 -0
  15. package/src/3d/point3d.js +200 -0
  16. package/src/3d/surface3d.js +81 -0
  17. package/src/3d/threed.js +38 -0
  18. package/src/3d/view3d.js +459 -0
  19. package/src/base/board.js +139 -85
  20. package/src/base/chart.js +1 -1
  21. package/src/base/circle.js +1 -1
  22. package/src/base/composition.js +1 -1
  23. package/src/base/constants.js +15 -14
  24. package/src/base/coords.js +3 -3
  25. package/src/base/coordselement.js +5 -8
  26. package/src/base/curve.js +1 -1
  27. package/src/base/element.js +36 -28
  28. package/src/base/foreignobject.js +12 -2
  29. package/src/base/group.js +1 -1
  30. package/src/base/image.js +1 -1
  31. package/src/base/line.js +2 -2
  32. package/src/base/point.js +8 -18
  33. package/src/base/polygon.js +89 -34
  34. package/src/base/text.js +8 -7
  35. package/src/base/ticks.js +17 -3
  36. package/src/base/transformation.js +1 -1
  37. package/src/base/turtle.js +1 -1
  38. package/src/element/arc.js +1 -1
  39. package/src/element/button.js +1 -1
  40. package/src/element/checkbox.js +1 -1
  41. package/src/element/comb.js +1 -1
  42. package/src/element/composition.js +2 -2
  43. package/src/element/conic.js +3 -3
  44. package/src/element/input.js +1 -1
  45. package/src/element/locus.js +1 -1
  46. package/src/element/measure.js +9 -4
  47. package/src/element/sector.js +5 -5
  48. package/src/element/slider.js +29 -12
  49. package/src/element/slopetriangle.js +1 -1
  50. package/src/jsxgraph.js +9 -3
  51. package/src/jxg.js +3 -3
  52. package/src/loadjsxgraph.js +18 -12
  53. package/src/math/bst.js +1 -1
  54. package/src/math/clip.js +550 -345
  55. package/src/math/complex.js +1 -1
  56. package/src/math/extrapolate.js +1 -1
  57. package/src/math/geometry.js +85 -6
  58. package/src/math/ia.js +69 -69
  59. package/src/math/math.js +10 -1
  60. package/src/math/metapost.js +1 -1
  61. package/src/math/nlp.js +4 -4
  62. package/src/math/numerics.js +2 -1
  63. package/src/math/plot.js +4 -4
  64. package/src/math/poly.js +1 -1
  65. package/src/math/probfuncs.js +2 -1
  66. package/src/math/qdt.js +11 -11
  67. package/src/math/statistics.js +10 -10
  68. package/src/math/symbolic.js +1 -1
  69. package/src/options.js +96 -40
  70. package/src/options3d.js +123 -0
  71. package/src/parser/ca.js +1297 -1291
  72. package/src/parser/datasource.js +1 -1
  73. package/src/parser/geonext.js +6 -6
  74. package/src/parser/jessiecode.js +369 -73
  75. package/src/parser/jessiescript.js +1 -1
  76. package/src/reader/cinderella.js +1 -1
  77. package/src/reader/file.js +1 -1
  78. package/src/reader/geogebra.js +1 -1
  79. package/src/reader/geonext.js +1 -1
  80. package/src/reader/graph.js +1 -1
  81. package/src/reader/intergeo.js +1 -1
  82. package/src/reader/sketch.js +7 -7
  83. package/src/renderer/abstract.js +8 -2
  84. package/src/renderer/canvas.js +9 -5
  85. package/src/renderer/no.js +2 -1
  86. package/src/renderer/svg.js +10 -13
  87. package/src/renderer/vml.js +1 -1
  88. package/src/server/server.js +1 -1
  89. package/src/utils/base64.js +2 -2
  90. package/src/utils/color.js +8 -9
  91. package/src/utils/dump.js +20 -5
  92. package/src/utils/env.js +13 -54
  93. package/src/utils/event.js +1 -1
  94. package/src/utils/expect.js +1 -1
  95. package/src/utils/type.js +12 -10
  96. package/src/utils/xml.js +1 -1
  97. package/src/utils/zip.js +1 -1
  98. package/CHANGELOG.md +0 -1366
@@ -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 2018-2021
2
+ Copyright 2018-2022
3
3
  Alfred Wassermann,
4
4
  Tigran Saluev
5
5
 
@@ -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,
@@ -1375,7 +1375,7 @@ define([
1375
1375
  };
1376
1376
 
1377
1377
  /**
1378
- * @class Bisector lines are similar to {@link Bisector} but takes two lines as parent elements. The resulting element is
1378
+ * @class Bisector lines are similar to {@link Bisector} but take two lines as parent elements. The resulting element is
1379
1379
  * a composition of two lines.
1380
1380
  * @pseudo
1381
1381
  * @constructor
@@ -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,
@@ -545,7 +545,7 @@ define([
545
545
  *
546
546
  */
547
547
  JXG.createParabola = function (board, parents, attributes) {
548
- var polarForm, curve, M, i,
548
+ var polarForm, curve, M,
549
549
  // focus
550
550
  F1 = parents[0],
551
551
  // directrix
@@ -574,7 +574,7 @@ define([
574
574
  }
575
575
 
576
576
  // Create line if given as array of two points.
577
- if (Type.isArray(l) && l.length == 2) {
577
+ if (Type.isArray(l) && l.length === 2) {
578
578
  attr_line = Type.copyAttributes(attributes, board.options, 'conic', 'line');
579
579
  l = board.create('line', l, attr_line);
580
580
  }
@@ -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,
@@ -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,
@@ -85,7 +85,7 @@ define([
85
85
  */
86
86
  JXG.createTapemeasure = function (board, parents, attributes) {
87
87
  var pos0, pos1,
88
- attr, withTicks, withText, precision,
88
+ attr, withTicks, withText, digits,
89
89
  li, p1, p2, n, ti;
90
90
 
91
91
  pos0 = parents[0];
@@ -106,7 +106,12 @@ define([
106
106
  attr = Type.copyAttributes(attributes, board.options, 'tapemeasure');
107
107
  withTicks = attr.withticks;
108
108
  withText = attr.withlabel;
109
- precision = attr.precision;
109
+ digits = attr.digits;
110
+
111
+ if (digits === 2 && attr.precision !== 2) {
112
+ // Backward compatibility
113
+ digits = attr.precision;
114
+ }
110
115
 
111
116
  // Below, we will replace the label by the measurement function.
112
117
  if (withText) {
@@ -122,7 +127,7 @@ define([
122
127
  n = '';
123
128
  }
124
129
  li.label.setText(function () {
125
- return n + Type.toFixed(p1.Dist(p2), precision);
130
+ return n + Type.toFixed(p1.Dist(p2), digits);
126
131
  });
127
132
  }
128
133
 
@@ -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,
@@ -199,7 +199,7 @@ define([
199
199
 
200
200
  if (type === '2lines') {
201
201
  /**
202
- * @ignore
202
+ * @ignore
203
203
  */
204
204
  el.Radius = function () {
205
205
  var r = Type.evaluate(parents[4]);
@@ -583,7 +583,7 @@ define([
583
583
  */
584
584
  el.setRadius = function (val) {
585
585
  /**
586
- * @ignore
586
+ * @ignore
587
587
  */
588
588
  el.Radius = function () {
589
589
  var r = Type.evaluate(val);
@@ -972,7 +972,7 @@ define([
972
972
  el.pointsquare = el.point3 = el.anglepoint = points[2];
973
973
 
974
974
  /**
975
- * @ignore
975
+ * @ignore
976
976
  */
977
977
  el.Radius = function () {
978
978
  // Set the angle radius, also @see @link Sector#autoRadius
@@ -1164,7 +1164,7 @@ define([
1164
1164
  */
1165
1165
  el.free = function () {
1166
1166
  var p = this.anglepoint;
1167
-
1167
+
1168
1168
  if (p.transformations.length > 0) {
1169
1169
  p.transformations.pop();
1170
1170
  p.isDraggable = true;
@@ -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,
@@ -143,7 +143,7 @@ define([
143
143
  * @example
144
144
  * // Set colors
145
145
  * var sl = board.create('slider', [[-3, 1], [1, 1], [-10, 1, 10]], {
146
- *
146
+ *
147
147
  * baseline: { strokeColor: 'blue'},
148
148
  * highline: { strokeColor: 'red'},
149
149
  * fillColor: 'yellow',
@@ -151,16 +151,16 @@ define([
151
151
  * name: 'xyz', // Not shown, if suffixLabel is set
152
152
  * suffixLabel: 'x = ',
153
153
  * postLabel: ' u'
154
- *
154
+ *
155
155
  * });
156
- *
156
+ *
157
157
  * </pre><div id="JXGd96c9e2c-2c25-4131-b6cf-9dbb80819401" class="jxgbox" style="width: 300px; height: 300px;"></div>
158
158
  * <script type="text/javascript">
159
159
  * (function() {
160
160
  * var board = JXG.JSXGraph.initBoard('JXGd96c9e2c-2c25-4131-b6cf-9dbb80819401',
161
161
  * {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
162
162
  * var sl = board.create('slider', [[-3, 1], [1, 1], [-10, 1, 10]], {
163
- *
163
+ *
164
164
  * baseline: { strokeColor: 'blue'},
165
165
  * highline: { strokeColor: 'red'},
166
166
  * fillColor: 'yellow',
@@ -168,24 +168,23 @@ define([
168
168
  * name: 'xyz', // Not shown, if suffixLabel is set
169
169
  * suffixLabel: 'x = ',
170
170
  * postLabel: ' u'
171
- *
171
+ *
172
172
  * });
173
- *
173
+ *
174
174
  * })();
175
- *
175
+ *
176
176
  * </script><pre>
177
- *
177
+ *
178
178
  */
179
179
  JXG.createSlider = function (board, parents, attributes) {
180
180
  var pos0, pos1, smin, start, smax, sdiff,
181
181
  p1, p2, l1, ticks, ti, startx, starty, p3, l2, t,
182
- withText, withTicks, snapWidth, sw, s, attr, precision;
182
+ withText, withTicks, snapWidth, sw, s, attr, digits;
183
183
 
184
184
  attr = Type.copyAttributes(attributes, board.options, 'slider');
185
185
  withTicks = attr.withticks;
186
186
  withText = attr.withlabel;
187
187
  snapWidth = attr.snapwidth;
188
- precision = attr.precision;
189
188
 
190
189
  // start point
191
190
  attr = Type.copyAttributes(attributes, board.options, 'slider', 'point1');
@@ -324,10 +323,16 @@ define([
324
323
  },
325
324
  function () {
326
325
  var n,
326
+ d = Type.evaluate(p3.visProp.digits),
327
327
  sl = Type.evaluate(p3.visProp.suffixlabel),
328
328
  ul = Type.evaluate(p3.visProp.unitlabel),
329
329
  pl = Type.evaluate(p3.visProp.postlabel);
330
330
 
331
+ if (d === 2 && Type.evaluate(p3.visProp.precision) !== 2) {
332
+ // Backwards compatibility
333
+ d = Type.evaluate(p3.visProp.precision);
334
+ }
335
+
331
336
  if (sl !== null) {
332
337
  n = sl;
333
338
  } else if (p3.name && p3.name !== '') {
@@ -336,7 +341,7 @@ define([
336
341
  n = '';
337
342
  }
338
343
 
339
- n += Type.toFixed(p3.Value(), precision);
344
+ n += Type.toFixed(p3.Value(), d);
340
345
 
341
346
  if (ul !== null) {
342
347
  n += ul;
@@ -458,6 +463,10 @@ define([
458
463
  p2.dump = false;
459
464
  l1.dump = false;
460
465
  l2.dump = false;
466
+ if (withText) {
467
+ t.dump = false;
468
+ }
469
+
461
470
 
462
471
  p3.elType = 'slider';
463
472
  p3.parents = parents;
@@ -475,6 +484,14 @@ define([
475
484
  p3.inherits.push(ti);
476
485
  }
477
486
 
487
+ p3.getParents = function() {
488
+ return [
489
+ this.point1.coords.usrCoords.slice(1),
490
+ this.point2.coords.usrCoords.slice(1),
491
+ [this._smin, this.position * (this._smax - this._smin) + this._smin, this._smax]
492
+ ];
493
+ };
494
+
478
495
  p3.baseline.on('up', function(evt) {
479
496
  var pos, c;
480
497
 
@@ -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,
package/src/jsxgraph.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,
@@ -304,6 +304,8 @@ define([
304
304
  initBoard: function (box, attributes) {
305
305
  var originX, originY, unitX, unitY,
306
306
  renderer,
307
+ offX = 0,
308
+ offY = 0,
307
309
  w, h, dimensions,
308
310
  bbox, attr, axattr, axattr_x, axattr_y,
309
311
  board;
@@ -339,15 +341,19 @@ define([
339
341
 
340
342
  if (Math.abs(unitX) < Math.abs(unitY)) {
341
343
  unitY = Math.abs(unitX) * unitY / Math.abs(unitY);
344
+ // Add the additional units in equal portions above and below
345
+ offY = (h / unitY - (bbox[1] - bbox[3])) * 0.5;
342
346
  } else {
343
347
  unitX = Math.abs(unitY) * unitX / Math.abs(unitX);
348
+ // Add the additional units in equal portions left and right
349
+ offX = (w / unitX - (bbox[2] - bbox[0])) * 0.5;
344
350
  }
345
351
  } else {
346
352
  unitX = w / (bbox[2] - bbox[0]);
347
353
  unitY = h / (bbox[1] - bbox[3]);
348
354
  }
349
- originX = -unitX * bbox[0];
350
- originY = unitY * bbox[1];
355
+ originX = -unitX * (bbox[0] - offX);
356
+ originY = unitY * (bbox[1] + offY);
351
357
  }
352
358
 
353
359
  renderer = this.initRenderer(box, dimensions, attr.document, attr.renderer);
package/src/jxg.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,
@@ -131,9 +131,9 @@ define([], function () {
131
131
  onlyOwn = onlyOwn || false;
132
132
  toUpper = toUpper || false;
133
133
 
134
- // the purpose of this for...in loop is indeed to use hasOwnProperty only if the caller explicitly wishes so.
134
+ // The purpose of this for...in loop is indeed to use hasOwnProperty only if the caller explicitly wishes so.
135
135
  for (e in constants) {
136
- if (!onlyOwn || (onlyOwn && extension.hasOwnProperty(e))) {
136
+ if (!onlyOwn || (onlyOwn && constants.hasOwnProperty(e))) {
137
137
  if (toUpper) {
138
138
  e2 = e.toUpperCase();
139
139
  } else {
@@ -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,
@@ -55,10 +55,9 @@ var JXG = {},
55
55
  //// ////
56
56
  //// Attention! Slows down the loading time! ////
57
57
  //////////////////////////////////////////////////////////////////////////
58
- var preventCachingFiles = true;
59
-
60
- // check and table are initialized at the end of the life
61
- var table,
58
+ var preventCachingFiles = true,
59
+ // check and table are initialized at the end of the life
60
+ table,
62
61
  waitlist = [],
63
62
  checkwaitlist = true,
64
63
  checkJXG = function () {
@@ -146,6 +145,9 @@ var JXG = {},
146
145
  ////////////////////////////////////////////////////////////////////////////////
147
146
 
148
147
  JXG.Load = (function () {
148
+ var requirePathLocation = 'href',
149
+ allowDocumentWrite = true;
150
+
149
151
  function createHTMLElement(tagName, attr) {
150
152
  var el = document.createElement(tagName), i,
151
153
  a_name, a_value, a_object;
@@ -162,14 +164,10 @@ var JXG = {},
162
164
  return el;
163
165
  }
164
166
 
165
- var allowDocumentWrite = true;
166
-
167
167
  window.onload = function () {
168
168
  allowDocumentWrite = false;
169
169
  };
170
170
 
171
- var requirePathLocation = 'href';
172
-
173
171
  return {
174
172
  requirePath: window.location.href,
175
173
 
@@ -298,7 +296,7 @@ var JXG = {},
298
296
  xhr.open('POST', url, true);
299
297
  xhr.send();
300
298
  }(file));
301
- },
299
+ }
302
300
  };
303
301
  })();
304
302
 
@@ -307,7 +305,7 @@ var JXG = {},
307
305
  ////////////////////////////////////////////////////////////////////////////////
308
306
 
309
307
  // Has to be a String for Makefile!
310
- JXG.Load.baseFiles = 'jxg,base/constants,utils/type,utils/xml,utils/env,utils/event,utils/expect,utils/color,math/probfuncs,math/math,math/ia,math/extrapolate,math/numerics,math/nlp,math/plot,math/metapost,math/statistics,math/symbolic,math/geometry,math/clip,math/poly,math/complex,renderer/abstract,renderer/no,reader/file,parser/geonext,base/board,options,jsxgraph,base/element,base/coordselement,base/coords,base/point,base/line,base/group,base/circle,element/conic,base/polygon,base/curve,element/arc,element/sector,base/composition,element/composition,base/text,base/image,element/slider,element/measure,base/chart,base/transformation,base/turtle,base/ticks,utils/zip,utils/base64,utils/uuid,utils/encoding,server/server,element/locus,parser/datasource,parser/ca,parser/jessiecode,utils/dump,renderer/svg,renderer/vml,renderer/canvas,renderer/no,element/comb,element/slopetriangle,math/qdt,element/checkbox,element/input,element/button,base/foreignobject';
308
+ JXG.Load.baseFiles = 'jxg,base/constants,utils/type,utils/xml,utils/env,utils/event,utils/expect,utils/color,math/probfuncs,math/math,math/ia,math/extrapolate,math/numerics,math/nlp,math/plot,math/metapost,math/statistics,math/symbolic,math/geometry,math/clip,math/poly,math/complex,renderer/abstract,renderer/no,reader/file,parser/geonext,base/board,options,jsxgraph,base/element,base/coordselement,base/coords,base/point,base/line,base/group,base/circle,element/conic,base/polygon,base/curve,element/arc,element/sector,base/composition,element/composition,base/text,base/image,element/slider,element/measure,base/chart,base/transformation,base/turtle,base/ticks,utils/zip,utils/base64,utils/uuid,utils/encoding,server/server,element/locus,parser/datasource,parser/ca,parser/jessiecode,utils/dump,renderer/svg,renderer/vml,renderer/canvas,renderer/no,element/comb,element/slopetriangle,math/qdt,element/checkbox,element/input,element/button,base/foreignobject,options3d,3d/threed,3d/view3d,3d/point3d,3d/curve3d,3d/surface3d,3d/linspace3d,3d/box3d';
311
309
  JXG.Load.setRequirePathToScriptFile('loadjsxgraph.js');
312
310
  JXG.Load.JSfiles(JXG.Load.baseFiles.split(','), preventCachingFiles);
313
311
  JXG.Load.baseFiles = null;
@@ -403,6 +401,14 @@ var JXG = {},
403
401
  'utils/type': checkJXG,
404
402
  'utils/uuid': makeCheck('Util'),
405
403
  'utils/xml': makeCheck('XML'),
406
- 'utils/zip': makeCheck('Util')
404
+ 'utils/zip': makeCheck('Util'),
405
+
406
+ '3d/threed': checkJXG,
407
+ '3d/view3d': checkJXG,
408
+ '3d/point3d': checkJXG,
409
+ '3d/curve3d': checkJXG,
410
+ '3d/surface3d': checkJXG,
411
+ '3d/linspace3d': checkJXG
412
+
407
413
  };
408
414
  }());
package/src/math/bst.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,