jsxgraph 1.4.2 → 1.4.5
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 +24 -0
- package/distrib/README.md +24 -0
- package/distrib/geogebra.min.js +1 -1
- package/distrib/geonext.min.js +1 -1
- package/distrib/index.d.ts +351 -39
- package/distrib/intergeo.min.js +1 -1
- package/distrib/jsxgraphcore.js +4 -4
- package/distrib/jsxgraphsrc.js +2909 -389
- package/distrib/sketch.min.js +2 -2
- package/package.json +1 -1
- package/src/3d/box3d.js +268 -0
- package/src/3d/curve3d.js +97 -0
- package/src/3d/linspace3d.js +375 -0
- package/src/3d/point3d.js +238 -0
- package/src/3d/surface3d.js +220 -0
- package/src/3d/threed.js +38 -0
- package/src/3d/view3d.js +529 -0
- package/src/base/board.js +160 -84
- package/src/base/constants.js +1 -1
- package/src/base/coordselement.js +1 -4
- package/src/base/element.js +22 -13
- package/src/base/foreignobject.js +7 -1
- package/src/base/line.js +1 -1
- package/src/base/polygon.js +88 -33
- package/src/base/text.js +42 -13
- package/src/base/ticks.js +3 -1
- package/src/element/composition.js +62 -23
- package/src/element/slider.js +12 -0
- package/src/jsxgraph.js +8 -5
- package/src/loadjsxgraph.js +17 -11
- package/src/math/clip.js +0 -1
- package/src/math/geometry.js +187 -2
- package/src/math/math.js +9 -0
- package/src/math/nlp.js +205 -173
- package/src/options.js +35 -13
- package/src/options3d.js +265 -0
- package/src/parser/jessiecode.js +1 -1
- package/src/reader/sketch.js +2 -2
- package/src/renderer/svg.js +7 -4
- package/src/utils/env.js +10 -10
- package/src/utils/type.js +2 -2
package/src/base/polygon.js
CHANGED
|
@@ -559,8 +559,35 @@ define([
|
|
|
559
559
|
|
|
560
560
|
/**
|
|
561
561
|
* Add more points to the polygon. The new points will be inserted at the end.
|
|
562
|
-
*
|
|
562
|
+
* The attributes of new border segments are set to the same values
|
|
563
|
+
* as those used when the polygon was created.
|
|
564
|
+
* If new vertices are supplied by coordinates, the default attributes of polygon
|
|
565
|
+
* vertices are taken as their attributes. Therefore, the visual attributes of
|
|
566
|
+
* new vertices and borders may have to be adapted afterwards.
|
|
567
|
+
* @param {JXG.Point} p Arbitrary number of points or coordinate arrays
|
|
563
568
|
* @returns {JXG.Polygon} Reference to the polygon
|
|
569
|
+
* @example
|
|
570
|
+
* const board = JXG.JSXGraph.initBoard('jxgbox', {axis:true});
|
|
571
|
+
* var pg = board.create('polygon', [[1,2], [3,4], [-3,1]], {hasInnerPoints: true});
|
|
572
|
+
* var newPoint = board.create('point', [-1, -1]);
|
|
573
|
+
* var newPoint2 = board.create('point', [-1, -2]);
|
|
574
|
+
* pg.addPoints(newPoint, newPoint2, [1, -2]);
|
|
575
|
+
*
|
|
576
|
+
* </pre><div id="JXG70eb0fd2-d20f-4ba9-9ab6-0eac92aabfa5" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
577
|
+
* <script type="text/javascript">
|
|
578
|
+
* (function() {
|
|
579
|
+
* var board = JXG.JSXGraph.initBoard('JXG70eb0fd2-d20f-4ba9-9ab6-0eac92aabfa5',
|
|
580
|
+
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
581
|
+
* const board = JXG.JSXGraph.initBoard('jxgbox', {axis:true});
|
|
582
|
+
* var pg = board.create('polygon', [[1,2], [3,4], [-3,1]], {hasInnerPoints: true});
|
|
583
|
+
* var newPoint = board.create('point', [-1, -1]);
|
|
584
|
+
* var newPoint2 = board.create('point', [-1, -2]);
|
|
585
|
+
* pg.addPoints(newPoint, newPoint2, [1, -2]);
|
|
586
|
+
*
|
|
587
|
+
* })();
|
|
588
|
+
*
|
|
589
|
+
* </script><pre>
|
|
590
|
+
*
|
|
564
591
|
*/
|
|
565
592
|
addPoints: function (p) {
|
|
566
593
|
var args = Array.prototype.slice.call(arguments);
|
|
@@ -569,44 +596,72 @@ define([
|
|
|
569
596
|
},
|
|
570
597
|
|
|
571
598
|
/**
|
|
572
|
-
*
|
|
573
|
-
*
|
|
574
|
-
*
|
|
599
|
+
* Insert points to the vertex list of the polygon after index <tt><idx</tt>.
|
|
600
|
+
* The attributes of new border segments are set to the same values
|
|
601
|
+
* as those used when the polygon was created.
|
|
602
|
+
* If new vertices are supplied by coordinates, the default attributes of polygon
|
|
603
|
+
* vertices are taken as their attributes. Therefore, the visual attributes of
|
|
604
|
+
* new vertices and borders may have to be adapted afterwards.
|
|
605
|
+
*
|
|
606
|
+
* @param {Number} idx The position after which the new vertices are inserted.
|
|
607
|
+
* Setting idx to -1 inserts the new points at the front, i.e. at position 0.
|
|
608
|
+
* @param {JXG.Point} p Arbitrary number of points or coordinate arrays to insert.
|
|
575
609
|
* @returns {JXG.Polygon} Reference to the polygon object
|
|
610
|
+
*
|
|
611
|
+
* @example
|
|
612
|
+
* const board = JXG.JSXGraph.initBoard('jxgbox', {axis:true});
|
|
613
|
+
* var pg = board.create('polygon', [[1,2], [3,4], [-3,1]], {hasInnerPoints: true});
|
|
614
|
+
* var newPoint = board.create('point', [-1, -1]);
|
|
615
|
+
* pg.insertPoints(0, newPoint, newPoint, [1, -2]);
|
|
616
|
+
*
|
|
617
|
+
* </pre><div id="JXG17b84b2a-a851-4e3f-824f-7f6a60f166ca" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
618
|
+
* <script type="text/javascript">
|
|
619
|
+
* (function() {
|
|
620
|
+
* var board = JXG.JSXGraph.initBoard('JXG17b84b2a-a851-4e3f-824f-7f6a60f166ca',
|
|
621
|
+
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
622
|
+
* const board = JXG.JSXGraph.initBoard('jxgbox', {axis:true});
|
|
623
|
+
* var pg = board.create('polygon', [[1,2], [3,4], [-3,1]], {hasInnerPoints: true});
|
|
624
|
+
* var newPoint = board.create('point', [-1, -1]);
|
|
625
|
+
* pg.insertPoints(0, newPoint, newPoint, [1, -2]);
|
|
626
|
+
*
|
|
627
|
+
* })();
|
|
628
|
+
*
|
|
629
|
+
* </script><pre>
|
|
630
|
+
*
|
|
576
631
|
*/
|
|
577
632
|
insertPoints: function (idx, p) {
|
|
578
|
-
var i,
|
|
633
|
+
var i, le;
|
|
579
634
|
|
|
580
635
|
if (arguments.length === 0) {
|
|
581
636
|
return this;
|
|
582
637
|
}
|
|
583
638
|
|
|
584
639
|
|
|
585
|
-
if (idx <
|
|
640
|
+
if (idx < -1 || idx > this.vertices.length - 2) {
|
|
586
641
|
return this;
|
|
587
642
|
}
|
|
588
643
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
644
|
+
le = arguments.length - 1;
|
|
645
|
+
for (i = 1; i < le + 1; i++) {
|
|
646
|
+
this.vertices.splice(idx + i, 0,
|
|
647
|
+
Type.providePoints(this.board, [arguments[i]], {}, 'polygon', ['vertices'])[0]
|
|
648
|
+
);
|
|
649
|
+
}
|
|
650
|
+
if (idx === -1) {
|
|
651
|
+
this.vertices[this.vertices.length - 1] = this.vertices[0];
|
|
593
652
|
}
|
|
594
|
-
|
|
595
|
-
tmp = this.vertices.slice(0, idx + 1).concat(npoints);
|
|
596
|
-
this.vertices = tmp.concat(this.vertices.slice(idx + 1));
|
|
597
|
-
|
|
598
653
|
if (this.withLines) {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
654
|
+
if (idx < 0) {
|
|
655
|
+
this.borders[this.borders.length - 1].point2 = this.vertices[this.vertices.length - 1];
|
|
656
|
+
} else {
|
|
657
|
+
this.borders[idx].point2 = this.vertices[idx + 1];
|
|
658
|
+
}
|
|
659
|
+
for (i = idx + 1; i < idx + 1 + le; i++) {
|
|
660
|
+
this.borders.splice(i, 0,
|
|
661
|
+
this.board.create('segment', [this.vertices[i], this.vertices[i + 1]], this.attr_line)
|
|
662
|
+
);
|
|
604
663
|
}
|
|
605
|
-
|
|
606
|
-
tmp.push(this.board.create('segment', [this.vertices[idx + npoints.length], this.vertices[idx + npoints.length + 1]], this.attr_line));
|
|
607
|
-
this.borders = tmp.concat(this.borders.slice(idx + 1));
|
|
608
664
|
}
|
|
609
|
-
|
|
610
665
|
this.board.update();
|
|
611
666
|
|
|
612
667
|
return this;
|
|
@@ -621,7 +676,7 @@ define([
|
|
|
621
676
|
var i, j, idx, nvertices = [], nborders = [],
|
|
622
677
|
nidx = [], partition = [];
|
|
623
678
|
|
|
624
|
-
//
|
|
679
|
+
// Partition:
|
|
625
680
|
// in order to keep the borders which could be recycled, we have to partition
|
|
626
681
|
// the set of removed points. I.e. if the points 1, 2, 5, 6, 7, 10 are removed,
|
|
627
682
|
// the partitions are
|
|
@@ -629,10 +684,10 @@ define([
|
|
|
629
684
|
// this gives us the borders, that can be removed and the borders we have to create.
|
|
630
685
|
|
|
631
686
|
|
|
632
|
-
//
|
|
687
|
+
// Remove the last vertex which is identical to the first
|
|
633
688
|
this.vertices = this.vertices.slice(0, this.vertices.length - 1);
|
|
634
689
|
|
|
635
|
-
//
|
|
690
|
+
// Collect all valid parameters as indices in nidx
|
|
636
691
|
for (i = 0; i < arguments.length; i++) {
|
|
637
692
|
idx = arguments[i];
|
|
638
693
|
if (Type.isPoint(idx)) {
|
|
@@ -644,22 +699,22 @@ define([
|
|
|
644
699
|
}
|
|
645
700
|
}
|
|
646
701
|
|
|
647
|
-
//
|
|
702
|
+
// Remove the polygon from each removed point's children
|
|
648
703
|
for (i = 0; i < nidx.length; i++) {
|
|
649
704
|
this.vertices[nidx[i]].removeChild(this);
|
|
650
705
|
}
|
|
651
706
|
|
|
652
|
-
//
|
|
707
|
+
// Sort the elements to be eliminated
|
|
653
708
|
nidx = nidx.sort();
|
|
654
709
|
nvertices = this.vertices.slice();
|
|
655
710
|
nborders = this.borders.slice();
|
|
656
711
|
|
|
657
|
-
//
|
|
712
|
+
// Initialize the partition
|
|
658
713
|
if (this.withLines) {
|
|
659
714
|
partition.push([nidx[nidx.length - 1]]);
|
|
660
715
|
}
|
|
661
716
|
|
|
662
|
-
//
|
|
717
|
+
// Run through all existing vertices and copy all remaining ones to nvertices,
|
|
663
718
|
// compute the partition
|
|
664
719
|
for (i = nidx.length - 1; i > -1; i--) {
|
|
665
720
|
nvertices[nidx[i]] = -1;
|
|
@@ -670,12 +725,12 @@ define([
|
|
|
670
725
|
}
|
|
671
726
|
}
|
|
672
727
|
|
|
673
|
-
//
|
|
728
|
+
// Finalize the partition computation
|
|
674
729
|
if (this.withLines) {
|
|
675
730
|
partition[partition.length - 1][1] = nidx[0];
|
|
676
731
|
}
|
|
677
732
|
|
|
678
|
-
//
|
|
733
|
+
// Update vertices
|
|
679
734
|
this.vertices = [];
|
|
680
735
|
for (i = 0; i < nvertices.length; i++) {
|
|
681
736
|
if (Type.isPoint(nvertices[i])) {
|
|
@@ -686,7 +741,7 @@ define([
|
|
|
686
741
|
this.vertices.push(this.vertices[0]);
|
|
687
742
|
}
|
|
688
743
|
|
|
689
|
-
//
|
|
744
|
+
// Delete obsolete and create missing borders
|
|
690
745
|
if (this.withLines) {
|
|
691
746
|
for (i = 0; i < partition.length; i++) {
|
|
692
747
|
for (j = partition[i][1] - 1; j < partition[i][0] + 1; j++) {
|
package/src/base/text.js
CHANGED
|
@@ -200,6 +200,7 @@ define([
|
|
|
200
200
|
|
|
201
201
|
this.orgText = text;
|
|
202
202
|
if (Type.isFunction(text)) {
|
|
203
|
+
// <value> tags will not be evaluated.
|
|
203
204
|
this.updateText = function () {
|
|
204
205
|
resolvedText = text().toString();
|
|
205
206
|
if (ev_p && !ev_um && !ev_uk) {
|
|
@@ -220,14 +221,20 @@ define([
|
|
|
220
221
|
// Convert via ASCIIMathML
|
|
221
222
|
this.content = "'`" + text + "`'";
|
|
222
223
|
} else if (ev_um || ev_uk) {
|
|
223
|
-
|
|
224
|
+
if (ev_p) {
|
|
225
|
+
this.content = this.generateTerm(text, true, true, true); // Replace value-tags
|
|
226
|
+
this.content = this.content.replace(/\\/g, "\\\\");
|
|
227
|
+
} else {
|
|
228
|
+
this.content = "'" + text + "'";
|
|
229
|
+
}
|
|
224
230
|
} else {
|
|
225
231
|
// Converts GEONExT syntax into JavaScript string
|
|
226
232
|
// Short math is allowed
|
|
227
233
|
// Avoid geonext2JS calls
|
|
228
|
-
this.content = this.generateTerm(text, true, true);
|
|
234
|
+
this.content = this.generateTerm(text, true, true, false);
|
|
229
235
|
}
|
|
230
236
|
}
|
|
237
|
+
// Convert JessieCode to JS function
|
|
231
238
|
updateText = this.board.jc.snippet(this.content, true, '', false);
|
|
232
239
|
this.updateText = function () {
|
|
233
240
|
this.plaintext = updateText();
|
|
@@ -583,30 +590,43 @@ define([
|
|
|
583
590
|
/**
|
|
584
591
|
* Converts the GEONExT syntax of the <value> terms into JavaScript.
|
|
585
592
|
* Also, all Objects whose name appears in the term are searched and
|
|
586
|
-
* the text is added as child to these objects.
|
|
593
|
+
* the text is added as child to these objects.
|
|
594
|
+
* This method is called if the attribute parse==true is set.
|
|
587
595
|
*
|
|
588
596
|
* @param{String} contentStr String to be parsed
|
|
589
597
|
* @param{Boolean} [expand] Optional flag if shortened math syntax is allowed (e.g. 3x instead of 3*x).
|
|
590
598
|
* @param{Boolean} [avoidGeonext2JS] Optional flag if geonext2JS should be called. For backwards compatibility
|
|
591
599
|
* this has to be set explicitely to true.
|
|
600
|
+
* @param{Boolean} [outputTeX] Optional flag which has to be true if the resulting term will be sent to MathJax or KaTeX.
|
|
601
|
+
* If true, "_" and "^" are NOT replaced by HTML tags sub and sup. Default: false, i.e. the replacement is done.
|
|
602
|
+
* This flag allows the combination of <value> tag containing calculations with TeX output.
|
|
603
|
+
*
|
|
592
604
|
* @private
|
|
593
605
|
* @see JXG.GeonextParser.geonext2JS
|
|
594
606
|
*/
|
|
595
|
-
generateTerm: function (contentStr, expand, avoidGeonext2JS) {
|
|
607
|
+
generateTerm: function (contentStr, expand, avoidGeonext2JS, outputTeX) {
|
|
596
608
|
var res, term, i, j,
|
|
597
609
|
plaintext = '""';
|
|
598
610
|
|
|
599
|
-
|
|
611
|
+
outputTeX = outputTeX || false;
|
|
612
|
+
|
|
613
|
+
// Revert possible jc replacement
|
|
600
614
|
contentStr = contentStr || '';
|
|
601
615
|
contentStr = contentStr.replace(/\r/g, '');
|
|
602
616
|
contentStr = contentStr.replace(/\n/g, '');
|
|
603
617
|
contentStr = contentStr.replace(/"/g, '\'');
|
|
604
618
|
contentStr = contentStr.replace(/'/g, "\\'");
|
|
605
619
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
620
|
+
if (!outputTeX) {
|
|
621
|
+
// Old GEONExT syntax, not (yet) supported as TeX output.
|
|
622
|
+
// Otherwise, the else clause should be used.
|
|
623
|
+
// That means, i.e. the <arc> tag and <sqrt> tag are not
|
|
624
|
+
// converted into TeX syntax.
|
|
625
|
+
contentStr = contentStr.replace(/&arc;/g, '∠');
|
|
626
|
+
contentStr = contentStr.replace(/<arc\s*\/>/g, '∠');
|
|
627
|
+
contentStr = contentStr.replace(/<arc\s*\/>/g, '∠');
|
|
628
|
+
contentStr = contentStr.replace(/<sqrt\s*\/>/g, '√');
|
|
629
|
+
}
|
|
610
630
|
|
|
611
631
|
contentStr = contentStr.replace(/<value>/g, '<value>');
|
|
612
632
|
contentStr = contentStr.replace(/<\/value>/g, '</value>');
|
|
@@ -616,7 +636,12 @@ define([
|
|
|
616
636
|
j = contentStr.indexOf('</value>');
|
|
617
637
|
if (i >= 0) {
|
|
618
638
|
while (i >= 0) {
|
|
619
|
-
|
|
639
|
+
if (!outputTeX) {
|
|
640
|
+
plaintext += ' + "' + this.replaceSub(this.replaceSup(contentStr.slice(0, i))) + '"';
|
|
641
|
+
// plaintext += ' + "' + this.replaceSub(contentStr.slice(0, i)) + '"';
|
|
642
|
+
} else {
|
|
643
|
+
plaintext += ' + "' + contentStr.slice(0, i) + '"';
|
|
644
|
+
}
|
|
620
645
|
term = contentStr.slice(i + 7, j);
|
|
621
646
|
term = term.replace(/\s+/g, ''); // Remove all whitespace
|
|
622
647
|
if (expand === true) {
|
|
@@ -649,10 +674,14 @@ define([
|
|
|
649
674
|
}
|
|
650
675
|
}
|
|
651
676
|
|
|
652
|
-
|
|
653
|
-
|
|
677
|
+
if (!outputTeX) {
|
|
678
|
+
plaintext += ' + "' + this.replaceSub(this.replaceSup(contentStr)) + '"';
|
|
679
|
+
plaintext = this.convertGeonextAndSketchometry2CSS(plaintext);
|
|
680
|
+
} else {
|
|
681
|
+
plaintext += ' + "' + contentStr + '"';
|
|
682
|
+
}
|
|
654
683
|
|
|
655
|
-
// This should replace &pi; by π
|
|
684
|
+
// This should replace e.g. &pi; by π
|
|
656
685
|
plaintext = plaintext.replace(/&/g, '&');
|
|
657
686
|
plaintext = plaintext.replace(/"/g, "'");
|
|
658
687
|
|
package/src/base/ticks.js
CHANGED
|
@@ -1022,7 +1022,7 @@ define([
|
|
|
1022
1022
|
|
|
1023
1023
|
// if value is Number
|
|
1024
1024
|
if (Type.isNumber(value)) {
|
|
1025
|
-
labelText = (Math.round(value * 1.
|
|
1025
|
+
labelText = (Math.round(value * 1.e11) / 1.e11).toString();
|
|
1026
1026
|
if (labelText.length > Type.evaluate(this.visProp.maxlabellength) ||
|
|
1027
1027
|
labelText.indexOf('e') !== -1) {
|
|
1028
1028
|
|
|
@@ -1267,6 +1267,8 @@ define([
|
|
|
1267
1267
|
attr.id = this.id + ld.i + 'Label' + this.labelCounter;
|
|
1268
1268
|
|
|
1269
1269
|
label = Text.createText(this.board, [ld.x, ld.y, ld.t], attr);
|
|
1270
|
+
this.addChild(label);
|
|
1271
|
+
label.setParents(this);
|
|
1270
1272
|
label.isDraggable = false;
|
|
1271
1273
|
label.dump = false;
|
|
1272
1274
|
this.labels.push(label);
|
|
@@ -592,9 +592,6 @@ define([
|
|
|
592
592
|
b.addChild(t);
|
|
593
593
|
}
|
|
594
594
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
595
|
t.elType = 'midpoint';
|
|
599
596
|
t.setParents([a.id, b.id]);
|
|
600
597
|
|
|
@@ -804,14 +801,21 @@ define([
|
|
|
804
801
|
};
|
|
805
802
|
|
|
806
803
|
/**
|
|
807
|
-
* @class A parallel is a line through a given point with the same slope as a given line
|
|
804
|
+
* @class A parallel is a line through a given point with the same slope as a given line or
|
|
805
|
+
* the line through two given point.
|
|
806
|
+
* <p>
|
|
807
|
+
* If original line is given as a JSXGraph line object, the resulting parallel line will be defined by the given point and an
|
|
808
|
+
* infinitely far away point (an ideal point). That means, the line can not be shortened to a segment.
|
|
809
|
+
* <p>
|
|
810
|
+
* If the original line is given as two points, the resulting parallel line can be shortened to a a segment.
|
|
808
811
|
* @pseudo
|
|
809
812
|
* @name Parallel
|
|
810
813
|
* @augments Line
|
|
811
814
|
* @constructor
|
|
812
815
|
* @type JXG.Line
|
|
813
816
|
* @throws {Error} If the element cannot be constructed with the given parent objects an exception is thrown.
|
|
814
|
-
* @param {JXG.Line_JXG.Point} l,p The constructed line contains p and has the same slope as l.
|
|
817
|
+
* @param {JXG.Line_JXG.Point} l,p The constructed line contains p and has the same slope as l. Alternative parameters are p1, p2, p: The
|
|
818
|
+
* constructed line contains p and has the same slope as the line through p1 and p2.
|
|
815
819
|
* @example
|
|
816
820
|
* // Create a parallel
|
|
817
821
|
* var p1 = board.create('point', [0.0, 2.0]);
|
|
@@ -829,22 +833,47 @@ define([
|
|
|
829
833
|
* var plex1_p3 = plex1_board.create('point', [3.0, 3.0]);
|
|
830
834
|
* var plex1_pl1 = plex1_board.create('parallel', [plex1_l1, plex1_p3]);
|
|
831
835
|
* </script><pre>
|
|
836
|
+
* @example
|
|
837
|
+
* var p1, p2, p3, l1, pl1;
|
|
838
|
+
*
|
|
839
|
+
* p1 = board.create('point', [0.0, 2.0]);
|
|
840
|
+
* p2 = board.create('point', [2.0, 1.0]);
|
|
841
|
+
* l1 = board.create('line', [p1, p2]);
|
|
842
|
+
*
|
|
843
|
+
* p3 = board.create('point', [1.0, 3.0]);
|
|
844
|
+
* pl1 = board.create('parallel', [p1, p2, p3], {straightFirst: false, straightLast: false});
|
|
845
|
+
*
|
|
846
|
+
* </pre><div id="JXGd643305d-20c3-4a88-91f9-8d0c4448594f" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
847
|
+
* <script type="text/javascript">
|
|
848
|
+
* (function() {
|
|
849
|
+
* var board = JXG.JSXGraph.initBoard('JXGd643305d-20c3-4a88-91f9-8d0c4448594f',
|
|
850
|
+
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
851
|
+
* var p1, p2, p3, l1, pl1;
|
|
852
|
+
*
|
|
853
|
+
* p1 = board.create('point', [0.0, 2.0]);
|
|
854
|
+
* p2 = board.create('point', [2.0, 1.0]);
|
|
855
|
+
* l1 = board.create('line', [p1, p2]);
|
|
856
|
+
*
|
|
857
|
+
* p3 = board.create('point', [1.0, 3.0]);
|
|
858
|
+
* pl1 = board.create('parallel', [p1, p2, p3], {straightFirst: false, straightLast: false});
|
|
859
|
+
*
|
|
860
|
+
* })();
|
|
861
|
+
*
|
|
862
|
+
* </script><pre>
|
|
863
|
+
*
|
|
832
864
|
*/
|
|
833
865
|
JXG.createParallel = function (board, parents, attributes) {
|
|
834
|
-
var p, pp, pl, li, i, attr;
|
|
866
|
+
var p, pp, pl, li, i, attr, ty = 1;
|
|
835
867
|
|
|
836
868
|
for (i = 0; i < parents.length; ++i) {
|
|
837
869
|
parents[i] = board.select(parents[i]);
|
|
838
870
|
}
|
|
839
871
|
p = null;
|
|
840
872
|
if (parents.length === 3) {
|
|
873
|
+
// Line / segment through point parents[2] which is parallel to line through parents[0] and parents[1]
|
|
841
874
|
parents = Type.providePoints(board, parents, attributes, 'point');
|
|
842
|
-
// line through point parents[2] which is parallel to line through parents[0] and parents[1]
|
|
843
875
|
p = parents[2];
|
|
844
|
-
|
|
845
|
-
li = function () {
|
|
846
|
-
return Mat.crossProduct(parents[0].coords.usrCoords, parents[1].coords.usrCoords);
|
|
847
|
-
};
|
|
876
|
+
ty = 0;
|
|
848
877
|
} else if (Type.isPointType(board, parents[0])) {
|
|
849
878
|
// Parallel to line parents[1] through point parents[0]
|
|
850
879
|
p = Type.providePoints(board, [parents[0]], attributes, 'point')[0];
|
|
@@ -866,11 +895,19 @@ define([
|
|
|
866
895
|
}
|
|
867
896
|
|
|
868
897
|
attr = Type.copyAttributes(attributes, board.options, 'parallel', 'point');
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
898
|
+
if (ty === 1) {
|
|
899
|
+
// Line is given by line element. The parallel line is
|
|
900
|
+
// constructed as line through an ideal point.
|
|
901
|
+
pp = board.create('point', [
|
|
902
|
+
function () {
|
|
903
|
+
return Mat.crossProduct([1, 0, 0], li());
|
|
904
|
+
}
|
|
905
|
+
], attr);
|
|
906
|
+
} else {
|
|
907
|
+
// Line is given by two points. The parallel line is
|
|
908
|
+
// constructed as line through two finite point.
|
|
909
|
+
pp = board.create('parallelpoint', parents, attr);
|
|
910
|
+
}
|
|
874
911
|
pp.isDraggable = true;
|
|
875
912
|
|
|
876
913
|
attr = Type.copyAttributes(attributes, board.options, 'parallel');
|
|
@@ -904,31 +941,33 @@ define([
|
|
|
904
941
|
};
|
|
905
942
|
|
|
906
943
|
/**
|
|
907
|
-
* @class An arrow parallel is a
|
|
944
|
+
* @class An arrow parallel is a segment with an arrow attached which is parallel through a given segment, given by its defining two points,
|
|
945
|
+
* through a given point.
|
|
946
|
+
* <p>
|
|
908
947
|
* @pseudo
|
|
909
948
|
* @constructor
|
|
910
949
|
* @name Arrowparallel
|
|
911
950
|
* @type Parallel
|
|
912
951
|
* @augments Parallel
|
|
913
952
|
* @throws {Error} If the element cannot be constructed with the given parent objects an exception is thrown.
|
|
914
|
-
* @param
|
|
953
|
+
* @param JXG.Point_JXG.Point_JXG.Point} p1, p2,p3 The constructed arrow contains p3 and has the same slope as the line through p1 and p2.
|
|
915
954
|
* @example
|
|
916
955
|
* // Create a parallel
|
|
917
956
|
* var p1 = board.create('point', [0.0, 2.0]);
|
|
918
957
|
* var p2 = board.create('point', [2.0, 1.0]);
|
|
919
|
-
* var l1 = board.create('
|
|
958
|
+
* var l1 = board.create('segment', [p1, p2]);
|
|
920
959
|
*
|
|
921
960
|
* var p3 = board.create('point', [3.0, 3.0]);
|
|
922
|
-
* var pl1 = board.create('arrowparallel', [
|
|
961
|
+
* var pl1 = board.create('arrowparallel', [p1, p2, p3]);
|
|
923
962
|
* </pre><div class="jxgbox" id="JXGeeacdf99-036f-4e83-aeb6-f7388423e369" style="width: 400px; height: 400px;"></div>
|
|
924
963
|
* <script type="text/javascript">
|
|
925
964
|
* (function () {
|
|
926
965
|
* var plex1_board = JXG.JSXGraph.initBoard('JXGeeacdf99-036f-4e83-aeb6-f7388423e369', {boundingbox: [-1, 9, 9, -1], axis: true, showcopyright: false, shownavigation: false});
|
|
927
966
|
* var plex1_p1 = plex1_board.create('point', [0.0, 2.0]);
|
|
928
967
|
* var plex1_p2 = plex1_board.create('point', [2.0, 1.0]);
|
|
929
|
-
* var plex1_l1 = plex1_board.create('
|
|
968
|
+
* var plex1_l1 = plex1_board.create('segment', [plex1_p1, plex1_p2]);
|
|
930
969
|
* var plex1_p3 = plex1_board.create('point', [3.0, 3.0]);
|
|
931
|
-
* var plex1_pl1 = plex1_board.create('arrowparallel', [
|
|
970
|
+
* var plex1_pl1 = plex1_board.create('arrowparallel', [plex1_p1, plex1_p2, plex1_p3]);
|
|
932
971
|
* })();
|
|
933
972
|
* </script><pre>
|
|
934
973
|
*/
|
|
@@ -1375,7 +1414,7 @@ define([
|
|
|
1375
1414
|
};
|
|
1376
1415
|
|
|
1377
1416
|
/**
|
|
1378
|
-
* @class Bisector lines are similar to {@link Bisector} but
|
|
1417
|
+
* @class Bisector lines are similar to {@link Bisector} but take two lines as parent elements. The resulting element is
|
|
1379
1418
|
* a composition of two lines.
|
|
1380
1419
|
* @pseudo
|
|
1381
1420
|
* @constructor
|
package/src/element/slider.js
CHANGED
|
@@ -463,6 +463,10 @@ define([
|
|
|
463
463
|
p2.dump = false;
|
|
464
464
|
l1.dump = false;
|
|
465
465
|
l2.dump = false;
|
|
466
|
+
if (withText) {
|
|
467
|
+
t.dump = false;
|
|
468
|
+
}
|
|
469
|
+
|
|
466
470
|
|
|
467
471
|
p3.elType = 'slider';
|
|
468
472
|
p3.parents = parents;
|
|
@@ -480,6 +484,14 @@ define([
|
|
|
480
484
|
p3.inherits.push(ti);
|
|
481
485
|
}
|
|
482
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
|
+
|
|
483
495
|
p3.baseline.on('up', function(evt) {
|
|
484
496
|
var pos, c;
|
|
485
497
|
|
package/src/jsxgraph.js
CHANGED
|
@@ -228,6 +228,7 @@ define([
|
|
|
228
228
|
*/
|
|
229
229
|
_setARIA: function(container, attr) {
|
|
230
230
|
var doc = attr.document || document,
|
|
231
|
+
doc_glob,
|
|
231
232
|
node_jsx, newNode, parent,
|
|
232
233
|
id_label, id_description;
|
|
233
234
|
|
|
@@ -236,18 +237,19 @@ define([
|
|
|
236
237
|
}
|
|
237
238
|
|
|
238
239
|
node_jsx = doc.getElementById(container);
|
|
240
|
+
doc_glob = node_jsx.ownerDocument; // This is the window.document element, needed below.
|
|
239
241
|
parent = node_jsx.parentNode;
|
|
240
242
|
|
|
241
243
|
id_label = container + '_ARIAlabel';
|
|
242
244
|
id_description = container + '_ARIAdescription';
|
|
243
245
|
|
|
244
|
-
newNode =
|
|
246
|
+
newNode = doc_glob.createElement('div');
|
|
245
247
|
newNode.innerHTML = attr.title;
|
|
246
248
|
newNode.setAttribute('id', id_label);
|
|
247
249
|
newNode.style.display = 'none';
|
|
248
250
|
parent.insertBefore(newNode, node_jsx);
|
|
249
251
|
|
|
250
|
-
newNode =
|
|
252
|
+
newNode = doc_glob.createElement('div');
|
|
251
253
|
newNode.innerHTML = attr.description;
|
|
252
254
|
newNode.setAttribute('id', id_description);
|
|
253
255
|
newNode.style.display = 'none';
|
|
@@ -273,12 +275,12 @@ define([
|
|
|
273
275
|
}
|
|
274
276
|
|
|
275
277
|
id = board.containerObj.getAttribute('aria-labelledby');
|
|
276
|
-
node =
|
|
278
|
+
node = doc.getElementById(id);
|
|
277
279
|
if (node && node.parentNode) {
|
|
278
280
|
node.parentNode.removeChild(node);
|
|
279
281
|
}
|
|
280
282
|
id = board.containerObj.getAttribute('aria-describedby');
|
|
281
|
-
node =
|
|
283
|
+
node = doc.getElementById(id);
|
|
282
284
|
if (node && node.parentNode) {
|
|
283
285
|
node.parentNode.removeChild(node);
|
|
284
286
|
}
|
|
@@ -544,7 +546,8 @@ define([
|
|
|
544
546
|
}
|
|
545
547
|
};
|
|
546
548
|
|
|
547
|
-
// JessieScript/JessieCode startup:
|
|
549
|
+
// JessieScript/JessieCode startup:
|
|
550
|
+
// Search for script tags of type text/jessiescript and interprete them.
|
|
548
551
|
if (Env.isBrowser && typeof window === 'object' && typeof document === 'object') {
|
|
549
552
|
Env.addEvent(window, 'load', function () {
|
|
550
553
|
var type, i, j, div,
|
package/src/loadjsxgraph.js
CHANGED
|
@@ -55,10 +55,9 @@ var JXG = {},
|
|
|
55
55
|
//// ////
|
|
56
56
|
//// Attention! Slows down the loading time! ////
|
|
57
57
|
//////////////////////////////////////////////////////////////////////////
|
|
58
|
-
var preventCachingFiles = true
|
|
59
|
-
|
|
60
|
-
|
|
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
|
}());
|