jsxgraph 1.3.0 → 1.4.1

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 +651 -448
  6. package/distrib/intergeo.min.js +3 -3
  7. package/distrib/jsxgraph.css +4 -13
  8. package/distrib/jsxgraphcore.js +9 -25
  9. package/distrib/jsxgraphsrc.js +28203 -25234
  10. package/distrib/sketch.min.js +3 -3
  11. package/package.json +11 -22
  12. package/src/base/board.js +674 -469
  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 +32 -11
  17. package/src/base/coords.js +4 -4
  18. package/src/base/coordselement.js +51 -24
  19. package/src/base/curve.js +308 -117
  20. package/src/base/element.js +79 -50
  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 +108 -21
  25. package/src/base/point.js +24 -28
  26. package/src/base/polygon.js +75 -18
  27. package/src/base/text.js +116 -63
  28. package/src/base/ticks.js +29 -11
  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 +127 -19
  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 +155 -126
  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 +377 -114
  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 +275 -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 +21 -13
  75. package/src/renderer/abstract.js +21 -6
  76. package/src/renderer/canvas.js +22 -15
  77. package/src/renderer/no.js +11 -4
  78. package/src/renderer/svg.js +76 -53
  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 +148 -3
  83. package/src/utils/dump.js +21 -15
  84. package/src/utils/env.js +63 -104
  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 -1281
