jsxgraph 1.6.0 → 1.6.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/CHANGELOG.md +25 -2
- package/distrib/docs/files.html +2 -2
- package/distrib/docs/index.html +2 -2
- package/distrib/docs/static/jsxgraph.css +24 -22
- package/distrib/docs/static/jsxgraphcore.js +2 -2
- package/distrib/docs/symbols/Angle.html +2 -2
- package/distrib/docs/symbols/Arc.html +2 -2
- package/distrib/docs/symbols/Arrow.html +2 -2
- package/distrib/docs/symbols/Arrowparallel.html +2 -2
- package/distrib/docs/symbols/Axis.html +2 -2
- package/distrib/docs/symbols/Bisector.html +2 -2
- package/distrib/docs/symbols/Bisectorlines.html +2 -2
- package/distrib/docs/symbols/Boxplot.html +2 -2
- package/distrib/docs/symbols/Button.html +4 -4
- package/distrib/docs/symbols/Cardinalspline.html +2 -2
- package/distrib/docs/symbols/Chart.html +2 -2
- package/distrib/docs/symbols/Checkbox.html +17 -17
- package/distrib/docs/symbols/Circle.html +2 -2
- package/distrib/docs/symbols/Circumcenter.html +4 -4
- package/distrib/docs/symbols/Circumcircle.html +2 -2
- package/distrib/docs/symbols/CircumcircleArc.html +2 -2
- package/distrib/docs/symbols/CircumcircleSector.html +2 -2
- package/distrib/docs/symbols/Comb.html +5 -5
- package/distrib/docs/symbols/Conic.html +2 -2
- package/distrib/docs/symbols/Constants.html +2 -2
- package/distrib/docs/symbols/Curve.html +2 -2
- package/distrib/docs/symbols/Curve3D.html +2 -2
- package/distrib/docs/symbols/CurveDifference.html +2 -2
- package/distrib/docs/symbols/CurveIntersection.html +2 -2
- package/distrib/docs/symbols/CurveUnion.html +2 -2
- package/distrib/docs/symbols/Derivative.html +2 -2
- package/distrib/docs/symbols/Ellipse.html +2 -2
- package/distrib/docs/symbols/ForeignObject.html +4 -4
- package/distrib/docs/symbols/Functiongraph.html +2 -2
- package/distrib/docs/symbols/Functiongraph3D.html +2 -2
- package/distrib/docs/symbols/Glider.html +4 -4
- package/distrib/docs/symbols/Grid.html +2 -2
- package/distrib/docs/symbols/Group.html +2 -2
- package/distrib/docs/symbols/Hatch.html +2 -2
- package/distrib/docs/symbols/Hyperbola.html +2 -2
- package/distrib/docs/symbols/Image.html +4 -4
- package/distrib/docs/symbols/Incenter.html +4 -4
- package/distrib/docs/symbols/Incircle.html +2 -2
- package/distrib/docs/symbols/Inequality.html +2 -2
- package/distrib/docs/symbols/Input.html +4 -4
- package/distrib/docs/symbols/Integral.html +2 -2
- package/distrib/docs/symbols/Intersection.html +4 -4
- package/distrib/docs/symbols/JXG.AbstractRenderer.html +2 -2
- package/distrib/docs/symbols/JXG.Board.html +144 -11
- package/distrib/docs/symbols/JXG.Board.infobox.html +2 -2
- package/distrib/docs/symbols/JXG.C.html +2 -2
- package/distrib/docs/symbols/JXG.CA.html +2 -2
- package/distrib/docs/symbols/JXG.CanvasRenderer.html +2 -2
- package/distrib/docs/symbols/JXG.Chart.html +2 -2
- package/distrib/docs/symbols/JXG.Circle.html +2 -2
- package/distrib/docs/symbols/JXG.Complex.html +2 -2
- package/distrib/docs/symbols/JXG.Composition.html +2 -2
- package/distrib/docs/symbols/JXG.Coords.html +2 -2
- package/distrib/docs/symbols/JXG.CoordsElement.html +54 -2
- package/distrib/docs/symbols/JXG.Curve.html +2 -2
- package/distrib/docs/symbols/JXG.Curve3D.html +2 -2
- package/distrib/docs/symbols/JXG.Dump.html +2 -2
- package/distrib/docs/symbols/JXG.EventEmitter.html +2 -2
- package/distrib/docs/symbols/JXG.ForeignObject.html +3 -3
- package/distrib/docs/symbols/JXG.GeometryElement.html +2 -2
- package/distrib/docs/symbols/JXG.GeometryElement3D.html +2 -2
- package/distrib/docs/symbols/JXG.GeonextParser.html +2 -2
- package/distrib/docs/symbols/JXG.Group.html +2 -2
- package/distrib/docs/symbols/JXG.Image.html +3 -3
- package/distrib/docs/symbols/JXG.JSXGraph.html +2 -2
- package/distrib/docs/symbols/JXG.JessieCode.html +2 -2
- package/distrib/docs/symbols/JXG.Legend.html +2 -2
- package/distrib/docs/symbols/JXG.Line.html +2 -2
- package/distrib/docs/symbols/JXG.Line3D.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Clip.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Extrapolate.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Geometry.html +2 -2
- package/distrib/docs/symbols/JXG.Math.IntervalArithmetic.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Metapost.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Nlp.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Numerics.html +23 -15
- package/distrib/docs/symbols/JXG.Math.Plot.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Poly.Monomial.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Poly.Polynomial.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Poly.Ring.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Poly.html +2 -2
- package/distrib/docs/symbols/JXG.Math.ProbFuncs.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Quadtree.html +122 -7
- package/distrib/docs/symbols/JXG.Math.Statistics.html +2 -2
- package/distrib/docs/symbols/JXG.Math.Symbolic.html +2 -2
- package/distrib/docs/symbols/JXG.Math.html +45 -2
- package/distrib/docs/symbols/JXG.NoRenderer.html +2 -2
- package/distrib/docs/symbols/JXG.Options.html +2 -2
- package/distrib/docs/symbols/JXG.Plane3D.html +2 -2
- package/distrib/docs/symbols/JXG.Point.html +3 -3
- package/distrib/docs/symbols/JXG.Point3D.html +2 -2
- package/distrib/docs/symbols/JXG.Polygon.html +2 -2
- package/distrib/docs/symbols/JXG.SVGRenderer.html +2 -2
- package/distrib/docs/symbols/JXG.Server.html +2 -2
- package/distrib/docs/symbols/JXG.Server.modules.html +2 -2
- package/distrib/docs/symbols/JXG.Surface3D.html +2 -2
- package/distrib/docs/symbols/JXG.Text.html +8 -8
- package/distrib/docs/symbols/JXG.Ticks.html +2 -2
- package/distrib/docs/symbols/JXG.Transformation.html +2 -2
- package/distrib/docs/symbols/JXG.Turtle.html +2 -2
- package/distrib/docs/symbols/JXG.Util.Base64.html +2 -2
- package/distrib/docs/symbols/JXG.Util.UTF8.html +2 -2
- package/distrib/docs/symbols/JXG.Util.Unzip.html +2 -2
- package/distrib/docs/symbols/JXG.Util.html +2 -2
- package/distrib/docs/symbols/JXG.VMLRenderer.html +2 -2
- package/distrib/docs/symbols/JXG.View3D.html +2 -2
- package/distrib/docs/symbols/JXG.XML.html +2 -2
- package/distrib/docs/symbols/Label.html +114 -4
- package/distrib/docs/symbols/Legend.html +2 -2
- package/distrib/docs/symbols/Line.html +2 -2
- package/distrib/docs/symbols/Line3D.html +2 -2
- package/distrib/docs/symbols/Locus.html +2 -2
- package/distrib/docs/symbols/MajorArc.html +2 -2
- package/distrib/docs/symbols/MajorSector.html +2 -2
- package/distrib/docs/symbols/Metapostspline.html +2 -2
- package/distrib/docs/symbols/Midpoint.html +4 -4
- package/distrib/docs/symbols/MinorArc.html +2 -2
- package/distrib/docs/symbols/MinorSector.html +2 -2
- package/distrib/docs/symbols/Mirrorelement.html +2 -2
- package/distrib/docs/symbols/Mirrorpoint.html +4 -4
- package/distrib/docs/symbols/NonReflexAngle.html +2 -2
- package/distrib/docs/symbols/Normal.html +2 -2
- package/distrib/docs/symbols/Orthogonalprojection.html +4 -4
- package/distrib/docs/symbols/OtherIntersection.html +4 -4
- package/distrib/docs/symbols/Parabola.html +2 -2
- package/distrib/docs/symbols/Parallel.html +2 -2
- package/distrib/docs/symbols/Parallelpoint.html +4 -4
- package/distrib/docs/symbols/ParametricSurface3D.html +2 -2
- package/distrib/docs/symbols/Perpendicular.html +2 -2
- package/distrib/docs/symbols/PerpendicularPoint.html +4 -4
- package/distrib/docs/symbols/PerpendicularSegment.html +2 -2
- package/distrib/docs/symbols/Point.html +4 -4
- package/distrib/docs/symbols/Point3D.html +2 -2
- package/distrib/docs/symbols/PolarLine.html +2 -2
- package/distrib/docs/symbols/PolePoint.html +4 -4
- package/distrib/docs/symbols/Polygon.html +2 -2
- package/distrib/docs/symbols/PolygonalChain.html +2 -2
- package/distrib/docs/symbols/RadicalAxis.html +2 -2
- package/distrib/docs/symbols/Reflection.html +2 -2
- package/distrib/docs/symbols/ReflexAngle.html +2 -2
- package/distrib/docs/symbols/RegularPolygon.html +2 -2
- package/distrib/docs/symbols/Riemannsum.html +7 -3
- package/distrib/docs/symbols/Sector.html +2 -2
- package/distrib/docs/symbols/Segment.html +2 -2
- package/distrib/docs/symbols/Semicircle.html +2 -2
- package/distrib/docs/symbols/Slider.html +145 -4
- package/distrib/docs/symbols/Slopefield.html +2 -2
- package/distrib/docs/symbols/Slopetriangle.html +2 -2
- package/distrib/docs/symbols/Smartlabel.html +4 -4
- package/distrib/docs/symbols/Spline.html +2 -2
- package/distrib/docs/symbols/Stepfunction.html +2 -2
- package/distrib/docs/symbols/Tangent.html +2 -2
- package/distrib/docs/symbols/Tapemeasure.html +2 -2
- package/distrib/docs/symbols/Text.html +4 -4
- package/distrib/docs/symbols/Ticks.html +2 -2
- package/distrib/docs/symbols/Tracecurve.html +2 -2
- package/distrib/docs/symbols/Transformation.html +2 -2
- package/distrib/docs/symbols/Turtle.html +2 -2
- package/distrib/docs/symbols/Vectorfield.html +2 -2
- package/distrib/docs/symbols/View3D.html +2 -2
- package/distrib/docs/symbols/_global_.html +2 -2
- package/distrib/docs/symbols/src/src_3d_view3d.js.html +29 -30
- package/distrib/docs/symbols/src/src_base_board.js.html +5020 -4930
- package/distrib/docs/symbols/src/src_base_constants.js.html +1 -1
- package/distrib/docs/symbols/src/src_base_coordselement.js.html +1829 -1789
- package/distrib/docs/symbols/src/src_base_curve.js.html +783 -778
- package/distrib/docs/symbols/src/src_base_text.js.html +345 -358
- package/distrib/docs/symbols/src/src_element_checkbox.js.html +30 -30
- package/distrib/docs/symbols/src/src_element_slider.js.html +391 -377
- package/distrib/docs/symbols/src/src_math_numerics.js.html +1226 -1190
- package/distrib/docs/symbols/src/src_math_qdt.js.html +318 -194
- package/distrib/docs/symbols/src/src_options.js.html +7137 -7034
- package/distrib/docs/symbols/src/src_renderer_abstract.js.html +1168 -1167
- package/distrib/docs/symbols/src/src_renderer_canvas.js.html +1 -1
- package/distrib/docs/symbols/src/src_renderer_svg.js.html +489 -494
- package/distrib/docs/symbols/src/src_utils_env.js.html +127 -90
- package/distrib/docs.zip +0 -0
- package/distrib/geogebra.min.js +1 -1
- package/distrib/geonext.min.js +1 -1
- package/distrib/intergeo.min.js +1 -1
- package/distrib/jsxgraph.css +24 -22
- package/distrib/jsxgraph.zip +0 -0
- package/distrib/jsxgraphcore.js +2 -2
- package/distrib/jsxgraphcore.mjs +2 -2
- package/distrib/jsxgraphcore.mjs.map +1 -1
- package/distrib/jsxgraphsrc.js +707 -276
- package/distrib/jsxgraphsrc.mjs +707 -276
- package/distrib/jsxgraphsrc.mjs.map +1 -1
- package/distrib/sketch.min.js +1 -1
- package/package.json +1 -1
- package/src/3d/view3d.js +0 -1
- package/src/base/board.js +140 -50
- package/src/base/constants.js +1 -1
- package/src/base/coordselement.js +54 -14
- package/src/base/curve.js +6 -1
- package/src/base/text.js +13 -26
- package/src/element/checkbox.js +17 -17
- package/src/element/slider.js +16 -2
- package/src/math/heap.js +34 -4
- package/src/math/numerics.js +112 -76
- package/src/math/qdt.js +141 -17
- package/src/options.js +115 -12
- package/src/renderer/abstract.js +15 -14
- package/src/renderer/canvas.js +1 -1
- package/src/renderer/svg.js +0 -5
- package/src/utils/env.js +75 -38
package/src/math/qdt.js
CHANGED
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
/*jslint nomen: true, plusplus: true*/
|
|
34
34
|
|
|
35
35
|
import Mat from "./math";
|
|
36
|
+
import Geometry from "./geometry";
|
|
36
37
|
import Type from "../utils/type";
|
|
37
38
|
|
|
38
39
|
/**
|
|
@@ -41,16 +42,31 @@ import Type from "../utils/type";
|
|
|
41
42
|
* @name JXG.Math.Quadtree
|
|
42
43
|
* @exports Mat.Quadtree as JXG.Math.Quadtree
|
|
43
44
|
* @param {Array} bbox Bounding box of the new quad (sub)tree.
|
|
45
|
+
* @param {Object} config Configuration object. Default value: to {capacity: 10}
|
|
46
|
+
*
|
|
44
47
|
* @constructor
|
|
45
48
|
*/
|
|
46
|
-
Mat.Quadtree = function (bbox) {
|
|
49
|
+
Mat.Quadtree = function (bbox, config, parent) {
|
|
50
|
+
config = config || {
|
|
51
|
+
capacity: 10,
|
|
52
|
+
pointType: 'coords'
|
|
53
|
+
};
|
|
54
|
+
|
|
47
55
|
/**
|
|
48
56
|
* The maximum number of points stored in a quad tree node
|
|
49
57
|
* before it is subdivided.
|
|
50
58
|
* @type Number
|
|
51
59
|
* @default 10
|
|
52
60
|
*/
|
|
53
|
-
this.capacity = 10;
|
|
61
|
+
this.capacity = config.capacity || 10;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Type of a point object. Possible values are:
|
|
65
|
+
* 'coords', 'object'.
|
|
66
|
+
* @type String
|
|
67
|
+
* @default 'coords'
|
|
68
|
+
*/
|
|
69
|
+
this.pointType = config.pointType || 'coords';
|
|
54
70
|
|
|
55
71
|
/**
|
|
56
72
|
* Point storage.
|
|
@@ -63,6 +79,15 @@ Mat.Quadtree = function (bbox) {
|
|
|
63
79
|
this.ylb = bbox[3];
|
|
64
80
|
this.yub = bbox[1];
|
|
65
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Parent quad tree or null if there is not parent.
|
|
84
|
+
*
|
|
85
|
+
* @name JXG.Math.Quadtree#northWest
|
|
86
|
+
* @type JXG.Math.Quadtree
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
this.parent = parent || null;
|
|
90
|
+
|
|
66
91
|
/**
|
|
67
92
|
* In a subdivided quad tree this represents the top left subtree.
|
|
68
93
|
* @name JXG.Math.Quadtree#northWest
|
|
@@ -90,6 +115,7 @@ Mat.Quadtree = function (bbox) {
|
|
|
90
115
|
* @type JXG.Math.Quadtree
|
|
91
116
|
*/
|
|
92
117
|
this.southWest = null;
|
|
118
|
+
|
|
93
119
|
};
|
|
94
120
|
|
|
95
121
|
Type.extend(
|
|
@@ -106,13 +132,24 @@ Type.extend(
|
|
|
106
132
|
},
|
|
107
133
|
|
|
108
134
|
/**
|
|
109
|
-
* Insert a new point into this quad tree.
|
|
135
|
+
* Insert a new point into this quad tree. Do this only,
|
|
136
|
+
* if the point is not yet in the quadtree (test exactly).
|
|
137
|
+
*
|
|
110
138
|
* @param {JXG.Coords} p
|
|
111
139
|
* @returns {Boolean}
|
|
112
140
|
*/
|
|
113
141
|
insert: function (p) {
|
|
114
|
-
|
|
115
|
-
|
|
142
|
+
switch (this.pointType) {
|
|
143
|
+
case 'coords':
|
|
144
|
+
if (!this.contains(p.usrCoords[1], p.usrCoords[2])) {
|
|
145
|
+
return false;
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
case 'object':
|
|
149
|
+
if (!this.contains(p.x, p.y)) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
116
153
|
}
|
|
117
154
|
|
|
118
155
|
if (this.points.length < this.capacity) {
|
|
@@ -144,21 +181,22 @@ Type.extend(
|
|
|
144
181
|
*/
|
|
145
182
|
subdivide: function () {
|
|
146
183
|
var i,
|
|
147
|
-
|
|
184
|
+
le = this.points.length,
|
|
148
185
|
mx = this.xlb + (this.xub - this.xlb) / 2,
|
|
149
186
|
my = this.ylb + (this.yub - this.ylb) / 2;
|
|
150
187
|
|
|
151
|
-
this.northWest = new Mat.Quadtree([this.xlb, this.yub, mx, my]);
|
|
152
|
-
this.northEast = new Mat.Quadtree([mx, this.yub, this.xub, my]);
|
|
153
|
-
this.southEast = new Mat.Quadtree([this.xlb, my, mx, this.ylb]);
|
|
154
|
-
this.southWest = new Mat.Quadtree([mx, my, this.xub, this.ylb]);
|
|
188
|
+
this.northWest = new Mat.Quadtree([this.xlb, this.yub, mx, my], this.config, this);
|
|
189
|
+
this.northEast = new Mat.Quadtree([mx, this.yub, this.xub, my], this.config, this);
|
|
190
|
+
this.southEast = new Mat.Quadtree([this.xlb, my, mx, this.ylb], this.config, this);
|
|
191
|
+
this.southWest = new Mat.Quadtree([mx, my, this.xub, this.ylb], this.config, this);
|
|
155
192
|
|
|
156
|
-
for (i = 0; i <
|
|
157
|
-
this.
|
|
158
|
-
this.northEast.insert(this.points[i]);
|
|
159
|
-
this.southEast.insert(this.points[i]);
|
|
160
|
-
this.southWest.insert(this.points[i]);
|
|
193
|
+
for (i = 0; i < le; i += 1) {
|
|
194
|
+
this.insert(this.points[i]);
|
|
161
195
|
}
|
|
196
|
+
|
|
197
|
+
// We empty this node points
|
|
198
|
+
this.points.length = 0;
|
|
199
|
+
this.points = [];
|
|
162
200
|
},
|
|
163
201
|
|
|
164
202
|
/**
|
|
@@ -204,14 +242,13 @@ Type.extend(
|
|
|
204
242
|
},
|
|
205
243
|
|
|
206
244
|
/**
|
|
207
|
-
* Retrieve the smallest quad tree that contains the given
|
|
245
|
+
* Retrieve the smallest quad tree that contains the given coordinate pair.
|
|
208
246
|
* @name JXG.Math.Quadtree#_query
|
|
209
247
|
* @param {JXG.Coords|Number} xp
|
|
210
248
|
* @param {Number} y
|
|
211
249
|
* @returns {Boolean|JXG.Quadtree} The quad tree if the point is found, false
|
|
212
250
|
* if none of the quad trees contains the point (i.e. the point is not inside
|
|
213
251
|
* the root tree's AABB).
|
|
214
|
-
* @private
|
|
215
252
|
*/
|
|
216
253
|
query: function (xp, y) {
|
|
217
254
|
var _x, _y;
|
|
@@ -225,7 +262,94 @@ Type.extend(
|
|
|
225
262
|
}
|
|
226
263
|
|
|
227
264
|
return this._query(_x, _y);
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
*
|
|
269
|
+
* @param {*} x
|
|
270
|
+
* @param {*} y
|
|
271
|
+
* @param {*} tol
|
|
272
|
+
* @returns {Boolean}
|
|
273
|
+
*/
|
|
274
|
+
isIn: function (x, y, tol) {
|
|
275
|
+
var r, i, le;
|
|
276
|
+
|
|
277
|
+
if (this.contains(x, y)) {
|
|
278
|
+
le = this.points.length;
|
|
279
|
+
|
|
280
|
+
switch (this.pointType) {
|
|
281
|
+
case 'coords':
|
|
282
|
+
for (i = 0; i < le; i++) {
|
|
283
|
+
if (Geometry.distance([x, y], this.points[i].usrCoords.slice(1), 2) < tol) {
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
break;
|
|
288
|
+
case 'object':
|
|
289
|
+
for (i = 0; i < le; i++) {
|
|
290
|
+
if (Geometry.distance([x, y], [this.points[i].x, this.points[i].y], 2) < tol) {
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
if (this.northWest === null) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
r = this.northWest.isIn(x, y, tol);
|
|
303
|
+
if (r) {
|
|
304
|
+
return r;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
r = this.northEast.isIn(x, y, tol);
|
|
308
|
+
if (r) {
|
|
309
|
+
return r;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
r = this.southEast.isIn(x, y, tol);
|
|
313
|
+
if (r) {
|
|
314
|
+
return r;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
r = this.southWest.isIn(x, y, tol);
|
|
318
|
+
if (r) {
|
|
319
|
+
return r;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
return false;
|
|
324
|
+
},
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
*
|
|
328
|
+
* @returns {Array}
|
|
329
|
+
*/
|
|
330
|
+
getAllPoints: function() {
|
|
331
|
+
var pointsList = [];
|
|
332
|
+
this.getAllPointsRecursive(pointsList);
|
|
333
|
+
return pointsList;
|
|
334
|
+
},
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
*
|
|
338
|
+
* @param {Array} pointsList
|
|
339
|
+
* @private
|
|
340
|
+
*/
|
|
341
|
+
getAllPointsRecursive(pointsList) {
|
|
342
|
+
if (this.northWest === null) {
|
|
343
|
+
Array.prototype.push.apply(pointsList, this.points.slice());
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
this.northWest.getAllPointsRecursive(pointsList);
|
|
348
|
+
this.northEast.getAllPointsRecursive(pointsList);
|
|
349
|
+
this.southEast.getAllPointsRecursive(pointsList);
|
|
350
|
+
this.southWest.getAllPointsRecursive(pointsList);
|
|
228
351
|
}
|
|
352
|
+
|
|
229
353
|
}
|
|
230
354
|
);
|
|
231
355
|
|
package/src/options.js
CHANGED
|
@@ -788,7 +788,7 @@ JXG.Options = {
|
|
|
788
788
|
* Especially, on mobile devices this enhances the user experience.
|
|
789
789
|
* However, it is recommended to allow dragging outside of the JSXGraph board only
|
|
790
790
|
* in certain constructions where users may not "loose" points outside of the board.
|
|
791
|
-
*
|
|
791
|
+
* In such a case, points may become unreachable.
|
|
792
792
|
* <p>
|
|
793
793
|
* A situation where dragging outside of the board is uncritical is for example if
|
|
794
794
|
* only sliders are used to interact with the construction.
|
|
@@ -800,9 +800,18 @@ JXG.Options = {
|
|
|
800
800
|
* <li> document
|
|
801
801
|
* </ul>
|
|
802
802
|
* <p>
|
|
803
|
+
* Since the introduction of this attribute "moveTarget", the value "document" has become sort of
|
|
804
|
+
* default on touch devices like smartphones. However, it is no longer the case that the document listens to
|
|
805
|
+
* move events, but there is the new feature "setPointerCapture", which is also implicitly enabled on certain devices.
|
|
806
|
+
* In future versions, JSXGraph may adopt this new standard and distinguish only two cases:
|
|
807
|
+
* <ul>
|
|
808
|
+
* <li>null: no pointerCapture
|
|
809
|
+
* <li>document: use pointerCapture
|
|
810
|
+
* </ul>
|
|
811
|
+
* <p>
|
|
803
812
|
* This attribute is immutable.
|
|
804
813
|
* It can be changed as follows:
|
|
805
|
-
*
|
|
814
|
+
*
|
|
806
815
|
* @example
|
|
807
816
|
* board.setAttribute({moveTarget: null});
|
|
808
817
|
* board.removeEventHandlers();
|
|
@@ -885,9 +894,9 @@ JXG.Options = {
|
|
|
885
894
|
* Allow user interaction by registering mouse, pointer, keyboard or touch events.
|
|
886
895
|
* Decide if JSXGraph listens to these events. Keyboard events can then turned off
|
|
887
896
|
* separately with the keyboard attribute.
|
|
888
|
-
*
|
|
897
|
+
*
|
|
889
898
|
* <p>This attribute is immutable. Please use
|
|
890
|
-
* {@link JXG.Board#addEventHandlers()} and
|
|
899
|
+
* {@link JXG.Board#addEventHandlers()} and
|
|
891
900
|
* {@link JXG.Board#removeEventHandlers()} directly.
|
|
892
901
|
*
|
|
893
902
|
* @name JXG.Board#registerEvents
|
|
@@ -903,7 +912,7 @@ JXG.Options = {
|
|
|
903
912
|
* Listen to fullscreen event.
|
|
904
913
|
*
|
|
905
914
|
* <p>This attribute is immutable. Please use
|
|
906
|
-
* {@link JXG.Board#addFullscreenEventHandlers()} and
|
|
915
|
+
* {@link JXG.Board#addFullscreenEventHandlers()} and
|
|
907
916
|
* {@link JXG.Board#removeEventHandlers()} directly.
|
|
908
917
|
*
|
|
909
918
|
* @name JXG.Board#registerFullscreenEvent
|
|
@@ -917,14 +926,14 @@ JXG.Options = {
|
|
|
917
926
|
/**
|
|
918
927
|
* Listen to resize events, i.e. start "resizeObserver" or handle the resize event with
|
|
919
928
|
* "resizeListener". This is independent from the mouse, touch, pointer events.
|
|
920
|
-
*
|
|
929
|
+
*
|
|
921
930
|
* <p>This attribute is immutable. Please use
|
|
922
|
-
* {@link JXG.Board#addResizeEventHandlers()} and
|
|
931
|
+
* {@link JXG.Board#addResizeEventHandlers()} and
|
|
923
932
|
* {@link JXG.Board#removeEventHandlers()} directly.
|
|
924
933
|
* <p>
|
|
925
934
|
* This attribute just starts a resizeObserver. If the resizeObserver reacts
|
|
926
935
|
* to size changed is controled wuth {@link JXG.Board#resize}.
|
|
927
|
-
*
|
|
936
|
+
*
|
|
928
937
|
* @name JXG.Board#registerResizeEvent
|
|
929
938
|
* @see JXG.Board#resize
|
|
930
939
|
* @see JXG.Board#registerEvents
|
|
@@ -941,7 +950,7 @@ JXG.Options = {
|
|
|
941
950
|
* <p>
|
|
942
951
|
* In case of 'canvas' it is advisable to call 'board.update()' after all elements have been
|
|
943
952
|
* constructed. This ensures that all elements are drawn with their intended visual appearance.
|
|
944
|
-
*
|
|
953
|
+
*
|
|
945
954
|
* <p>
|
|
946
955
|
* This attribute is immutable.
|
|
947
956
|
*
|
|
@@ -3972,11 +3981,11 @@ JXG.Options = {
|
|
|
3972
3981
|
width: 0.4,
|
|
3973
3982
|
|
|
3974
3983
|
/**
|
|
3975
|
-
* Angle under which comb elements are positioned.
|
|
3984
|
+
* Angle - given in radians - under which comb elements are positioned.
|
|
3976
3985
|
*
|
|
3977
3986
|
* @type Number
|
|
3978
3987
|
* @name Comb#angle
|
|
3979
|
-
* @default 60 degrees
|
|
3988
|
+
* @default Math.PI / 3 (i.e. π /3 or 60^° degrees)
|
|
3980
3989
|
*/
|
|
3981
3990
|
angle: Math.PI / 3,
|
|
3982
3991
|
|
|
@@ -4812,7 +4821,37 @@ JXG.Options = {
|
|
|
4812
4821
|
*
|
|
4813
4822
|
*
|
|
4814
4823
|
*/
|
|
4815
|
-
autoPosition: false
|
|
4824
|
+
autoPosition: false,
|
|
4825
|
+
|
|
4826
|
+
/**
|
|
4827
|
+
* The auto position algorithm tries to put a label to a conflict-free
|
|
4828
|
+
* position around it's anchor element. For this, the algorithm tests 12 positions
|
|
4829
|
+
* around the anchor element starting at a distance from the anchor
|
|
4830
|
+
* defined here (in pixel).
|
|
4831
|
+
*
|
|
4832
|
+
* @name Label#autoPositionMinDistance
|
|
4833
|
+
* @see Label#autoPosition
|
|
4834
|
+
* @see Label#autoPositionMaxDistance
|
|
4835
|
+
* @type Number
|
|
4836
|
+
* @default 12
|
|
4837
|
+
*
|
|
4838
|
+
*/
|
|
4839
|
+
autoPositionMinDistance: 12,
|
|
4840
|
+
|
|
4841
|
+
/**
|
|
4842
|
+
* The auto position algorithm tries to put a label to a conflict-free
|
|
4843
|
+
* position around it's anchor element. For this, the algorithm tests 12 positions
|
|
4844
|
+
* around the anchor element up to a distance from the anchor
|
|
4845
|
+
* defined here (in pixel).
|
|
4846
|
+
*
|
|
4847
|
+
* @name Label#autoPositionMaxDistance
|
|
4848
|
+
* @see Label#autoPosition
|
|
4849
|
+
* @see Label#autoPositionMinDistance
|
|
4850
|
+
* @type Number
|
|
4851
|
+
* @default 28
|
|
4852
|
+
*
|
|
4853
|
+
*/
|
|
4854
|
+
autoPositionMaxDistance: 28
|
|
4816
4855
|
|
|
4817
4856
|
/**#@-*/
|
|
4818
4857
|
},
|
|
@@ -6114,6 +6153,70 @@ JXG.Options = {
|
|
|
6114
6153
|
*/
|
|
6115
6154
|
snapWidth: -1, // -1 = deactivated
|
|
6116
6155
|
|
|
6156
|
+
/**
|
|
6157
|
+
* List of values to snap to. If the glider is within snapValueDistance
|
|
6158
|
+
* (in user coordinate units) of one of these points,
|
|
6159
|
+
* then the glider snaps to that point.
|
|
6160
|
+
*
|
|
6161
|
+
* @memberOf Slider.prototype
|
|
6162
|
+
* @name snapValues
|
|
6163
|
+
* @type Array
|
|
6164
|
+
* @see Slider#snapValueDistance
|
|
6165
|
+
* @default empty
|
|
6166
|
+
*
|
|
6167
|
+
* @example
|
|
6168
|
+
* var n = board.create('slider', [[-2, 3], [4, 3], [1, 5, 100]], {
|
|
6169
|
+
* name: 'n',
|
|
6170
|
+
* snapWidth: 1,
|
|
6171
|
+
* snapValues: [1, 22, 77, 100],
|
|
6172
|
+
* snapValueDistance: 5
|
|
6173
|
+
* });
|
|
6174
|
+
*
|
|
6175
|
+
* var k = board.create('slider', [[-2, -1], [4, -1], [-4, 0, 4]], {
|
|
6176
|
+
* name: 'k',
|
|
6177
|
+
* snapWidth: 0.1,
|
|
6178
|
+
* snapValues: [-3, -1, 1, 3],
|
|
6179
|
+
* snapValueDistance: 0.4
|
|
6180
|
+
* });
|
|
6181
|
+
*
|
|
6182
|
+
* </pre><div id="JXG9be68014-4e14-479a-82b4-e92d9b8f6eef" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
6183
|
+
* <script type="text/javascript">
|
|
6184
|
+
* (function() {
|
|
6185
|
+
* var board = JXG.JSXGraph.initBoard('JXG9be68014-4e14-479a-82b4-e92d9b8f6eef',
|
|
6186
|
+
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
6187
|
+
* var n = board.create('slider', [[-2, 3], [4, 3], [1, 5, 100]], {
|
|
6188
|
+
* name: 'n',
|
|
6189
|
+
* snapWidth: 1,
|
|
6190
|
+
* snapValues: [1, 22, 77, 100],
|
|
6191
|
+
* snapValueDistance: 5
|
|
6192
|
+
* });
|
|
6193
|
+
*
|
|
6194
|
+
* var k = board.create('slider', [[-2, -1], [4, -1], [-4, 0, 4]], {
|
|
6195
|
+
* name: 'k',
|
|
6196
|
+
* snapWidth: 0.1,
|
|
6197
|
+
* snapValues: [-3, -1, 1, 3],
|
|
6198
|
+
* snapValueDistance: 0.4
|
|
6199
|
+
* });
|
|
6200
|
+
*
|
|
6201
|
+
* })();
|
|
6202
|
+
*
|
|
6203
|
+
* </script><pre>
|
|
6204
|
+
*
|
|
6205
|
+
*/
|
|
6206
|
+
snapValues: [],
|
|
6207
|
+
|
|
6208
|
+
/**
|
|
6209
|
+
* If the difference between the slider value and one of the elements of snapValues is less
|
|
6210
|
+
* than this number (in user coordinate units), the slider will snap to that value.
|
|
6211
|
+
*
|
|
6212
|
+
* @memberOf Slider.prototype
|
|
6213
|
+
* @name snapValueDistance
|
|
6214
|
+
* @type Number
|
|
6215
|
+
* @see Slider#snapValues
|
|
6216
|
+
* @default 0.0
|
|
6217
|
+
*/
|
|
6218
|
+
snapValueDistance: 0.0,
|
|
6219
|
+
|
|
6117
6220
|
/**
|
|
6118
6221
|
* The precision of the slider value displayed in the optional text.
|
|
6119
6222
|
* Replaced by the attribute "digits".
|
package/src/renderer/abstract.js
CHANGED
|
@@ -1257,20 +1257,21 @@ JXG.extend(
|
|
|
1257
1257
|
MathJax.Hub.Queue(["Typeset", MathJax.Hub, el.rendNode]);
|
|
1258
1258
|
}
|
|
1259
1259
|
|
|
1260
|
-
//
|
|
1261
|
-
//
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1260
|
+
// Obsolete:
|
|
1261
|
+
// // Restore the transformation necessary for fullscreen mode
|
|
1262
|
+
// // MathJax removes it when handling dynamic content
|
|
1263
|
+
// id = el.board.container;
|
|
1264
|
+
// wrap_id = "fullscreenwrap_" + id;
|
|
1265
|
+
// if (document.getElementById(wrap_id)) {
|
|
1266
|
+
// scale = el.board.containerObj._cssFullscreenStore.scale;
|
|
1267
|
+
// vshift = el.board.containerObj._cssFullscreenStore.vshift;
|
|
1268
|
+
// Env.scaleJSXGraphDiv(
|
|
1269
|
+
// "#" + wrap_id,
|
|
1270
|
+
// "#" + id,
|
|
1271
|
+
// scale,
|
|
1272
|
+
// vshift
|
|
1273
|
+
// );
|
|
1274
|
+
// }
|
|
1274
1275
|
} catch (e) {
|
|
1275
1276
|
JXG.debug("MathJax (not yet) loaded");
|
|
1276
1277
|
}
|
package/src/renderer/canvas.js
CHANGED
|
@@ -1687,7 +1687,7 @@ JXG.extend(
|
|
|
1687
1687
|
}
|
|
1688
1688
|
this.context = this.canvasRoot.getContext("2d");
|
|
1689
1689
|
// The width and height of the canvas is set to twice the CSS values,
|
|
1690
|
-
// followed by an
|
|
1690
|
+
// followed by an appropriate scaling.
|
|
1691
1691
|
// See https://stackoverflow.com/questions/22416462/canvas-element-with-blurred-lines
|
|
1692
1692
|
this.context.scale(2, 2);
|
|
1693
1693
|
},
|
package/src/renderer/svg.js
CHANGED
|
@@ -1827,13 +1827,8 @@ JXG.extend(
|
|
|
1827
1827
|
|
|
1828
1828
|
// documented in AbstractRenderer
|
|
1829
1829
|
resize: function (w, h) {
|
|
1830
|
-
// this.svgRoot.style.width = parseFloat(w) + 'px';
|
|
1831
|
-
// this.svgRoot.style.height = parseFloat(h) + 'px';
|
|
1832
|
-
|
|
1833
1830
|
this.svgRoot.setAttribute("width", parseFloat(w));
|
|
1834
1831
|
this.svgRoot.setAttribute("height", parseFloat(h));
|
|
1835
|
-
// this.svgRoot.setAttribute('width', '100%');
|
|
1836
|
-
// this.svgRoot.setAttribute('height', '100%');
|
|
1837
1832
|
},
|
|
1838
1833
|
|
|
1839
1834
|
// documented in JXG.AbstractRenderer
|
package/src/utils/env.js
CHANGED
|
@@ -547,7 +547,7 @@ JXG.extend(
|
|
|
547
547
|
/**
|
|
548
548
|
* Cross browser mouse / pointer / touch coordinates retrieval relative to the documents's top left corner.
|
|
549
549
|
* This method might be a bit outdated today, since pointer events and clientX/Y are omnipresent.
|
|
550
|
-
*
|
|
550
|
+
*
|
|
551
551
|
* @param {Object} [e] The browsers event object. If omitted, <tt>window.event</tt> will be used.
|
|
552
552
|
* @param {Number} [index] If <tt>e</tt> is a touch event, this provides the index of the touch coordinates, i.e. it determines which finger.
|
|
553
553
|
* @param {Object} [doc] The document object.
|
|
@@ -912,10 +912,16 @@ JXG.extend(
|
|
|
912
912
|
*
|
|
913
913
|
*/
|
|
914
914
|
scaleJSXGraphDiv: function (wrap_id, inner_id, doc, scale) {
|
|
915
|
-
var len = doc.styleSheets.length, style, rule,
|
|
916
|
-
|
|
915
|
+
var len = doc.styleSheets.length, style, rule,
|
|
916
|
+
w, h, b,
|
|
917
|
+
wi, hi,
|
|
918
|
+
wo, ho, inner,
|
|
919
|
+
scale_l, vshift_l,
|
|
917
920
|
f = scale,
|
|
918
|
-
|
|
921
|
+
ratio,
|
|
922
|
+
rule_inner_l,
|
|
923
|
+
title = 'jsxgraph_fullscreen_css',
|
|
924
|
+
found_css,
|
|
919
925
|
pseudo_keys = [
|
|
920
926
|
":fullscreen",
|
|
921
927
|
":-webkit-full-screen",
|
|
@@ -938,45 +944,80 @@ JXG.extend(
|
|
|
938
944
|
h = b.height;
|
|
939
945
|
w = b.width;
|
|
940
946
|
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
947
|
+
inner = doc.getElementById(inner_id);
|
|
948
|
+
wo = inner._cssFullscreenStore.w;
|
|
949
|
+
ho = inner._cssFullscreenStore.h;
|
|
950
|
+
ratio = ho / wo;
|
|
951
|
+
|
|
952
|
+
// Scale the div such that fits into the fullscreen.
|
|
953
|
+
if (wo > w * f) {
|
|
954
|
+
wo = w * f;
|
|
955
|
+
ho = wo * ratio;
|
|
956
|
+
}
|
|
957
|
+
if (ho > h * f) {
|
|
958
|
+
ho = h * f;
|
|
959
|
+
wo = ho / ratio;
|
|
960
|
+
}
|
|
944
961
|
|
|
945
|
-
|
|
946
|
-
|
|
962
|
+
wi = wo;
|
|
963
|
+
hi = ho;
|
|
964
|
+
// Compare this.setBoundingBox()
|
|
965
|
+
if (ratio > 1) {
|
|
966
|
+
// h > w
|
|
967
|
+
if (ratio < h / w) {
|
|
968
|
+
scale_l = w * f / wo;
|
|
969
|
+
} else {
|
|
970
|
+
scale_l = h * f / ho;
|
|
971
|
+
}
|
|
947
972
|
} else {
|
|
948
|
-
|
|
973
|
+
// h <= w
|
|
974
|
+
if (ratio < h / w) {
|
|
975
|
+
scale_l = w * f / wo;
|
|
976
|
+
} else {
|
|
977
|
+
scale_l = h * f / ho;
|
|
978
|
+
}
|
|
949
979
|
}
|
|
950
980
|
vshift_l = (h - hi) * 0.5;
|
|
951
981
|
|
|
952
982
|
// CSS rules to center the inner div horizontally and vertically.
|
|
953
983
|
rule_inner_l =
|
|
954
|
-
"{
|
|
955
|
-
|
|
956
|
-
"
|
|
957
|
-
|
|
958
|
-
",0," +
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
984
|
+
"{" +
|
|
985
|
+
"width:" + wi + "px !important;" +
|
|
986
|
+
"height:" + hi + "px !important;" +
|
|
987
|
+
"margin:0 auto;" +
|
|
988
|
+
"transform:matrix(" + scale_l + ",0,0," + scale_l + ",0," + vshift_l + ");" +
|
|
989
|
+
"}";
|
|
990
|
+
|
|
991
|
+
found_css = false;
|
|
992
|
+
// Removing of the CSS here should happen only
|
|
993
|
+
// in emergency cases.
|
|
994
|
+
for (i = len - 1; i >= 0; i--) {
|
|
995
|
+
if (doc.styleSheets[i].title === title) {
|
|
996
|
+
found_css = true;
|
|
997
|
+
|
|
998
|
+
if (doc.styleSheets[i].title === title &&
|
|
999
|
+
doc.styleSheets[i].cssRules.length > 0 &&
|
|
1000
|
+
regex.test(doc.styleSheets[i].cssRules[0].cssText) &&
|
|
1001
|
+
doc.styleSheets[i].deleteRule
|
|
1002
|
+
) {
|
|
1003
|
+
doc.styleSheets[i].deleteRule(0);
|
|
1004
|
+
break;
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
if (!found_css) {
|
|
1009
|
+
// In case there is not yet a CSS style sheet for fullscreen
|
|
1010
|
+
// defined, do it now.
|
|
964
1011
|
style = document.createElement("style");
|
|
1012
|
+
style.setAttribute('title', title);
|
|
965
1013
|
// WebKit hack :(
|
|
966
1014
|
style.appendChild(document.createTextNode(""));
|
|
967
|
-
// Add the <style> element to the page
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
// Remove a previously installed CSS rule.
|
|
973
|
-
if (
|
|
974
|
-
doc.styleSheets[len - 1].cssRules.length > 0 &&
|
|
975
|
-
regex.test(doc.styleSheets[len - 1].cssRules[0].cssText) &&
|
|
976
|
-
doc.styleSheets[len - 1].deleteRule
|
|
977
|
-
) {
|
|
978
|
-
doc.styleSheets[len - 1].deleteRule(0);
|
|
1015
|
+
// Add the <style> element to the page head.
|
|
1016
|
+
// It must be document, not the shadowDOM root.
|
|
1017
|
+
// It seems that the head tag does always exist.
|
|
1018
|
+
document.head.appendChild(style);
|
|
979
1019
|
}
|
|
1020
|
+
len = doc.styleSheets.length;
|
|
980
1021
|
|
|
981
1022
|
// Install a CSS rule to center the JSXGraph div at the first position of the list.
|
|
982
1023
|
for (i = 0; i < len_pseudo; i++) {
|
|
@@ -986,14 +1027,10 @@ JXG.extend(
|
|
|
986
1027
|
doc.styleSheets[len - 1].insertRule(rule, 0);
|
|
987
1028
|
|
|
988
1029
|
break;
|
|
989
|
-
} catch (err) {
|
|
990
|
-
// console.log('JXG.scaleJSXGraphDiv: Could not add CSS rule "' + pseudo_keys[i] + '".');
|
|
991
|
-
// console.log('One possible reason could be that the id of the JSXGraph container does not start with a letter.');
|
|
992
|
-
}
|
|
1030
|
+
} catch (err) {}
|
|
993
1031
|
}
|
|
994
1032
|
if (i === len_pseudo) {
|
|
995
|
-
|
|
996
|
-
console.log(
|
|
1033
|
+
JXG.debug("JXG.scaleJSXGraphDiv: Could not add any CSS rule.\n" +
|
|
997
1034
|
"One possible reason could be that the id of the JSXGraph container does not start with a letter."
|
|
998
1035
|
);
|
|
999
1036
|
}
|