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.
- package/README.md +2 -2
- package/distrib/README.md +2 -2
- package/distrib/geogebra.min.js +3 -3
- package/distrib/geonext.min.js +3 -3
- package/distrib/index.d.ts +651 -448
- package/distrib/intergeo.min.js +3 -3
- package/distrib/jsxgraph.css +4 -13
- package/distrib/jsxgraphcore.js +9 -25
- package/distrib/jsxgraphsrc.js +28203 -25234
- package/distrib/sketch.min.js +3 -3
- package/package.json +11 -22
- package/src/base/board.js +674 -469
- package/src/base/chart.js +1 -1
- package/src/base/circle.js +23 -1
- package/src/base/composition.js +1 -1
- package/src/base/constants.js +32 -11
- package/src/base/coords.js +4 -4
- package/src/base/coordselement.js +51 -24
- package/src/base/curve.js +308 -117
- package/src/base/element.js +79 -50
- package/src/base/foreignobject.js +463 -0
- package/src/base/group.js +2 -2
- package/src/base/image.js +12 -15
- package/src/base/line.js +108 -21
- package/src/base/point.js +24 -28
- package/src/base/polygon.js +75 -18
- package/src/base/text.js +116 -63
- package/src/base/ticks.js +29 -11
- package/src/base/transformation.js +1 -1
- package/src/base/turtle.js +1 -1
- package/src/element/arc.js +1 -1
- package/src/element/button.js +29 -2
- package/src/element/checkbox.js +31 -1
- package/src/element/comb.js +5 -2
- package/src/element/composition.js +127 -19
- package/src/element/conic.js +46 -5
- package/src/element/input.js +32 -1
- package/src/element/locus.js +2 -2
- package/src/element/measure.js +9 -4
- package/src/element/sector.js +46 -12
- package/src/element/slider.js +17 -12
- package/src/element/slopetriangle.js +1 -1
- package/src/jsxgraph.js +28 -9
- package/src/jxg.js +4 -3
- package/src/loadjsxgraph.js +3 -2
- package/src/math/bst.js +1 -1
- package/src/math/clip.js +550 -345
- package/src/math/complex.js +1 -1
- package/src/math/extrapolate.js +1 -1
- package/src/math/geometry.js +155 -126
- package/src/math/ia.js +290 -21
- package/src/math/math.js +30 -1
- package/src/math/metapost.js +1 -1
- package/src/math/nlp.js +25 -5
- package/src/math/numerics.js +183 -4
- package/src/math/plot.js +4 -4
- package/src/math/poly.js +1 -1
- package/src/math/probfuncs.js +2 -1
- package/src/math/qdt.js +68 -62
- package/src/math/statistics.js +58 -7
- package/src/math/symbolic.js +1 -1
- package/src/options.js +377 -114
- package/src/parser/ca.js +1297 -1291
- package/src/parser/datasource.js +1 -1
- package/src/parser/geonext.js +6 -6
- package/src/parser/jessiecode.js +275 -79
- package/src/parser/jessiescript.js +1 -1
- package/src/reader/cinderella.js +1 -1
- package/src/reader/file.js +1 -1
- package/src/reader/geogebra.js +1 -1
- package/src/reader/geonext.js +1 -1
- package/src/reader/graph.js +1 -1
- package/src/reader/intergeo.js +1 -1
- package/src/reader/sketch.js +21 -13
- package/src/renderer/abstract.js +21 -6
- package/src/renderer/canvas.js +22 -15
- package/src/renderer/no.js +11 -4
- package/src/renderer/svg.js +76 -53
- package/src/renderer/vml.js +36 -32
- package/src/server/server.js +1 -1
- package/src/utils/base64.js +2 -2
- package/src/utils/color.js +148 -3
- package/src/utils/dump.js +21 -15
- package/src/utils/env.js +63 -104
- package/src/utils/event.js +1 -1
- package/src/utils/expect.js +1 -1
- package/src/utils/type.js +30 -19
- package/src/utils/xml.js +1 -1
- package/src/utils/zip.js +1 -1
- package/CHANGELOG.md +0 -1281
package/src/base/text.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2008-
|
|
2
|
+
Copyright 2008-2022
|
|
3
3
|
Matthias Ehmann,
|
|
4
4
|
Michael Gerhaeuser,
|
|
5
5
|
Carsten Miller,
|
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
and <http://opensource.org/licenses/MIT/>.
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
|
-
|
|
33
32
|
/*global JXG: true, define: true, window: true*/
|
|
34
33
|
/*jslint nomen: true, plusplus: true*/
|
|
35
34
|
|
|
@@ -56,12 +55,12 @@ define([
|
|
|
56
55
|
"use strict";
|
|
57
56
|
|
|
58
57
|
var priv = {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
HTMLSliderInputEventHandler: function () {
|
|
59
|
+
this._val = parseFloat(this.rendNodeRange.value);
|
|
60
|
+
this.rendNodeOut.value = this.rendNodeRange.value;
|
|
61
|
+
this.board.update();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
65
64
|
|
|
66
65
|
/**
|
|
67
66
|
* Construct and handle texts.
|
|
@@ -99,18 +98,20 @@ define([
|
|
|
99
98
|
* Width and height of the the text element in pixel.
|
|
100
99
|
*
|
|
101
100
|
* @private
|
|
102
|
-
* @type
|
|
101
|
+
* @type Array
|
|
103
102
|
*/
|
|
104
103
|
this.size = [1.0, 1.0];
|
|
105
104
|
this.id = this.board.setId(this, 'T');
|
|
106
105
|
|
|
107
|
-
// Set text before drawing
|
|
108
|
-
this._setUpdateText(content);
|
|
109
|
-
this.updateText();
|
|
110
|
-
|
|
111
106
|
this.board.renderer.drawText(this);
|
|
112
107
|
this.board.finalizeAdding(this);
|
|
113
108
|
|
|
109
|
+
// Set text before drawing
|
|
110
|
+
// this._createFctUpdateText(content);
|
|
111
|
+
// this.updateText();
|
|
112
|
+
|
|
113
|
+
this.setText(content);
|
|
114
|
+
|
|
114
115
|
if (Type.isString(this.content)) {
|
|
115
116
|
this.notifyParents(this.content);
|
|
116
117
|
}
|
|
@@ -133,7 +134,7 @@ define([
|
|
|
133
134
|
* at the left side or at the right side of the text.
|
|
134
135
|
* Sensitivity is set in this.board.options.precision.hasPoint.
|
|
135
136
|
* If dragarea is set to 'all' (default), tests if the the screen
|
|
136
|
-
|
|
137
|
+
* coordinates (x,y) are in within the text boundary.
|
|
137
138
|
* @param {Number} x
|
|
138
139
|
* @param {Number} y
|
|
139
140
|
* @returns {Boolean}
|
|
@@ -177,12 +178,12 @@ define([
|
|
|
177
178
|
top = bot - this.size[1];
|
|
178
179
|
|
|
179
180
|
if (Type.evaluate(this.visProp.dragarea) === 'all') {
|
|
180
|
-
return x >= lft - r && x < rt + r && y >= top - r
|
|
181
|
+
return x >= lft - r && x < rt + r && y >= top - r && y <= bot + r;
|
|
181
182
|
}
|
|
182
183
|
// e.g. 'small'
|
|
183
184
|
return (y >= top - r && y <= bot + r) &&
|
|
184
|
-
((x >= lft - r
|
|
185
|
-
|
|
185
|
+
((x >= lft - r && x <= lft + 2 * r) ||
|
|
186
|
+
(x >= rt - 2 * r && x <= rt + r));
|
|
186
187
|
},
|
|
187
188
|
|
|
188
189
|
/**
|
|
@@ -191,7 +192,7 @@ define([
|
|
|
191
192
|
* @param {String|Function|Number} text
|
|
192
193
|
* @private
|
|
193
194
|
*/
|
|
194
|
-
|
|
195
|
+
_createFctUpdateText: function (text) {
|
|
195
196
|
var updateText, resolvedText,
|
|
196
197
|
ev_p = Type.evaluate(this.visProp.parse),
|
|
197
198
|
ev_um = Type.evaluate(this.visProp.usemathjax),
|
|
@@ -202,7 +203,7 @@ define([
|
|
|
202
203
|
this.updateText = function () {
|
|
203
204
|
resolvedText = text().toString();
|
|
204
205
|
if (ev_p && !ev_um && !ev_uk) {
|
|
205
|
-
this.plaintext = this.replaceSub(this.replaceSup(this.
|
|
206
|
+
this.plaintext = this.replaceSub(this.replaceSup(this.convertGeonextAndSketchometry2CSS(resolvedText)));
|
|
206
207
|
} else {
|
|
207
208
|
this.plaintext = resolvedText;
|
|
208
209
|
}
|
|
@@ -242,7 +243,7 @@ define([
|
|
|
242
243
|
* @private
|
|
243
244
|
*/
|
|
244
245
|
_setText: function (text) {
|
|
245
|
-
this.
|
|
246
|
+
this._createFctUpdateText(text);
|
|
246
247
|
|
|
247
248
|
// First evaluation of the string.
|
|
248
249
|
// We need this for display='internal' and Canvas
|
|
@@ -270,7 +271,6 @@ define([
|
|
|
270
271
|
var s;
|
|
271
272
|
|
|
272
273
|
this.visProp.castext = text;
|
|
273
|
-
|
|
274
274
|
if (Type.isFunction(text)) {
|
|
275
275
|
s = function () {
|
|
276
276
|
return Type.sanitizeHTML(text());
|
|
@@ -308,7 +308,7 @@ define([
|
|
|
308
308
|
* @return {[type]} [description]
|
|
309
309
|
*/
|
|
310
310
|
updateSize: function () {
|
|
311
|
-
var tmp,
|
|
311
|
+
var tmp, that, node,
|
|
312
312
|
ev_d = Type.evaluate(this.visProp.display);
|
|
313
313
|
|
|
314
314
|
if (!Env.isBrowser || this.board.renderer.type === 'no') {
|
|
@@ -346,13 +346,14 @@ define([
|
|
|
346
346
|
} else if (ev_d === 'internal') {
|
|
347
347
|
if (this.board.renderer.type === 'svg') {
|
|
348
348
|
that = this;
|
|
349
|
-
window.setTimeout(function(){
|
|
349
|
+
window.setTimeout(function () {
|
|
350
350
|
try {
|
|
351
351
|
tmp = node.getBBox();
|
|
352
352
|
that.size = [tmp.width, tmp.height];
|
|
353
353
|
that.needsUpdate = true;
|
|
354
354
|
that.updateRenderer();
|
|
355
|
-
} catch (e) {
|
|
355
|
+
} catch (e) {
|
|
356
|
+
}
|
|
356
357
|
}, 0);
|
|
357
358
|
} else if (this.board.renderer.type === 'canvas') {
|
|
358
359
|
this.size = this.crudeSizeEstimate();
|
|
@@ -376,7 +377,7 @@ define([
|
|
|
376
377
|
* @param {String} string
|
|
377
378
|
* @returns {String}
|
|
378
379
|
*/
|
|
379
|
-
utf8_decode
|
|
380
|
+
utf8_decode: function (string) {
|
|
380
381
|
return string.replace(/&#x(\w+);/g, function (m, p1) {
|
|
381
382
|
return String.fromCharCode(parseInt(p1, 16));
|
|
382
383
|
});
|
|
@@ -574,8 +575,8 @@ define([
|
|
|
574
575
|
* @param{String} expr Math term
|
|
575
576
|
* @returns {string} expanded String
|
|
576
577
|
*/
|
|
577
|
-
expandShortMath: function(expr) {
|
|
578
|
-
var re = /([
|
|
578
|
+
expandShortMath: function (expr) {
|
|
579
|
+
var re = /([)0-9.])\s*([(a-zA-Z_])/g;
|
|
579
580
|
return expr.replace(re, '$1*$2');
|
|
580
581
|
},
|
|
581
582
|
|
|
@@ -589,7 +590,7 @@ define([
|
|
|
589
590
|
* @param{Boolean} [avoidGeonext2JS] Optional flag if geonext2JS should be called. For backwards compatibility
|
|
590
591
|
* this has to be set explicitely to true.
|
|
591
592
|
* @private
|
|
592
|
-
* @see JXG.GeonextParser.geonext2JS
|
|
593
|
+
* @see JXG.GeonextParser.geonext2JS
|
|
593
594
|
*/
|
|
594
595
|
generateTerm: function (contentStr, expand, avoidGeonext2JS) {
|
|
595
596
|
var res, term, i, j,
|
|
@@ -649,7 +650,7 @@ define([
|
|
|
649
650
|
}
|
|
650
651
|
|
|
651
652
|
plaintext += ' + "' + this.replaceSub(this.replaceSup(contentStr)) + '"';
|
|
652
|
-
plaintext = this.
|
|
653
|
+
plaintext = this.convertGeonextAndSketchometry2CSS(plaintext);
|
|
653
654
|
|
|
654
655
|
// This should replace &pi; by π
|
|
655
656
|
plaintext = plaintext.replace(/&/g, '&');
|
|
@@ -660,25 +661,76 @@ define([
|
|
|
660
661
|
|
|
661
662
|
/**
|
|
662
663
|
* Converts the GEONExT tags <overline> and <arrow> to
|
|
663
|
-
* HTML span tags with proper CSS
|
|
664
|
+
* HTML span tags with proper CSS formatting.
|
|
664
665
|
* @private
|
|
665
|
-
* @see JXG.Text.generateTerm
|
|
666
|
+
* @see JXG.Text.generateTerm
|
|
667
|
+
* @see JXG.Text._setText
|
|
666
668
|
*/
|
|
667
669
|
convertGeonext2CSS: function (s) {
|
|
668
670
|
if (Type.isString(s)) {
|
|
669
|
-
s = s.replace(
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
s = s.replace(
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
671
|
+
s = s.replace(
|
|
672
|
+
/(<|<)overline(>|>)/g,
|
|
673
|
+
'<span style=text-decoration:overline;>'
|
|
674
|
+
);
|
|
675
|
+
s = s.replace(
|
|
676
|
+
/(<|<)\/overline(>|>)/g,
|
|
677
|
+
'</span>'
|
|
678
|
+
);
|
|
679
|
+
s = s.replace(
|
|
680
|
+
/(<|<)arrow(>|>)/g,
|
|
681
|
+
'<span style=text-decoration:overline;>'
|
|
682
|
+
);
|
|
683
|
+
s = s.replace(
|
|
684
|
+
/(<|<)\/arrow(>|>)/g,
|
|
685
|
+
'</span>'
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
return s;
|
|
690
|
+
},
|
|
691
|
+
|
|
692
|
+
/**
|
|
693
|
+
* Converts the sketchometry tag <sketchofont> to
|
|
694
|
+
* HTML span tags with proper CSS formatting.
|
|
695
|
+
* @private
|
|
696
|
+
* @see JXG.Text.generateTerm
|
|
697
|
+
* @see JXG.Text._setText
|
|
698
|
+
*/
|
|
699
|
+
convertSketchometry2CSS: function (s) {
|
|
700
|
+
if (Type.isString(s)) {
|
|
701
|
+
s = s.replace(
|
|
702
|
+
/(<|<)sketchofont(>|>)/g,
|
|
703
|
+
'<span style=font-family:sketchometry-light;font-weight:500;>'
|
|
704
|
+
);
|
|
705
|
+
s = s.replace(
|
|
706
|
+
/(<|<)\/sketchofont(>|>)/g,
|
|
707
|
+
'</span>'
|
|
708
|
+
);
|
|
709
|
+
s = s.replace(
|
|
710
|
+
/(<|<)sketchometry-light(>|>)/g,
|
|
711
|
+
'<span style=font-family:sketchometry-light;font-weight:500;>'
|
|
712
|
+
);
|
|
713
|
+
s = s.replace(
|
|
714
|
+
/(<|<)\/sketchometry-light(>|>)/g,
|
|
715
|
+
'</span>'
|
|
716
|
+
);
|
|
677
717
|
}
|
|
678
718
|
|
|
679
719
|
return s;
|
|
680
720
|
},
|
|
681
721
|
|
|
722
|
+
/**
|
|
723
|
+
* Alias for convertGeonext2CSS and convertSketchometry2CSS
|
|
724
|
+
* @private
|
|
725
|
+
* @see JXG.Text.convertGeonext2CSS
|
|
726
|
+
* @see JXG.Text.convertSketchometry2CSS
|
|
727
|
+
*/
|
|
728
|
+
convertGeonextAndSketchometry2CSS: function (s){
|
|
729
|
+
s = this.convertGeonext2CSS(s);
|
|
730
|
+
s = this.convertSketchometry2CSS(s);
|
|
731
|
+
return s;
|
|
732
|
+
},
|
|
733
|
+
|
|
682
734
|
/**
|
|
683
735
|
* Finds dependencies in a given term and notifies the parents by adding the
|
|
684
736
|
* dependent object to the found objects child elements.
|
|
@@ -694,7 +746,7 @@ define([
|
|
|
694
746
|
content = content.replace(/<\/value>/g, '</value>');
|
|
695
747
|
|
|
696
748
|
do {
|
|
697
|
-
search = /<value>([\w\s
|
|
749
|
+
search = /<value>([\w\s*/^\-+()[\],<>=!]+)<\/value>/;
|
|
698
750
|
res = search.exec(content);
|
|
699
751
|
|
|
700
752
|
if (res !== null) {
|
|
@@ -732,7 +784,7 @@ define([
|
|
|
732
784
|
return [c[1], c[2] + this.size[1] / this.board.unitY, c[1] + this.size[0] / this.board.unitX, c[2]];
|
|
733
785
|
},
|
|
734
786
|
|
|
735
|
-
getAnchorX: function() {
|
|
787
|
+
getAnchorX: function () {
|
|
736
788
|
var a = Type.evaluate(this.visProp.anchorx);
|
|
737
789
|
if (a === 'auto') {
|
|
738
790
|
switch (this.visProp.position) {
|
|
@@ -753,7 +805,7 @@ define([
|
|
|
753
805
|
return a;
|
|
754
806
|
},
|
|
755
807
|
|
|
756
|
-
getAnchorY: function() {
|
|
808
|
+
getAnchorY: function () {
|
|
757
809
|
var a = Type.evaluate(this.visProp.anchory);
|
|
758
810
|
if (a === 'auto') {
|
|
759
811
|
switch (this.visProp.position) {
|
|
@@ -785,9 +837,9 @@ define([
|
|
|
785
837
|
* @param {Number} h width of the box in pixel
|
|
786
838
|
* @return {Number} Number of overlapping elements
|
|
787
839
|
*/
|
|
788
|
-
getNumberofConflicts: function(x, y, w, h) {
|
|
840
|
+
getNumberofConflicts: function (x, y, w, h) {
|
|
789
841
|
var count = 0,
|
|
790
|
-
|
|
842
|
+
i, obj, le,
|
|
791
843
|
savePointPrecision;
|
|
792
844
|
|
|
793
845
|
// Set the precision of hasPoint to half the max if label isn't too long
|
|
@@ -796,21 +848,21 @@ define([
|
|
|
796
848
|
this.board.options.precision.hasPoint = (w + h) * 0.25;
|
|
797
849
|
// TODO:
|
|
798
850
|
// Make it compatible with the objects' visProp.precision attribute
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
851
|
+
for (i = 0, le = this.board.objectsList.length; i < le; i++) {
|
|
852
|
+
obj = this.board.objectsList[i];
|
|
853
|
+
if (obj.visPropCalc.visible &&
|
|
802
854
|
obj.elType !== 'axis' &&
|
|
803
855
|
obj.elType !== 'ticks' &&
|
|
804
856
|
obj !== this.board.infobox &&
|
|
805
857
|
obj !== this &&
|
|
806
858
|
obj.hasPoint(x, y)) {
|
|
807
859
|
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
860
|
+
count++;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
811
863
|
this.board.options.precision.hasPoint = savePointPrecision;
|
|
812
864
|
|
|
813
|
-
|
|
865
|
+
return count;
|
|
814
866
|
},
|
|
815
867
|
|
|
816
868
|
/**
|
|
@@ -820,9 +872,10 @@ define([
|
|
|
820
872
|
*
|
|
821
873
|
* @returns {JXG.Text} Reference to the text object.
|
|
822
874
|
*/
|
|
823
|
-
setAutoPosition: function() {
|
|
875
|
+
setAutoPosition: function () {
|
|
824
876
|
var x, y, cx, cy,
|
|
825
|
-
anchorCoords,
|
|
877
|
+
anchorCoords,
|
|
878
|
+
// anchorX, anchorY,
|
|
826
879
|
w = this.size[0],
|
|
827
880
|
h = this.size[1],
|
|
828
881
|
start_angle, angle,
|
|
@@ -844,8 +897,8 @@ define([
|
|
|
844
897
|
return this;
|
|
845
898
|
}
|
|
846
899
|
|
|
847
|
-
anchorX = Type.evaluate(this.visProp.anchorx);
|
|
848
|
-
anchorY = Type.evaluate(this.visProp.anchory);
|
|
900
|
+
// anchorX = Type.evaluate(this.visProp.anchorx);
|
|
901
|
+
// anchorY = Type.evaluate(this.visProp.anchory);
|
|
849
902
|
offset = Type.evaluate(this.visProp.offset);
|
|
850
903
|
anchorCoords = this.element.getLabelAnchor();
|
|
851
904
|
cx = anchorCoords.scrCoords[1];
|
|
@@ -870,8 +923,8 @@ define([
|
|
|
870
923
|
start_angle = Math.atan2(dy, dx);
|
|
871
924
|
|
|
872
925
|
optimum.conflicts = conflicts;
|
|
873
|
-
optimum.angle
|
|
874
|
-
optimum.r
|
|
926
|
+
optimum.angle = start_angle;
|
|
927
|
+
optimum.r = r;
|
|
875
928
|
|
|
876
929
|
while (optimum.conflicts > 0 && r < max_r) {
|
|
877
930
|
for (j = 1, angle = start_angle + step; j < num_positions && optimum.conflicts > 0; j++) {
|
|
@@ -880,12 +933,12 @@ define([
|
|
|
880
933
|
|
|
881
934
|
x = cx + r * co;
|
|
882
935
|
y = cy - r * si;
|
|
883
|
-
|
|
936
|
+
|
|
884
937
|
conflicts = this.getNumberofConflicts(x, y, w, h);
|
|
885
938
|
if (conflicts < optimum.conflicts) {
|
|
886
939
|
optimum.conflicts = conflicts;
|
|
887
|
-
optimum.angle
|
|
888
|
-
optimum.r
|
|
940
|
+
optimum.angle = angle;
|
|
941
|
+
optimum.r = r;
|
|
889
942
|
}
|
|
890
943
|
if (optimum.conflicts === 0) {
|
|
891
944
|
break;
|
|
@@ -992,8 +1045,8 @@ define([
|
|
|
992
1045
|
|
|
993
1046
|
if (!t) {
|
|
994
1047
|
throw new Error("JSXGraph: Can't create text with parent types '" +
|
|
995
|
-
|
|
996
|
-
|
|
1048
|
+
(typeof parents[0]) + "' and '" + (typeof parents[1]) + "'." +
|
|
1049
|
+
"\nPossible parent types: [x,y], [z,x,y], [element,transformation]");
|
|
997
1050
|
}
|
|
998
1051
|
|
|
999
1052
|
if (attr.rotate !== 0 && attr.display === 'internal') { // This is the default value, i.e. no rotation
|
|
@@ -1065,7 +1118,7 @@ define([
|
|
|
1065
1118
|
t.rendNodeForm.id = t.rendNode.id + '_form';
|
|
1066
1119
|
t.rendNodeRange.id = t.rendNode.id + '_range';
|
|
1067
1120
|
t.rendNodeOut.id = t.rendNode.id + '_out';
|
|
1068
|
-
|
|
1121
|
+
} catch (e) {
|
|
1069
1122
|
JXG.debug(e);
|
|
1070
1123
|
}
|
|
1071
1124
|
|
package/src/base/ticks.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2008-
|
|
2
|
+
Copyright 2008-2022
|
|
3
3
|
Matthias Ehmann,
|
|
4
4
|
Michael Gerhaeuser,
|
|
5
5
|
Carsten Miller,
|
|
@@ -133,13 +133,13 @@ define([
|
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* Stores the ticks coordinates
|
|
136
|
-
* @type
|
|
136
|
+
* @type Array
|
|
137
137
|
*/
|
|
138
138
|
this.ticks = [];
|
|
139
139
|
|
|
140
140
|
/**
|
|
141
141
|
* Distance between two major ticks in user coordinates
|
|
142
|
-
* @type
|
|
142
|
+
* @type Number
|
|
143
143
|
*/
|
|
144
144
|
this.ticksDelta = 1;
|
|
145
145
|
|
|
@@ -153,13 +153,13 @@ define([
|
|
|
153
153
|
|
|
154
154
|
/**
|
|
155
155
|
* A list of labels which have to be displayed in updateRenderer.
|
|
156
|
-
* @type
|
|
156
|
+
* @type Array
|
|
157
157
|
*/
|
|
158
158
|
this.labelData = [];
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
161
|
* To ensure the uniqueness of label ids this counter is used.
|
|
162
|
-
* @type
|
|
162
|
+
* @type number
|
|
163
163
|
*/
|
|
164
164
|
this.labelCounter = 0;
|
|
165
165
|
|
|
@@ -279,22 +279,23 @@ define([
|
|
|
279
279
|
return this;
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
// horizontal line
|
|
283
282
|
if (Math.abs(this.line.stdform[1]) < Mat.eps &&
|
|
284
283
|
Math.abs(c.usrCoords[1] * oldc.usrCoords[1]) > Mat.eps) {
|
|
285
284
|
|
|
285
|
+
// Horizontal line
|
|
286
286
|
dx = oldc.usrCoords[1] / c.usrCoords[1];
|
|
287
287
|
bb[0] *= dx;
|
|
288
288
|
bb[2] *= dx;
|
|
289
|
-
this.board.setBoundingBox(bb,
|
|
290
|
-
|
|
289
|
+
this.board.setBoundingBox(bb, this.board.keepaspectratio, 'update');
|
|
290
|
+
|
|
291
291
|
} else if (Math.abs(this.line.stdform[2]) < Mat.eps &&
|
|
292
292
|
Math.abs(c.usrCoords[2] * oldc.usrCoords[2]) > Mat.eps) {
|
|
293
293
|
|
|
294
|
+
// Vertical line
|
|
294
295
|
dy = oldc.usrCoords[2] / c.usrCoords[2];
|
|
295
296
|
bb[3] *= dy;
|
|
296
297
|
bb[1] *= dy;
|
|
297
|
-
this.board.setBoundingBox(bb,
|
|
298
|
+
this.board.setBoundingBox(bb, this.board.keepaspectratio, 'update');
|
|
298
299
|
}
|
|
299
300
|
|
|
300
301
|
return this;
|
|
@@ -670,11 +671,16 @@ define([
|
|
|
670
671
|
tickPosition = ticksDelta;
|
|
671
672
|
}
|
|
672
673
|
while (tickPosition <= bounds.upper + eps2) {
|
|
673
|
-
// Only draw ticks when we are within bounds, ignore case where
|
|
674
|
+
// Only draw ticks when we are within bounds, ignore case where tickPosition < lower < upper
|
|
674
675
|
if (tickPosition >= bounds.lower - eps2) {
|
|
675
676
|
this.processTickPosition(coordsZero, tickPosition, ticksDelta, deltas);
|
|
676
677
|
}
|
|
677
678
|
tickPosition += ticksDelta;
|
|
679
|
+
|
|
680
|
+
// Emergency out
|
|
681
|
+
if ((bounds.upper - tickPosition) > ticksDelta * 10000) {
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
678
684
|
}
|
|
679
685
|
|
|
680
686
|
// Position ticks from zero (not inclusive) to the negative side while not reaching the lower boundary
|
|
@@ -685,6 +691,11 @@ define([
|
|
|
685
691
|
this.processTickPosition(coordsZero, tickPosition, ticksDelta, deltas);
|
|
686
692
|
}
|
|
687
693
|
tickPosition -= ticksDelta;
|
|
694
|
+
|
|
695
|
+
// Emergency out
|
|
696
|
+
if ((tickPosition - bounds.lower) > ticksDelta * 10000) {
|
|
697
|
+
break;
|
|
698
|
+
}
|
|
688
699
|
}
|
|
689
700
|
},
|
|
690
701
|
|
|
@@ -1006,13 +1017,20 @@ define([
|
|
|
1006
1017
|
*/
|
|
1007
1018
|
formatLabelText: function(value) {
|
|
1008
1019
|
var labelText = value.toString(),
|
|
1020
|
+
digits,
|
|
1009
1021
|
ev_s = Type.evaluate(this.visProp.scalesymbol);
|
|
1010
1022
|
|
|
1011
1023
|
// if value is Number
|
|
1012
1024
|
if (Type.isNumber(value)) {
|
|
1013
1025
|
if (labelText.length > Type.evaluate(this.visProp.maxlabellength) ||
|
|
1014
1026
|
labelText.indexOf('e') !== -1) {
|
|
1015
|
-
|
|
1027
|
+
|
|
1028
|
+
digits = Type.evaluate(this.visProp.digits);
|
|
1029
|
+
if (Type.evaluate(this.visProp.precision) !== 3 && digits === 3) {
|
|
1030
|
+
// Use the deprecated attribute "precision"
|
|
1031
|
+
digits = Type.evaluate(this.visProp.precision);
|
|
1032
|
+
}
|
|
1033
|
+
labelText = value.toPrecision(digits).toString();
|
|
1016
1034
|
}
|
|
1017
1035
|
|
|
1018
1036
|
if (Type.evaluate(this.visProp.beautifulscientificticklabels)) {
|
package/src/base/turtle.js
CHANGED
package/src/element/arc.js
CHANGED
package/src/element/button.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2008-
|
|
2
|
+
Copyright 2008-2022
|
|
3
3
|
Matthias Ehmann,
|
|
4
4
|
Michael Gerhaeuser,
|
|
5
5
|
Carsten Miller,
|
|
@@ -160,7 +160,35 @@ define([
|
|
|
160
160
|
* visible: () => butt.value
|
|
161
161
|
* });
|
|
162
162
|
*
|
|
163
|
+
* })();
|
|
164
|
+
*
|
|
165
|
+
* </script><pre>
|
|
163
166
|
*
|
|
167
|
+
* @example
|
|
168
|
+
* var i1 = board.create('input', [-3, 4, 'sin(x)', 'f(x)='], {cssStyle: 'width:4em', maxlength: 2});
|
|
169
|
+
* var c1 = board.create('checkbox', [-3, 2, 'label 1'], {});
|
|
170
|
+
* var b1 = board.create('button', [-3, -1, 'Change texts', function () {
|
|
171
|
+
* i1.setText('g(x)');
|
|
172
|
+
* i1.set('cos(x)');
|
|
173
|
+
* c1.setText('label 2');
|
|
174
|
+
* b1.setText('Texts are changed');
|
|
175
|
+
* }],
|
|
176
|
+
* {cssStyle: 'width:400px'});
|
|
177
|
+
*
|
|
178
|
+
* </pre><div id="JXG11cac8ff-2354-47e7-9da4-eb928e53de05" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
179
|
+
* <script type="text/javascript">
|
|
180
|
+
* (function() {
|
|
181
|
+
* var board = JXG.JSXGraph.initBoard('JXG11cac8ff-2354-47e7-9da4-eb928e53de05',
|
|
182
|
+
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
183
|
+
* var i1 = board.create('input', [-3, 4, 'sin(x)', 'f(x)='], {cssStyle: 'width:4em', maxlength: 2});
|
|
184
|
+
* var c1 = board.create('checkbox', [-3, 2, 'label 1'], {});
|
|
185
|
+
* var b1 = board.create('button', [-3, -1, 'Change texts', function () {
|
|
186
|
+
* i1.setText('g(x)');
|
|
187
|
+
* i1.set('cos(x)');
|
|
188
|
+
* c1.setText('label 2');
|
|
189
|
+
* b1.setText('Texts are changed');
|
|
190
|
+
* }],
|
|
191
|
+
* {cssStyle: 'width:400px'});
|
|
164
192
|
*
|
|
165
193
|
* })();
|
|
166
194
|
*
|
|
@@ -206,7 +234,6 @@ define([
|
|
|
206
234
|
}
|
|
207
235
|
|
|
208
236
|
Env.addEvent(t.rendNodeButton, 'click', priv.ButtonClickEventHandler, t);
|
|
209
|
-
|
|
210
237
|
Env.addEvent(t.rendNodeButton, 'mousedown', function (evt) { if (Type.exists(evt.stopPropagation)) { evt.stopPropagation(); } }, t);
|
|
211
238
|
Env.addEvent(t.rendNodeButton, 'touchstart', function (evt) { if (Type.exists(evt.stopPropagation)) { evt.stopPropagation(); } }, t);
|
|
212
239
|
Env.addEvent(t.rendNodeButton, 'pointerdown', function (evt) { if (Type.exists(evt.stopPropagation)) { evt.stopPropagation(); } }, t);
|
package/src/element/checkbox.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2008-
|
|
2
|
+
Copyright 2008-2022
|
|
3
3
|
Matthias Ehmann,
|
|
4
4
|
Michael Gerhaeuser,
|
|
5
5
|
Carsten Miller,
|
|
@@ -137,6 +137,36 @@ define([
|
|
|
137
137
|
* }, checkbox);
|
|
138
138
|
* })();
|
|
139
139
|
* </script><pre>
|
|
140
|
+
*
|
|
141
|
+
* @example
|
|
142
|
+
* var i1 = board.create('input', [-3, 4, 'sin(x)', 'f(x)='], {cssStyle: 'width:4em', maxlength: 2});
|
|
143
|
+
* var c1 = board.create('checkbox', [-3, 2, 'label 1'], {});
|
|
144
|
+
* var b1 = board.create('button', [-3, -1, 'Change texts', function () {
|
|
145
|
+
* i1.setText('g(x)');
|
|
146
|
+
* i1.set('cos(x)');
|
|
147
|
+
* c1.setText('label 2');
|
|
148
|
+
* b1.setText('Texts are changed');
|
|
149
|
+
* }],
|
|
150
|
+
* {cssStyle: 'width:400px'});
|
|
151
|
+
*
|
|
152
|
+
* </pre><div id="JXG11cac8gg-2354-47e7-9da4-eb298e53de05" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
153
|
+
* <script type="text/javascript">
|
|
154
|
+
* (function() {
|
|
155
|
+
* var board = JXG.JSXGraph.initBoard('JXG11cac8gg-2354-47e7-9da4-eb298e53de05',
|
|
156
|
+
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
157
|
+
* var i1 = board.create('input', [-3, 4, 'sin(x)', 'f(x)='], {cssStyle: 'width:4em', maxlength: 2});
|
|
158
|
+
* var c1 = board.create('checkbox', [-3, 2, 'label 1'], {});
|
|
159
|
+
* var b1 = board.create('button', [-3, -1, 'Change texts', function () {
|
|
160
|
+
* i1.setText('g(x)');
|
|
161
|
+
* i1.set('cos(x)');
|
|
162
|
+
* c1.setText('label 2');
|
|
163
|
+
* b1.setText('Texts are changed');
|
|
164
|
+
* }],
|
|
165
|
+
* {cssStyle: 'width:400px'});
|
|
166
|
+
*
|
|
167
|
+
* })();
|
|
168
|
+
*
|
|
169
|
+
* </script><pre>
|
|
140
170
|
*/
|
|
141
171
|
JXG.createCheckbox = function (board, parents, attributes) {
|
|
142
172
|
var t, par,
|
package/src/element/comb.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2018-
|
|
2
|
+
Copyright 2018-2022
|
|
3
3
|
Alfred Wassermann,
|
|
4
4
|
Tigran Saluev
|
|
5
5
|
|
|
@@ -176,7 +176,10 @@ define([
|
|
|
176
176
|
Type.merge(attr, Type.copyAttributes(attributes, board.options, 'comb', 'curve'));
|
|
177
177
|
c = board.create('curve', [[0], [0]], attr);
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
/**
|
|
180
|
+
* @ignore
|
|
181
|
+
*/
|
|
182
|
+
c.updateDataArray = function() {
|
|
180
183
|
var s = 0,
|
|
181
184
|
max_s = p1.Dist(p2),
|
|
182
185
|
cs, sn, dx, dy,
|