@@ -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,
@@ -153,7 +153,13 @@ define([
153
153
 
154
154
  t.update();
155
155
 
156
- t.generatePolynomial = function () {
156
+ /**
157
+ * Used to generate a polynomial for the orthogonal projection
158
+ * @name Orthogonalprojection#generatePolynomial
159
+ * @returns {Array} An array containing the generated polynomial.
160
+ * @private
161
+ */
162
+ t.generatePolynomial = function () {
157
163
  /*
158
164
  * Perpendicular takes point P and line L and creates point T and line M:
159
165
  *
@@ -353,7 +359,13 @@ define([
353
359
 
354
360
  t.update();
355
361
 
356
- t.generatePolynomial = function () {
362
+ /**
363
+ * Used to generate a polynomial for the perpendicular point
364
+ * @name PerpendicularPoint#generatePolynomial
365
+ * @returns {Array} An array containing the generated polynomial.
366
+ * @private
367
+ */
368
+ t.generatePolynomial = function () {
357
369
  /*
358
370
  * Perpendicular takes point P and line L and creates point T and line M:
359
371
  *
@@ -588,7 +600,13 @@ define([
588
600
 
589
601
  t.prepareUpdate().update();
590
602
 
591
- t.generatePolynomial = function () {
603
+ /**
604
+ * Used to generate a polynomial for the midpoint.
605
+ * @name Midpoint#generatePolynomial
606
+ * @returns {Array} An array containing the generated polynomial.
607
+ * @private
608
+ */
609
+ t.generatePolynomial = function () {
592
610
  /*
593
611
  * Midpoint takes two point A and B or line L (with points P and Q) and creates point T:
594
612
  *
@@ -1040,44 +1058,131 @@ define([
1040
1058
  l = board.create('line', [
1041
1059
  function () {
1042
1060
  var i = Math.floor(p.position),
1043
- lbda = p.position - i;
1061
+ lbda = p.position - i,
1062
+ p1, p2, t, A, B, C, D, dx, dy, d;
1044
1063
 
1045
- if (i === c.numberPoints - 1) {
1046
- i -= 1;
1047
- lbda = 1;
1064
+ if (c.bezierdegree === 1) {
1065
+ if (i === c.numberPoints - 1) {
1066
+ i -= 1;
1067
+ lbda = 1;
1068
+ }
1069
+ } else if (c.bezierDegree === 3) {
1070
+ // i is start of the Bezier segment
1071
+ // t is the position in the Bezier segment
1072
+ i = Math.floor(p.position * (c.numberPoints - 1) / 3) * 3;
1073
+ t = (p.position * (c.numberPoints - 1) - i) / 3;
1074
+ if (i >= c.numberPoints - 1) {
1075
+ i = c.numberPoints - 4;
1076
+ t = 1;
1077
+ }
1078
+ } else {
1079
+ return 0;
1048
1080
  }
1049
1081
 
1050
1082
  if (i < 0) {
1051
1083
  return 1;
1052
1084
  }
1053
1085
 
1054
- return (c.Y(i) + lbda * (c.Y(i + 1) - c.Y(i))) * (c.Y(i) - c.Y(i + 1)) - (c.X(i) + lbda * (c.X(i + 1) - c.X(i))) * (c.X(i + 1) - c.X(i));
1086
+ if (c.bezierDegree === 1) {
1087
+ return (c.Y(i) + lbda * (c.Y(i + 1) - c.Y(i))) * (c.Y(i) - c.Y(i + 1)) - (c.X(i) + lbda * (c.X(i + 1) - c.X(i))) * (c.X(i + 1) - c.X(i));
1088
+ } else {
1089
+ A = c.points[i].usrCoords;
1090
+ B = c.points[i + 1].usrCoords;
1091
+ C = c.points[i + 2].usrCoords;
1092
+ D = c.points[i + 3].usrCoords;
1093
+ dx = (1 - t) * (1 - t) * (B[1] - A[1]) + 2 * (1 - t) * t * (C[1] - B[1]) + t * t * (D[1]- C[1]);
1094
+ dy = (1 - t) * (1 - t) * (B[2] - A[2]) + 2 * (1 - t) * t * (C[2] - B[2]) + t * t * (D[2]- C[2]);
1095
+ d = Math.sqrt(dx * dx + dy * dy);
1096
+ dx /= d;
1097
+ dy /= d;
1098
+ p1 = p.coords.usrCoords;
1099
+ p2 = [1, p1[1] - dy, p1[2] + dx];
1100
+ return p1[2] * p2[1] - p1[1] * p2[2];
1101
+ }
1055
1102
  },
1056
1103
  function () {
1057
- var i = Math.floor(p.position);
1104
+ var i = Math.floor(p.position),
1105
+ p1, p2, t, A, B, C, D, dx, dy, d;
1058
1106
 
1059
- if (i === c.numberPoints - 1) {
1060
- i -= 1;
1107
+ if (c.bezierdegree === 1) {
1108
+ if (i === c.numberPoints - 1) {
1109
+ i -= 1;
1110
+ }
1111
+ } else if (c.bezierDegree === 3) {
1112
+ // i is start of the Bezier segment
1113
+ // t is the position in the Bezier segment
1114
+ i = Math.floor(p.position * (c.numberPoints - 1) / 3) * 3;
1115
+ t = (p.position * (c.numberPoints - 1) - i) / 3;
1116
+ if (i >= c.numberPoints - 1) {
1117
+ i = c.numberPoints - 4;
1118
+ t = 1;
1119
+ }
1120
+ } else {
1121
+ return 0;
1061
1122
  }
1062
1123
 
1063
1124
  if (i < 0) {
1064
1125
  return 0;
1065
1126
  }
1127
+ if (c.bezierDegree === 1) {
1128
+ return c.X(i + 1) - c.X(i);
1129
+ } else {
1130
+ A = c.points[i].usrCoords;
1131
+ B = c.points[i + 1].usrCoords;
1132
+ C = c.points[i + 2].usrCoords;
1133
+ D = c.points[i + 3].usrCoords;
1134
+ dx = (1 - t) * (1 - t) * (B[1] - A[1]) + 2 * (1 - t) * t * (C[1] - B[1]) + t * t * (D[1]- C[1]);
1135
+ dy = (1 - t) * (1 - t) * (B[2] - A[2]) + 2 * (1 - t) * t * (C[2] - B[2]) + t * t * (D[2]- C[2]);
1136
+ d = Math.sqrt(dx * dx + dy * dy);
1137
+ dx /= d;
1138
+ dy /= d;
1139
+ p1 = p.coords.usrCoords;
1140
+ p2 = [1, p1[1] - dy, p1[2] + dx];
1141
+ return p2[2] - p1[2];
1142
+ }
1066
1143
 
1067
- return c.X(i + 1) - c.X(i);
1068
1144
  },
1069
1145
  function () {
1070
- var i = Math.floor(p.position);
1146
+ var i = Math.floor(p.position),
1147
+ p1, p2, t, A, B, C, D, dx, dy, d;
1071
1148
 
1072
- if (i === c.numberPoints - 1) {
1073
- i -= 1;
1149
+ if (c.bezierdegree === 1) {
1150
+ if (i === c.numberPoints - 1) {
1151
+ i -= 1;
1152
+ }
1153
+ } else if (c.bezierDegree === 3) {
1154
+ // i is start of the Bezier segment
1155
+ // t is the position in the Bezier segment
1156
+ i = Math.floor(p.position * (c.numberPoints - 1) / 3) * 3;
1157
+ t = (p.position * (c.numberPoints - 1) - i) / 3;
1158
+ if (i >= c.numberPoints - 1) {
1159
+ i = c.numberPoints - 4;
1160
+ t = 1;
1161
+ }
1162
+ } else {
1163
+ return 0;
1074
1164
  }
1075
1165
 
1076
1166
  if (i < 0) {
1077
1167
  return 0;
1078
1168
  }
1079
1169
 
1080
- return c.Y(i + 1) - c.Y(i);
1170
+ if (c.bezierDegree === 1) {
1171
+ return c.Y(i + 1) - c.Y(i);
1172
+ } else {
1173
+ A = c.points[i].usrCoords;
1174
+ B = c.points[i + 1].usrCoords;
1175
+ C = c.points[i + 2].usrCoords;
1176
+ D = c.points[i + 3].usrCoords;
1177
+ dx = (1 - t) * (1 - t) * (B[1] - A[1]) + 2 * (1 - t) * t * (C[1] - B[1]) + t * t * (D[1]- C[1]);
1178
+ dy = (1 - t) * (1 - t) * (B[2] - A[2]) + 2 * (1 - t) * t * (C[2] - B[2]) + t * t * (D[2]- C[2]);
1179
+ d = Math.sqrt(dx * dx + dy * dy);
1180
+ dx /= d;
1181
+ dy /= d;
1182
+ p1 = p.coords.usrCoords;
1183
+ p2 = [1, p1[1] - dy, p1[2] + dx];
1184
+ return p1[1] - p2[1];
1185
+ }
1081
1186
  }
1082
1187
  ], attr);
1083
1188
  }
@@ -2189,7 +2294,7 @@ define([
2189
2294
  * within the interval <tt>i</tt>.
2190
2295
  * @example
2191
2296
  * var c1 = board.create('functiongraph', [function (t) { return t*t*t; }]);
2192
- * var i1 = board.create('integral', [[-1.0, 4.0], c1]);
2297
+ * var i1 = board.create('integral', [[-2.0, 2.0], c1]);
2193
2298
  * </pre><div class="jxgbox" id="JXGd45d7188-6624-4d6e-bebb-1efa2a305c8a" style="width: 400px; height: 400px;"></div>
2194
2299
  * <script type="text/javascript">
2195
2300
  * var intex1_board = JXG.JSXGraph.initBoard('JXGd45d7188-6624-4d6e-bebb-1efa2a305c8a', {boundingbox: [-5, 5, 5, -5], axis: true, showcopyright: false, shownavigation: false});
@@ -2540,7 +2645,10 @@ define([
2540
2645
  c.elType = 'grid';
2541
2646
  c.type = Const.OBJECT_TYPE_GRID;
2542
2647
 
2543
- c.updateDataArray = function () {
2648
+ /**
2649
+ * @ignore
2650
+ */
2651
+ c.updateDataArray = function () {
2544
2652
  var start, end, i, topLeft, bottomRight,
2545
2653
  gridX = Type.evaluate(this.visProp.gridx),
2546
2654
  gridY = Type.evaluate(this.visProp.gridy);
@@ -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,
@@ -69,7 +69,8 @@ define([
69
69
  * numbers describing the coordinates of a point. In the latter case the point will be constructed automatically as a fixed invisible point.
70
70
  * @param {JXG.Point,array_JXG.Point,array_number,function} point1,point2,number Parent elements can be two elements either of type {@link JXG.Point} or array of
71
71
  * numbers describing the coordinates of a point. The third parameter is a number/function which defines the length of the major axis
72
- * Optional parameters four and five are numbers which define the curve length (e.g. start/end). Default values are -pi and pi.
72
+ * @param {Number} start (Optional) parameter of the curve start, default: 0.
73
+ * @param {Number} end (Optional) parameter for the curve end, default: 2&pi;.
73
74
  * @example
74
75
  * // Create an Ellipse by three points
75
76
  * var A = board.create('point', [-1,4]);
@@ -78,12 +79,45 @@ define([
78
79
  * var el = board.create('ellipse',[A,B,C]);
79
80
  * </pre><div class="jxgbox" id="JXGa4d7fb6f-8708-4e45-87f2-2379ae2bd2c0" style="width: 300px; height: 300px;"></div>
80
81
  * <script type="text/javascript">
82
+ * (function() {
81
83
  * var glex1_board = JXG.JSXGraph.initBoard('JXGa4d7fb6f-8708-4e45-87f2-2379ae2bd2c0', {boundingbox:[-6,6,6,-6], keepaspectratio:true, showcopyright: false, shownavigation: false});
82
84
  * var A = glex1_board.create('point', [-1,4]);
83
85
  * var B = glex1_board.create('point', [-1,-4]);
84
86
  * var C = glex1_board.create('point', [1,1]);
85
87
  * var el = glex1_board.create('ellipse',[A,B,C]);
88
+ * })();
86
89
  * </script><pre>
90
+ *
91
+ * @example
92
+ * // Create an elliptical arc
93
+ * var p1 = board.create('point', [-1, 2]);
94
+ * var p2 = board.create('point', [ 1, 2]);
95
+ * var p3 = board.create('point', [0, 3]);
96
+ *
97
+ * var ell = board.create('ellipse', [
98
+ * p1, p2, p3, 0, Math.PI], {
99
+ * lastArrow: {type: 7}
100
+ * });
101
+ *
102
+ * </pre><div id="JXG950f7c07-27a4-4c67-9505-c73c22ce9345" class="jxgbox" style="width: 300px; height: 300px;"></div>
103
+ * <script type="text/javascript">
104
+ * (function() {
105
+ * var board = JXG.JSXGraph.initBoard('JXG950f7c07-27a4-4c67-9505-c73c22ce9345',
106
+ * {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
107
+ * var p1 = board.create('point', [-1, 2]);
108
+ * var p2 = board.create('point', [ 1, 2]);
109
+ * var p3 = board.create('point', [0, 3]);
110
+ *
111
+ * var ell = board.create('ellipse', [
112
+ * p1, p2, p3, 0, Math.PI], {
113
+ * lastArrow: {type: 7}
114
+ * });
115
+ *
116
+ * })();
117
+ *
118
+ * </script><pre>
119
+ *
120
+ *
87
121
  */
88
122
  JXG.createEllipse = function (board, parents, attributes) {
89
123
  var polarForm, curve, M, C, majorAxis, i,
@@ -287,7 +321,8 @@ define([
287
321
  * numbers describing the coordinates of a point. In the latter case the point will be constructed automatically as a fixed invisible point.
288
322
  * @param {JXG.Point,array_JXG.Point,array_number,function} point1,point2,number Parent elements can be two elements either of type {@link JXG.Point} or array of
289
323
  * numbers describing the coordinates of a point. The third parameter is a number/function which defines the length of the major axis
290
- * Optional parameters four and five are numbers which define the curve length (e.g. start/end). Default values are -pi and pi.
324
+ * @param {Number} start (Optional) parameter of the curve start, default: -&pi;.
325
+ * @param {Number} end (Optional) parameter for the curve end, default: &pi;.
291
326
  * @example
292
327
  * // Create an Hyperbola by three points
293
328
  * var A = board.create('point', [-1,4]);
@@ -296,11 +331,13 @@ define([
296
331
  * var el = board.create('hyperbola',[A,B,C]);
297
332
  * </pre><div class="jxgbox" id="JXGcf99049d-a3fe-407f-b936-27d76550f8c4" style="width: 300px; height: 300px;"></div>
298
333
  * <script type="text/javascript">
334
+ * (function(){
299
335
  * var glex1_board = JXG.JSXGraph.initBoard('JXGcf99049d-a3fe-407f-b936-27d76550f8c4', {boundingbox:[-6,6,6,-6], keepaspectratio:true, showcopyright: false, shownavigation: false});
300
336
  * var A = glex1_board.create('point', [-1,4]);
301
337
  * var B = glex1_board.create('point', [-1,-4]);
302
338
  * var C = glex1_board.create('point', [1,1]);
303
339
  * var el = glex1_board.create('hyperbola',[A,B,C]);
340
+ * })();
304
341
  * </script><pre>
305
342
  */
306
343
  JXG.createHyperbola = function (board, parents, attributes) {
@@ -482,12 +519,14 @@ define([
482
519
  * var el = board.create('parabola',[C,l]);
483
520
  * </pre><div class="jxgbox" id="JXG524d1aae-217d-44d4-ac58-a19c7ab1de36" style="width: 300px; height: 300px;"></div>
484
521
  * <script type="text/javascript">
522
+ * (function() {
485
523
  * var glex1_board = JXG.JSXGraph.initBoard('JXG524d1aae-217d-44d4-ac58-a19c7ab1de36', {boundingbox:[-6,6,6,-6], keepaspectratio:true, showcopyright: false, shownavigation: false});
486
524
  * var A = glex1_board.create('point', [-1,4]);
487
525
  * var B = glex1_board.create('point', [-1,-4]);
488
526
  * var l = glex1_board.create('line', [A,B]);
489
527
  * var C = glex1_board.create('point', [1,1]);
490
528
  * var el = glex1_board.create('parabola',[C,l]);
529
+ * })();
491
530
  * </script><pre>
492
531
  *
493
532
  * @example
@@ -506,7 +545,7 @@ define([
506
545
  *
507
546
  */
508
547
  JXG.createParabola = function (board, parents, attributes) {
509
- var polarForm, curve, M, i,
548
+ var polarForm, curve, M,
510
549
  // focus
511
550
  F1 = parents[0],
512
551
  // directrix
@@ -535,7 +574,7 @@ define([
535
574
  }
536
575
 
537
576
  // Create line if given as array of two points.
538
- if (Type.isArray(l) && l.length == 2) {
577
+ if (Type.isArray(l) && l.length === 2) {
539
578
  attr_line = Type.copyAttributes(attributes, board.options, 'conic', 'line');
540
579
  l = board.create('line', l, attr_line);
541
580
  }
@@ -684,6 +723,7 @@ define([
684
723
  * var conic = board.create('conic',[A,B,C,D,E]);
685
724
  * </pre><div class="jxgbox" id="JXG2d79bd6a-db9b-423c-9cba-2497f0b06320" style="width: 300px; height: 300px;"></div>
686
725
  * <script type="text/javascript">
726
+ * (function(){
687
727
  * var glex1_board = JXG.JSXGraph.initBoard('JXG2d79bd6a-db9b-423c-9cba-2497f0b06320', {boundingbox:[-6,6,6,-6], keepaspectratio:true, showcopyright: false, shownavigation: false});
688
728
  * var A = glex1_board.create('point', [1,5]);
689
729
  * var B = glex1_board.create('point', [1,2]);
@@ -691,6 +731,7 @@ define([
691
731
  * var D = glex1_board.create('point', [0,0]);
692
732
  * var E = glex1_board.create('point', [-1,5]);
693
733
  * var conic = glex1_board.create('conic',[A,B,C,D,E]);
734
+ * })();
694
735
  * </script><pre>
695
736
  *
696
737
  * @example
@@ -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,
@@ -171,6 +171,7 @@ define([
171
171
  t.Value = function () {
172
172
  return this._value;
173
173
  };
174
+
174
175
  /**
175
176
  * Sets value of the input element.
176
177
  * @name set
@@ -180,6 +181,36 @@ define([
180
181
  * @param {String} val
181
182
  * @returns {JXG.GeometryElement} Reference to the element.
182
183
  *
184
+ * @example
185
+ * var i1 = board.create('input', [-3, 4, 'sin(x)', 'f(x)='], {cssStyle: 'width:4em', maxlength: 2});
186
+ * var c1 = board.create('checkbox', [-3, 2, 'label 1'], {});
187
+ * var b1 = board.create('button', [-3, -1, 'Change texts', function () {
188
+ * i1.setText('g(x)');
189
+ * i1.set('cos(x)');
190
+ * c1.setText('label 2');
191
+ * b1.setText('Texts are changed');
192
+ * }],
193
+ * {cssStyle: 'width:400px'});
194
+ *
195
+ * </pre><div id="JXG11cac8ff-2354-47e7-9da4-eb298e53de05" class="jxgbox" style="width: 300px; height: 300px;"></div>
196
+ * <script type="text/javascript">
197
+ * (function() {
198
+ * var board = JXG.JSXGraph.initBoard('JXG11cac8ff-2354-47e7-9da4-eb298e53de05',
199
+ * {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
200
+ * var i1 = board.create('input', [-3, 4, 'sin(x)', 'f(x)='], {cssStyle: 'width:4em', maxlength: 2});
201
+ * var c1 = board.create('checkbox', [-3, 2, 'label 1'], {});
202
+ * var b1 = board.create('button', [-3, -1, 'Change texts', function () {
203
+ * i1.setText('g(x)');
204
+ * i1.set('cos(x)');
205
+ * c1.setText('label 2');
206
+ * b1.setText('Texts are changed');
207
+ * }],
208
+ * {cssStyle: 'width:400px'});
209
+ *
210
+ * })();
211
+ *
212
+ * </script><pre>
213
+ *
183
214
  */
184
215
  t.set = function (val) {
185
216
  this._value = val;
@@ -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,
@@ -112,7 +112,7 @@ define([
112
112
  c.setParents([p.id]);
113
113
 
114
114
  /**
115
- * should be documented in JXG.Curve
115
+ * Should be documented in JXG.Curve
116
116
  * @ignore
117
117
  */
118
118
  c.updateDataArray = function () {
@@ -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,
@@ -198,7 +198,10 @@ define([
198
198
  };
199
199
 
200
200
  if (type === '2lines') {
201
- el.Radius = function () {
201
+ /**
202
+ * @ignore
203
+ */
204
+ el.Radius = function () {
202
205
  var r = Type.evaluate(parents[4]);
203
206
  if (r === 'auto') {
204
207
  return this.autoRadius();
@@ -299,8 +302,8 @@ define([
299
302
  };
300
303
 
301
304
  el.methodMap = JXG.deepCopy(el.methodMap, {
302
- radius: 'getRadius',
303
- getRadius: 'getRadius',
305
+ radius: 'Radius',
306
+ getRadius: 'Radius',
304
307
  setRadius: 'setRadius'
305
308
  });
306
309
 
@@ -364,8 +367,8 @@ define([
364
367
  center: 'center',
365
368
  radiuspoint: 'radiuspoint',
366
369
  anglepoint: 'anglepoint',
367
- radius: 'getRadius',
368
- getRadius: 'getRadius',
370
+ radius: 'Radius',
371
+ getRadius: 'Radius',
369
372
  setRadius: 'setRadius'
370
373
  });
371
374
 
@@ -579,7 +582,10 @@ define([
579
582
  * @param {Number, Function} value New radius.
580
583
  */
581
584
  el.setRadius = function (val) {
582
- el.Radius = function () {
585
+ /**
586
+ * @ignore
587
+ */
588
+ el.Radius = function () {
583
589
  var r = Type.evaluate(val);
584
590
  if (r === 'auto') {
585
591
  return this.autoRadius();
@@ -965,8 +971,11 @@ define([
965
971
  */
966
972
  el.pointsquare = el.point3 = el.anglepoint = points[2];
967
973
 
968
- // Set the angle radius, also @see @link Sector#autoRadius
974
+ /**
975
+ * @ignore
976
+ */
969
977
  el.Radius = function () {
978
+ // Set the angle radius, also @see @link Sector#autoRadius
970
979
  var r = Type.evaluate(radius);
971
980
  if (r === 'auto') {
972
981
  return el.autoRadius();
@@ -1110,14 +1119,35 @@ define([
1110
1119
  *
1111
1120
  */
1112
1121
  el.setAngle = function (val) {
1113
- var t, t2,
1122
+ var t1, t2, val2,
1114
1123
  p = this.anglepoint,
1115
1124
  q = this.radiuspoint;
1116
1125
 
1117
1126
  if (p.draggable()) {
1118
- t = this.board.create('transform', [val, this.center], {type: 'rotate'});
1119
- p.addTransform(q, t);
1120
- // p.isDraggable = false;
1127
+ t1 = this.board.create('transform', [val, this.center], {type: 'rotate'});
1128
+ p.addTransform(q, t1);
1129
+ // Immediately apply the transformation.
1130
+ // This prevents that jumping elements can be watched.
1131
+ t1.update();
1132
+ p.moveTo(Mat.matVecMult(t1.matrix, q.coords.usrCoords));
1133
+
1134
+ if (Type.isFunction(val)) {
1135
+ /**
1136
+ * @ignore
1137
+ */
1138
+ val2 = function() { return Math.PI * 2 - val(); };
1139
+ } else {
1140
+ /**
1141
+ * @ignore
1142
+ */
1143
+ val2 = function() { return Math.PI * 2 - val; };
1144
+ }
1145
+ t2 = this.board.create('transform', [val2, this.center], {type: 'rotate'});
1146
+ p.coords.on('update', function() {
1147
+ t2.update();
1148
+ q.moveTo(Mat.matVecMult(t2.matrix, p.coords.usrCoords));
1149
+ });
1150
+
1121
1151
  p.setParents(q);
1122
1152
  }
1123
1153
  return this;
@@ -1134,11 +1164,15 @@ define([
1134
1164
  */
1135
1165
  el.free = function () {
1136
1166
  var p = this.anglepoint;
1167
+
1137
1168
  if (p.transformations.length > 0) {
1138
1169
  p.transformations.pop();
1139
1170
  p.isDraggable = true;
1140
1171
  p.parents = [];
1172
+
1173
+ p.coords.off('update');
1141
1174
  }
1175
+
1142
1176
  return this;
1143
1177
  };
1144
1178
 
@@ -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;
@@ -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,