jsxgraph 1.4.5 → 1.4.6
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/build/Readme.md +17 -0
- package/build/bin/jsxcompressor.js +1 -0
- package/build/bin/jsxgraphcore-min.js +7 -0
- package/build/bin/jsxgraphcore.js +83017 -0
- package/build/bin/jsxgraphcore.min.js +67 -0
- package/build/compressor.build.json +14 -0
- package/build/compressor.deps.js +8 -0
- package/build/core-amd.build.json +14 -0
- package/build/core-amd.deps.js +81 -0
- package/build/core.build.json +14 -0
- package/build/core.deps.js +102 -0
- package/build/plot.build.json +15 -0
- package/distrib/geogebra.min.js +1 -1
- package/distrib/geonext.min.js +1 -1
- package/distrib/index.d.ts +1 -0
- package/distrib/intergeo.min.js +1 -1
- package/distrib/jsxgraph.css +6 -0
- package/distrib/jsxgraphcore.js +3 -3
- package/distrib/jsxgraphsrc.js +3326 -1816
- package/distrib/sketch.min.js +1 -1
- package/package.json +1 -1
- package/src/3d/box3d.js +43 -38
- package/src/3d/curve3d.js +157 -53
- package/src/3d/element3d.js +84 -0
- package/src/3d/linspace3d.js +427 -146
- package/src/3d/point3d.js +352 -153
- package/src/3d/surface3d.js +140 -42
- package/src/3d/view3d.js +319 -164
- package/src/base/board.js +42 -26
- package/src/base/constants.js +8 -1
- package/src/base/curve.js +51 -9
- package/src/base/polygon.js +111 -69
- package/src/base/text.js +125 -51
- package/src/base/ticks.js +11 -2
- package/src/element/button.js +7 -3
- package/src/element/checkbox.js +8 -4
- package/src/element/composition.js +7 -1
- package/src/element/conic.js +2 -2
- package/src/element/input.js +9 -5
- package/src/jsxgraph.js +2 -0
- package/src/loadjsxgraph.js +13 -8
- package/src/math/clip.js +34 -134
- package/src/math/geometry.js +204 -3
- package/src/math/math.js +1 -2
- package/src/math/nlp.js +789 -730
- package/src/options.js +159 -8
- package/src/options3d.js +24 -7
- package/src/parser/jessiecode.js +8 -2
- package/src/renderer/abstract.js +26 -15
- package/src/renderer/canvas.js +2 -2
- package/src/renderer/svg.js +15 -2
- package/src/utils/env.js +29 -46
- package/src/utils/type.js +75 -2
- package/src/3d/threed.js +0 -38
package/src/utils/env.js
CHANGED
|
@@ -793,53 +793,14 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
793
793
|
window.setTimeout(timerFun, 1);
|
|
794
794
|
},
|
|
795
795
|
|
|
796
|
-
/**
|
|
797
|
-
* Calculate the scale factor and vertical shift for the JSXGraph div
|
|
798
|
-
* in full screen mode.
|
|
799
|
-
*
|
|
800
|
-
* @param {Object} obj Reference to a DOM node.
|
|
801
|
-
* @returns Object {scale: number, vshift: number}
|
|
802
|
-
* @see JXG.Board#fullscreenListener
|
|
803
|
-
* @private
|
|
804
|
-
*/
|
|
805
|
-
_getScaleFactors: function (node) {
|
|
806
|
-
var width = node.getBoundingClientRect().width,
|
|
807
|
-
height = node.getBoundingClientRect().height,
|
|
808
|
-
|
|
809
|
-
// Determine the maximum scale factor.
|
|
810
|
-
r_w = window.screen.width / width,
|
|
811
|
-
r_h = window.screen.height / height,
|
|
812
|
-
|
|
813
|
-
// Determine the vertical shift to place the div in the center of the screen
|
|
814
|
-
vshift = (window.screen.height - height) * 0.5,
|
|
815
|
-
|
|
816
|
-
// Scaling factor: if not supplied, it's taken as large as possible
|
|
817
|
-
scale = Math.min(r_w, r_h);
|
|
818
|
-
|
|
819
|
-
// Adapt vshift and scale for landscape on tablets
|
|
820
|
-
if (window.matchMedia && window.matchMedia('(orientation:landscape)').matches &&
|
|
821
|
-
window.screen.width < window.screen.height) {
|
|
822
|
-
// Landscape on iOS: it returns 'landscape', but still width < height.
|
|
823
|
-
r_w = window.screen.height / width;
|
|
824
|
-
r_h = window.screen.width / height;
|
|
825
|
-
scale = Math.min(r_w, r_h);
|
|
826
|
-
vshift = (window.screen.width - height) * 0.5;
|
|
827
|
-
}
|
|
828
|
-
scale *= 0.85;
|
|
829
|
-
|
|
830
|
-
return { scale: scale, vshift: vshift, width: width };
|
|
831
|
-
},
|
|
832
|
-
|
|
833
796
|
/**
|
|
834
797
|
* Scale and vertically shift a DOM element (usually a JSXGraph div)
|
|
835
798
|
* inside of a parent DOM
|
|
836
799
|
* element which is set to fullscreen.
|
|
837
800
|
* This is realized with a CSS transformation.
|
|
838
|
-
*
|
|
801
|
+
*
|
|
839
802
|
* @param {String} wrap_id id of the parent DOM element which is in fullscreen mode
|
|
840
803
|
* @param {String} inner_id id of the DOM element which is scaled and shifted
|
|
841
|
-
* @param {Number} scale Scaling factor
|
|
842
|
-
* @param {Number} vshift Vertical shift (in pixel)
|
|
843
804
|
* @param {Object} doc document object or shadow root
|
|
844
805
|
*
|
|
845
806
|
* @private
|
|
@@ -847,19 +808,37 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
847
808
|
* @see JXG.Board#fullscreenListener
|
|
848
809
|
*
|
|
849
810
|
*/
|
|
850
|
-
|
|
851
|
-
var len = doc.styleSheets.length, style,
|
|
811
|
+
scaleJSXGraphDiv: function (wrap_id, inner_id, doc) {
|
|
812
|
+
var len = doc.styleSheets.length, style, rule, w, h, b, wi, hi, bi,
|
|
813
|
+
scale_l, vshift_l, // scale_p, vshift_p,
|
|
814
|
+
f = 0.85,
|
|
815
|
+
rule_inner_l, // rule_inner_p,
|
|
852
816
|
|
|
853
817
|
pseudo_keys = [':fullscreen', ':-webkit-full-screen', ':-moz-full-screen', ':-ms-fullscreen'],
|
|
854
818
|
len_pseudo = pseudo_keys.length, i,
|
|
855
819
|
|
|
856
|
-
// CSS rules to center the inner div horizontally and vertically.
|
|
857
|
-
rule_inner = '{margin:0 auto;transform:matrix(' + scale + ',0,0,' + scale + ',0,' + vshift + ');}',
|
|
858
|
-
|
|
859
820
|
// A previously installed CSS rule to center the JSXGraph div has to
|
|
860
821
|
// be searched and removed again.
|
|
861
822
|
regex = new RegExp('.*#' + wrap_id + ':.*full.*screen.*#' + inner_id + '.*auto;.*transform:.*matrix');
|
|
862
823
|
|
|
824
|
+
b = doc.getElementById(wrap_id).getBoundingClientRect();
|
|
825
|
+
h = b.height;
|
|
826
|
+
w = b.width;
|
|
827
|
+
|
|
828
|
+
bi = doc.getElementById(inner_id).getBoundingClientRect();
|
|
829
|
+
hi = bi.height;
|
|
830
|
+
wi = bi.width;
|
|
831
|
+
|
|
832
|
+
if (wi / hi >= w / h) {
|
|
833
|
+
scale_l = f * w / wi;
|
|
834
|
+
} else {
|
|
835
|
+
scale_l = f * h / hi;
|
|
836
|
+
}
|
|
837
|
+
vshift_l = (h - hi) * 0.5;
|
|
838
|
+
|
|
839
|
+
// CSS rules to center the inner div horizontally and vertically.
|
|
840
|
+
rule_inner_l = '{margin:0 auto;transform:matrix(' + scale_l + ',0,0,' + scale_l + ',0,' + vshift_l + ');}';
|
|
841
|
+
|
|
863
842
|
if (len === 0) {
|
|
864
843
|
// In case there is not a single CSS rule defined at all.
|
|
865
844
|
style = document.createElement('style');
|
|
@@ -880,7 +859,10 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
880
859
|
// Install a CSS rule to center the JSXGraph div at the first position of the list.
|
|
881
860
|
for (i = 0; i < len_pseudo; i++) {
|
|
882
861
|
try {
|
|
883
|
-
|
|
862
|
+
rule = '#' + wrap_id + pseudo_keys[i] + ' #' + inner_id + rule_inner_l;
|
|
863
|
+
// rule = '@media all and (orientation:landscape) {' + rule + '}';
|
|
864
|
+
doc.styleSheets[len - 1].insertRule(rule, 0);
|
|
865
|
+
|
|
884
866
|
break;
|
|
885
867
|
} catch (err) {
|
|
886
868
|
// console.log('JXG.scaleJSXGraphDiv: Could not add CSS rule "' + pseudo_keys[i] + '".');
|
|
@@ -892,6 +874,7 @@ define(['jxg', 'utils/type'], function (JXG, Type) {
|
|
|
892
874
|
console.log('One possible reason could be that the id of the JSXGraph container does not start with a letter.');
|
|
893
875
|
}
|
|
894
876
|
}
|
|
877
|
+
|
|
895
878
|
});
|
|
896
879
|
|
|
897
880
|
return JXG;
|
package/src/utils/type.js
CHANGED
|
@@ -141,13 +141,21 @@ define([
|
|
|
141
141
|
* @returns {Boolean} True, if v is of type JXG.Point.
|
|
142
142
|
*/
|
|
143
143
|
isPoint: function (v) {
|
|
144
|
-
if (v !== null && typeof v === 'object') {
|
|
144
|
+
if (v !== null && typeof v === 'object' && this.exists(v.elementClass)) {
|
|
145
145
|
return (v.elementClass === Const.OBJECT_CLASS_POINT);
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
return false;
|
|
149
149
|
},
|
|
150
150
|
|
|
151
|
+
isPoint3D: function (v) {
|
|
152
|
+
if (v !== null && typeof v === 'object' && this.exists(v.elType)) {
|
|
153
|
+
return (v.elType === 'point3d');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
return false;
|
|
157
|
+
},
|
|
158
|
+
|
|
151
159
|
/**
|
|
152
160
|
* Checks if a given variable is a reference of a JSXGraph Point element or an array of length at least two or
|
|
153
161
|
* a function returning an array of length two or three.
|
|
@@ -395,6 +403,71 @@ define([
|
|
|
395
403
|
return points;
|
|
396
404
|
},
|
|
397
405
|
|
|
406
|
+
/**
|
|
407
|
+
* Test if the parents array contains existing points. If instead parents contains coordinate arrays or
|
|
408
|
+
* function returning coordinate arrays
|
|
409
|
+
* free points with these coordinates are created.
|
|
410
|
+
*
|
|
411
|
+
* @param {JXG.View3D} view View3D object
|
|
412
|
+
* @param {Array} parents Array containing parent elements for a new object. This array may contain
|
|
413
|
+
* <ul>
|
|
414
|
+
* <li> {@link JXG.Point3D} objects
|
|
415
|
+
* <li> {@link JXG.GeometryElement#name} of {@link JXG.Point3D} objects
|
|
416
|
+
* <li> {@link JXG.GeometryElement#id} of {@link JXG.Point3D} objects
|
|
417
|
+
* <li> Coordinates of 3D points given as array of numbers of length three, e.g. [2, 3, 1].
|
|
418
|
+
* <li> Coordinates of 3D points given as array of functions of length three. Each function returns one coordinate, e.g.
|
|
419
|
+
* [function(){ return 2; }, function(){ return 3; }, function(){ return 1; }]
|
|
420
|
+
* <li> Function returning coordinates, e.g. function() { return [2, 3, 1]; }
|
|
421
|
+
* </ul>
|
|
422
|
+
* In the last three cases a new 3D point will be created.
|
|
423
|
+
* @param {String} attrClass Main attribute class of newly created 3D points, see {@link JXG#copyAttributes}
|
|
424
|
+
* @param {Array} attrArray List of subtype attributes for the newly created 3D points. The list of subtypes is mapped to the list of new 3D points.
|
|
425
|
+
* @returns {Array} List of newly created {@link JXG.Point3D} elements or false if not all returned elements are 3D points.
|
|
426
|
+
*/
|
|
427
|
+
providePoints3D: function (view, parents, attributes, attrClass, attrArray) {
|
|
428
|
+
var i, j,
|
|
429
|
+
len,
|
|
430
|
+
lenAttr = 0,
|
|
431
|
+
points = [], attr, val;
|
|
432
|
+
|
|
433
|
+
if (!this.isArray(parents)) {
|
|
434
|
+
parents = [parents];
|
|
435
|
+
}
|
|
436
|
+
len = parents.length;
|
|
437
|
+
if (this.exists(attrArray)) {
|
|
438
|
+
lenAttr = attrArray.length;
|
|
439
|
+
}
|
|
440
|
+
if (lenAttr === 0) {
|
|
441
|
+
attr = this.copyAttributes(attributes, view.board.options, attrClass);
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
for (i = 0; i < len; ++i) {
|
|
445
|
+
if (lenAttr > 0) {
|
|
446
|
+
j = Math.min(i, lenAttr - 1);
|
|
447
|
+
attr = this.copyAttributes(attributes, view.board.options, attrClass, attrArray[j]);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
if (this.isArray(parents[i]) && parents[i].length > 1) {
|
|
451
|
+
points.push(view.create('point3d', parents[i], attr));
|
|
452
|
+
points[points.length - 1]._is_new = true;
|
|
453
|
+
} else if (this.isFunction(parents[i])) {
|
|
454
|
+
val = parents[i]();
|
|
455
|
+
if (this.isArray(val) && (val.length > 1)) {
|
|
456
|
+
points.push(view.create('point3d', [parents[i]], attr));
|
|
457
|
+
points[points.length - 1]._is_new = true;
|
|
458
|
+
}
|
|
459
|
+
} else {
|
|
460
|
+
points.push(view.select(parents[i]));
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
if (!this.isPoint3D(points[i])) {
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
return points;
|
|
469
|
+
},
|
|
470
|
+
|
|
398
471
|
/**
|
|
399
472
|
* Generates a function which calls the function fn in the scope of owner.
|
|
400
473
|
* @param {Function} fn Function to call.
|
|
@@ -732,7 +805,7 @@ define([
|
|
|
732
805
|
var x = Math.abs(val),
|
|
733
806
|
str;
|
|
734
807
|
|
|
735
|
-
if (x
|
|
808
|
+
if (x >= 0.1) {
|
|
736
809
|
str = this.toFixed(val, 2);
|
|
737
810
|
} else if (x >= 0.01) {
|
|
738
811
|
str = this.toFixed(val, 4);
|
package/src/3d/threed.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2008-2022
|
|
3
|
-
Matthias Ehmann,
|
|
4
|
-
Carsten Miller,
|
|
5
|
-
Andreas Walter,
|
|
6
|
-
Alfred Wassermann
|
|
7
|
-
|
|
8
|
-
This file is part of JSXGraph.
|
|
9
|
-
|
|
10
|
-
JSXGraph is free software dual licensed under the GNU LGPL or MIT License.
|
|
11
|
-
|
|
12
|
-
You can redistribute it and/or modify it under the terms of the
|
|
13
|
-
|
|
14
|
-
* GNU Lesser General Public License as published by
|
|
15
|
-
the Free Software Foundation, either version 3 of the License, or
|
|
16
|
-
(at your option) any later version
|
|
17
|
-
OR
|
|
18
|
-
* MIT License: https://github.com/jsxgraph/jsxgraph/blob/master/LICENSE.MIT
|
|
19
|
-
|
|
20
|
-
JSXGraph is distributed in the hope that it will be useful,
|
|
21
|
-
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22
|
-
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
23
|
-
GNU Lesser General Public License for more details.
|
|
24
|
-
|
|
25
|
-
You should have received a copy of the GNU Lesser General Public License and
|
|
26
|
-
the MIT License along with JSXGraph. If not, see <http://www.gnu.org/licenses/>
|
|
27
|
-
and <http://opensource.org/licenses/MIT/>.
|
|
28
|
-
*/
|
|
29
|
-
/*global JXG:true, define: true*/
|
|
30
|
-
|
|
31
|
-
define(['jxg'
|
|
32
|
-
], function (JXG) {
|
|
33
|
-
"use strict";
|
|
34
|
-
|
|
35
|
-
JXG.ThreeD = {};
|
|
36
|
-
|
|
37
|
-
return JXG.ThreeD;
|
|
38
|
-
});
|