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/jsxgraph.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,
|
|
@@ -192,6 +192,7 @@ define([
|
|
|
192
192
|
attr.navbar = Type.copyAttributes(attr.navbar, Options, 'navbar');
|
|
193
193
|
attr.screenshot = Type.copyAttributes(attr, Options, 'board', 'screenshot');
|
|
194
194
|
attr.resize = Type.copyAttributes(attr, Options, 'board', 'resize');
|
|
195
|
+
attr.fullscreen = Type.copyAttributes(attr, Options, 'board', 'fullscreen');
|
|
195
196
|
|
|
196
197
|
// Treat moveTarget separately, because deepCopy will not work here.
|
|
197
198
|
// Reason: moveTarget will be an HTML node and it is prevented that Type.deepCopy will copy it.
|
|
@@ -303,6 +304,8 @@ define([
|
|
|
303
304
|
initBoard: function (box, attributes) {
|
|
304
305
|
var originX, originY, unitX, unitY,
|
|
305
306
|
renderer,
|
|
307
|
+
offX = 0,
|
|
308
|
+
offY = 0,
|
|
306
309
|
w, h, dimensions,
|
|
307
310
|
bbox, attr, axattr, axattr_x, axattr_y,
|
|
308
311
|
board;
|
|
@@ -338,15 +341,19 @@ define([
|
|
|
338
341
|
|
|
339
342
|
if (Math.abs(unitX) < Math.abs(unitY)) {
|
|
340
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;
|
|
341
346
|
} else {
|
|
342
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;
|
|
343
350
|
}
|
|
344
351
|
} else {
|
|
345
352
|
unitX = w / (bbox[2] - bbox[0]);
|
|
346
353
|
unitY = h / (bbox[1] - bbox[3]);
|
|
347
354
|
}
|
|
348
|
-
originX = -unitX * bbox[0];
|
|
349
|
-
originY = unitY * bbox[1];
|
|
355
|
+
originX = -unitX * (bbox[0] - offX);
|
|
356
|
+
originY = unitY * (bbox[1] + offY);
|
|
350
357
|
}
|
|
351
358
|
|
|
352
359
|
renderer = this.initRenderer(box, dimensions, attr.document, attr.renderer);
|
|
@@ -541,8 +548,9 @@ define([
|
|
|
541
548
|
if (Env.isBrowser && typeof window === 'object' && typeof document === 'object') {
|
|
542
549
|
Env.addEvent(window, 'load', function () {
|
|
543
550
|
var type, i, j, div,
|
|
544
|
-
id, board,
|
|
545
|
-
|
|
551
|
+
id, board, txt,
|
|
552
|
+
width, height, maxWidth, aspectRatio, cssClasses,
|
|
553
|
+
bbox, axis, grid, code,
|
|
546
554
|
src, request, postpone = false,
|
|
547
555
|
scripts = document.getElementsByTagName('script'),
|
|
548
556
|
init = function (code, type, bbox) {
|
|
@@ -576,8 +584,11 @@ define([
|
|
|
576
584
|
if (Type.exists(type) &&
|
|
577
585
|
(type.toLowerCase() === 'text/jessiescript' || type.toLowerCase() === 'jessiescript' ||
|
|
578
586
|
type.toLowerCase() === 'text/jessiecode' || type.toLowerCase() === 'jessiecode')) {
|
|
579
|
-
|
|
580
|
-
|
|
587
|
+
cssClasses = scripts[i].getAttribute('class', false) || '';
|
|
588
|
+
width = scripts[i].getAttribute('width', false) || '';
|
|
589
|
+
height = scripts[i].getAttribute('height', false) || '';
|
|
590
|
+
maxWidth = scripts[i].getAttribute('maxwidth', false) || '100%';
|
|
591
|
+
aspectRatio = scripts[i].getAttribute('aspectratio', false) || '1/1';
|
|
581
592
|
bbox = scripts[i].getAttribute('boundingbox', false) || '-5, 5, 5, -5';
|
|
582
593
|
id = scripts[i].getAttribute('container', false);
|
|
583
594
|
src = scripts[i].getAttribute('src', false);
|
|
@@ -597,8 +608,14 @@ define([
|
|
|
597
608
|
id = 'jessiescript_autgen_jxg_' + i;
|
|
598
609
|
div = document.createElement('div');
|
|
599
610
|
div.setAttribute('id', id);
|
|
600
|
-
|
|
601
|
-
|
|
611
|
+
|
|
612
|
+
txt = (width !== '') ? ('width:' + width + ';') : '';
|
|
613
|
+
txt += (height !== '') ? ('height:' + height + ';') : '';
|
|
614
|
+
txt += (maxWidth !== '') ? ('max-width:' + maxWidth + ';') : '';
|
|
615
|
+
txt += (aspectRatio !== '') ? ('aspect-ratio:' + aspectRatio + ';') : '';
|
|
616
|
+
|
|
617
|
+
div.setAttribute('style', txt);
|
|
618
|
+
div.setAttribute('class', 'jxgbox ' + cssClasses);
|
|
602
619
|
try {
|
|
603
620
|
document.body.insertBefore(div, scripts[i]);
|
|
604
621
|
} catch (e) {
|
|
@@ -618,6 +635,7 @@ define([
|
|
|
618
635
|
request = new XMLHttpRequest();
|
|
619
636
|
request.open("GET", src);
|
|
620
637
|
request.overrideMimeType("text/plain; charset=x-user-defined");
|
|
638
|
+
/* jshint ignore:start */
|
|
621
639
|
request.addEventListener("load", function() {
|
|
622
640
|
if (this.status < 400) {
|
|
623
641
|
code = this.responseText + '\n' + code;
|
|
@@ -630,6 +648,7 @@ define([
|
|
|
630
648
|
request.addEventListener("error", function(e) {
|
|
631
649
|
throw new Error("\nJSXGraph: failed to load file", src, ":", e);
|
|
632
650
|
});
|
|
651
|
+
/* jshint ignore:end */
|
|
633
652
|
request.send();
|
|
634
653
|
} else {
|
|
635
654
|
postpone = false;
|
package/src/jxg.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,
|
|
@@ -53,6 +53,7 @@ define([], function () {
|
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* JXG is the top object of JSXGraph and defines the namespace
|
|
56
|
+
* @exports jxg as JXG
|
|
56
57
|
*/
|
|
57
58
|
var jxg = {};
|
|
58
59
|
|
|
@@ -130,9 +131,9 @@ define([], function () {
|
|
|
130
131
|
onlyOwn = onlyOwn || false;
|
|
131
132
|
toUpper = toUpper || false;
|
|
132
133
|
|
|
133
|
-
//
|
|
134
|
+
// The purpose of this for...in loop is indeed to use hasOwnProperty only if the caller explicitly wishes so.
|
|
134
135
|
for (e in constants) {
|
|
135
|
-
if (!onlyOwn || (onlyOwn &&
|
|
136
|
+
if (!onlyOwn || (onlyOwn && constants.hasOwnProperty(e))) {
|
|
136
137
|
if (toUpper) {
|
|
137
138
|
e2 = e.toUpperCase();
|
|
138
139
|
} else {
|
package/src/loadjsxgraph.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,
|
|
@@ -307,7 +307,7 @@ var JXG = {},
|
|
|
307
307
|
////////////////////////////////////////////////////////////////////////////////
|
|
308
308
|
|
|
309
309
|
// Has to be a String for Makefile!
|
|
310
|
-
JXG.Load.baseFiles = 'jxg,base/constants,utils/type,utils/xml,utils/env,utils/event,utils/expect,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,
|
|
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';
|
|
311
311
|
JXG.Load.setRequirePathToScriptFile('loadjsxgraph.js');
|
|
312
312
|
JXG.Load.JSfiles(JXG.Load.baseFiles.split(','), preventCachingFiles);
|
|
313
313
|
JXG.Load.baseFiles = null;
|
|
@@ -353,6 +353,7 @@ var JXG = {},
|
|
|
353
353
|
'element/checkbox': checkJXG,
|
|
354
354
|
'element/input': checkJXG,
|
|
355
355
|
'element/button': checkJXG,
|
|
356
|
+
'element/foreignobject': checkJXG,
|
|
356
357
|
|
|
357
358
|
'math/bst': makeCheck('Math.BST'),
|
|
358
359
|
'math/qdt': makeCheck('Math.Quadtree'),
|
package/src/math/bst.js
CHANGED