jsxgraph 1.9.1 → 1.9.2
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 +49 -0
- package/distrib/docs.zip +0 -0
- package/distrib/geogebra.min.js +2 -2
- package/distrib/geonext.min.js +2 -2
- package/distrib/intergeo.min.js +2 -2
- package/distrib/jsxgraph.css +1 -1
- package/distrib/jsxgraph.zip +0 -0
- package/distrib/jsxgraphcore.js +3 -3
- package/distrib/jsxgraphcore.mjs +3 -3
- package/distrib/jsxgraphcore.mjs.map +1 -1
- package/distrib/jsxgraphsrc.js +2328 -1508
- package/distrib/jsxgraphsrc.mjs +2328 -1508
- package/distrib/jsxgraphsrc.mjs.map +1 -1
- package/distrib/sketch.min.js +3 -3
- package/package.json +4 -4
- package/src/3d/box3d.js +4 -1
- package/src/3d/circle3d.js +10 -9
- package/src/3d/curve3d.js +2 -0
- package/src/3d/linspace3d.js +18 -55
- package/src/3d/point3d.js +6 -0
- package/src/3d/polygon3d.js +1 -0
- package/src/3d/sphere3d.js +47 -43
- package/src/3d/surface3d.js +1 -0
- package/src/3d/view3d.js +1504 -1067
- package/src/base/board.js +176 -55
- package/src/base/circle.js +3 -1
- package/src/base/constants.js +1 -1
- package/src/base/curve.js +1 -0
- package/src/base/element.js +38 -30
- package/src/base/line.js +93 -105
- package/src/base/polygon.js +1 -1
- package/src/base/text.js +5 -1
- package/src/element/button.js +62 -12
- package/src/element/checkbox.js +6 -2
- package/src/element/grid.js +6 -6
- package/src/element/input.js +9 -6
- package/src/element/slider.js +42 -39
- package/src/jsxgraph.js +5 -3
- package/src/math/geometry.js +86 -64
- package/src/math/math.js +47 -5
- package/src/options.js +45 -0
- package/src/options3d.js +82 -5
- package/src/parser/jessiecode.js +2 -1
- package/src/parser/prefix.js +8 -1
- package/src/reader/sketch.js +106 -0
- package/src/renderer/svg.js +16 -6
- package/src/utils/env.js +2 -2
- package/src/utils/type.js +27 -15
package/src/base/line.js
CHANGED
|
@@ -330,7 +330,9 @@ JXG.extend(
|
|
|
330
330
|
// Compute the actual length of the segment
|
|
331
331
|
d = this.point1.Dist(this.point2);
|
|
332
332
|
// Determine the length the segment ought to have
|
|
333
|
-
d_new =
|
|
333
|
+
d_new = (Type.evaluate(this.visProp.nonnegativeonly)) ?
|
|
334
|
+
Math.max(0.0, this.fixedLength()) :
|
|
335
|
+
Math.abs(this.fixedLength());
|
|
334
336
|
|
|
335
337
|
// Distances between the two points and their respective
|
|
336
338
|
// position before the update
|
|
@@ -1010,6 +1012,8 @@ JXG.extend(
|
|
|
1010
1012
|
}
|
|
1011
1013
|
|
|
1012
1014
|
this.fixedLength = Type.createFunction(l, this.board);
|
|
1015
|
+
this.hasFixedLength = true;
|
|
1016
|
+
this.addParentsFromJCFunctions([this.fixedLength]);
|
|
1013
1017
|
this.board.update();
|
|
1014
1018
|
|
|
1015
1019
|
return this;
|
|
@@ -1475,15 +1479,22 @@ JXG.createSegment = function (board, parents, attributes) {
|
|
|
1475
1479
|
el = board.create("line", parents.slice(0, 2), attr);
|
|
1476
1480
|
|
|
1477
1481
|
if (parents.length === 3) {
|
|
1478
|
-
|
|
1482
|
+
try {
|
|
1483
|
+
el.hasFixedLength = true;
|
|
1484
|
+
el.fixedLengthOldCoords = [];
|
|
1485
|
+
el.fixedLengthOldCoords[0] = new Coords(
|
|
1486
|
+
Const.COORDS_BY_USER,
|
|
1487
|
+
el.point1.coords.usrCoords.slice(1, 3),
|
|
1488
|
+
board
|
|
1489
|
+
);
|
|
1490
|
+
el.fixedLengthOldCoords[1] = new Coords(
|
|
1491
|
+
Const.COORDS_BY_USER,
|
|
1492
|
+
el.point2.coords.usrCoords.slice(1, 3),
|
|
1493
|
+
board
|
|
1494
|
+
);
|
|
1479
1495
|
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
return parents[2];
|
|
1483
|
-
};
|
|
1484
|
-
} else if (Type.isFunction(parents[2])) {
|
|
1485
|
-
el.fixedLength = Type.createFunction(parents[2], this.board);
|
|
1486
|
-
} else {
|
|
1496
|
+
el.setFixedLength(parents[2]);
|
|
1497
|
+
} catch (err) {
|
|
1487
1498
|
throw new Error(
|
|
1488
1499
|
"JSXGraph: Can't create segment with third parent type '" +
|
|
1489
1500
|
typeof parents[2] +
|
|
@@ -1491,22 +1502,25 @@ JXG.createSegment = function (board, parents, attributes) {
|
|
|
1491
1502
|
"\nPossible third parent types: number or function"
|
|
1492
1503
|
);
|
|
1493
1504
|
}
|
|
1505
|
+
// if (Type.isNumber(parents[2])) {
|
|
1506
|
+
// el.fixedLength = function () {
|
|
1507
|
+
// return parents[2];
|
|
1508
|
+
// };
|
|
1509
|
+
// } else if (Type.isFunction(parents[2])) {
|
|
1510
|
+
// el.fixedLength = Type.createFunction(parents[2], this.board);
|
|
1511
|
+
// } else {
|
|
1512
|
+
// throw new Error(
|
|
1513
|
+
// "JSXGraph: Can't create segment with third parent type '" +
|
|
1514
|
+
// typeof parents[2] +
|
|
1515
|
+
// "'." +
|
|
1516
|
+
// "\nPossible third parent types: number or function"
|
|
1517
|
+
// );
|
|
1518
|
+
// }
|
|
1494
1519
|
|
|
1495
1520
|
el.getParents = function () {
|
|
1496
1521
|
return this.parents.concat(this.fixedLength());
|
|
1497
1522
|
};
|
|
1498
1523
|
|
|
1499
|
-
el.fixedLengthOldCoords = [];
|
|
1500
|
-
el.fixedLengthOldCoords[0] = new Coords(
|
|
1501
|
-
Const.COORDS_BY_USER,
|
|
1502
|
-
el.point1.coords.usrCoords.slice(1, 3),
|
|
1503
|
-
board
|
|
1504
|
-
);
|
|
1505
|
-
el.fixedLengthOldCoords[1] = new Coords(
|
|
1506
|
-
Const.COORDS_BY_USER,
|
|
1507
|
-
el.point2.coords.usrCoords.slice(1, 3),
|
|
1508
|
-
board
|
|
1509
|
-
);
|
|
1510
1524
|
}
|
|
1511
1525
|
|
|
1512
1526
|
el.elType = "segment";
|
|
@@ -1918,8 +1932,13 @@ JXG.createAxis = function (board, parents, attributes) {
|
|
|
1918
1932
|
JXG.registerElement("axis", JXG.createAxis);
|
|
1919
1933
|
|
|
1920
1934
|
/**
|
|
1921
|
-
* @class With the element tangent the slope of a line, circle, or curve in a certain point can be visualized. A tangent is always constructed
|
|
1922
|
-
* by a
|
|
1935
|
+
* @class With the element tangent the slope of a line, circle, conic, turtle, or curve in a certain point can be visualized. A tangent is always constructed
|
|
1936
|
+
* by a point on a line, circle, or curve and describes the tangent in the point on that line, circle, or curve.
|
|
1937
|
+
* <p>
|
|
1938
|
+
* If the point is not on the object (line, circle, conic, curve, turtle) the output depends on the type of the object.
|
|
1939
|
+
* For conics and circles, the polar line will be constructed. For function graphs,
|
|
1940
|
+
* the tangent of the vertical projection of the point to the function graph is constructed. For all other objects, the tangent
|
|
1941
|
+
* in the orthogonal projection of the point to the object will be constructed.
|
|
1923
1942
|
* @pseudo
|
|
1924
1943
|
* @name Tangent
|
|
1925
1944
|
* @augments JXG.Line
|
|
@@ -1927,6 +1946,7 @@ JXG.registerElement("axis", JXG.createAxis);
|
|
|
1927
1946
|
* @type JXG.Line
|
|
1928
1947
|
* @throws {Exception} If the element cannot be constructed with the given parent objects an exception is thrown.
|
|
1929
1948
|
* @param {Glider} g A glider on a line, circle, or curve.
|
|
1949
|
+
* @param {JXG.GeometryElement} [c] Optional element for which the tangent is constructed
|
|
1930
1950
|
* @example
|
|
1931
1951
|
* // Create a tangent providing a glider on a function graph
|
|
1932
1952
|
* var c1 = board.create('curve', [function(t){return t},function(t){return t*t*t;}]);
|
|
@@ -1944,12 +1964,13 @@ JXG.createTangent = function (board, parents, attributes) {
|
|
|
1944
1964
|
var p, c, j, el, tangent, attr,
|
|
1945
1965
|
getCurveTangentDir;
|
|
1946
1966
|
|
|
1947
|
-
// One argument: glider on line, circle or curve
|
|
1948
1967
|
if (parents.length === 1) {
|
|
1968
|
+
// One argument: glider on line, circle or curve
|
|
1949
1969
|
p = parents[0];
|
|
1950
1970
|
c = p.slideObject;
|
|
1951
|
-
|
|
1971
|
+
|
|
1952
1972
|
} else if (parents.length === 2) {
|
|
1973
|
+
// Two arguments: (point,line|curve|circle|conic) or (line|curve|circle|conic,point).
|
|
1953
1974
|
// In fact, for circles and conics it is the polar
|
|
1954
1975
|
if (Type.isPoint(parents[0])) {
|
|
1955
1976
|
p = parents[0];
|
|
@@ -1964,7 +1985,7 @@ JXG.createTangent = function (board, parents, attributes) {
|
|
|
1964
1985
|
"' and '" +
|
|
1965
1986
|
typeof parents[1] +
|
|
1966
1987
|
"'." +
|
|
1967
|
-
"\nPossible parent types: [glider], [point,line|curve|circle|conic]"
|
|
1988
|
+
"\nPossible parent types: [glider|point], [point,line|curve|circle|conic]"
|
|
1968
1989
|
);
|
|
1969
1990
|
}
|
|
1970
1991
|
} else {
|
|
@@ -1974,7 +1995,7 @@ JXG.createTangent = function (board, parents, attributes) {
|
|
|
1974
1995
|
"' and '" +
|
|
1975
1996
|
typeof parents[1] +
|
|
1976
1997
|
"'." +
|
|
1977
|
-
"\nPossible parent types: [glider], [point,line|curve|circle|conic]"
|
|
1998
|
+
"\nPossible parent types: [glider|point], [point,line|curve|circle|conic]"
|
|
1978
1999
|
);
|
|
1979
2000
|
}
|
|
1980
2001
|
|
|
@@ -1992,17 +2013,22 @@ JXG.createTangent = function (board, parents, attributes) {
|
|
|
1992
2013
|
[
|
|
1993
2014
|
function () {
|
|
1994
2015
|
var g = c.X,
|
|
1995
|
-
f = c.Y
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2016
|
+
f = c.Y,
|
|
2017
|
+
t;
|
|
2018
|
+
|
|
2019
|
+
if (p.type === Const.OBJECT_TYPE_GLIDER) {
|
|
2020
|
+
t = p.position;
|
|
2021
|
+
} else if (Type.evaluate(c.visProp.curvetype) === 'functiongraph') {
|
|
2022
|
+
t = p.X();
|
|
2023
|
+
} else {
|
|
2024
|
+
t = Geometry.projectPointToCurve(p, c, board)[1];
|
|
2025
|
+
}
|
|
2026
|
+
|
|
2027
|
+
return [
|
|
2028
|
+
-p.X() * Numerics.D(f)(t) + p.Y() * Numerics.D(g)(t),
|
|
2029
|
+
Numerics.D(c.Y)(t),
|
|
2030
|
+
-Numerics.D(c.X)(t)
|
|
2031
|
+
];
|
|
2006
2032
|
}
|
|
2007
2033
|
],
|
|
2008
2034
|
attr
|
|
@@ -2070,12 +2096,10 @@ JXG.createTangent = function (board, parents, attributes) {
|
|
|
2070
2096
|
B = points[i + 1].usrCoords;
|
|
2071
2097
|
C = points[i + 2].usrCoords;
|
|
2072
2098
|
D = points[i + 3].usrCoords;
|
|
2073
|
-
dx =
|
|
2074
|
-
(1 - t) * (1 - t) * (B[1] - A[1]) +
|
|
2099
|
+
dx = (1 - t) * (1 - t) * (B[1] - A[1]) +
|
|
2075
2100
|
2 * (1 - t) * t * (C[1] - B[1]) +
|
|
2076
2101
|
t * t * (D[1] - C[1]);
|
|
2077
|
-
dy =
|
|
2078
|
-
(1 - t) * (1 - t) * (B[2] - A[2]) +
|
|
2102
|
+
dy = (1 - t) * (1 - t) * (B[2] - A[2]) +
|
|
2079
2103
|
2 * (1 - t) * t * (C[2] - B[2]) +
|
|
2080
2104
|
t * t * (D[2] - C[2]);
|
|
2081
2105
|
d = Mat.hypot(dx, dy);
|
|
@@ -2092,21 +2116,28 @@ JXG.createTangent = function (board, parents, attributes) {
|
|
|
2092
2116
|
return p2[2] - p1[2];
|
|
2093
2117
|
case 2:
|
|
2094
2118
|
return p1[1] - p2[1];
|
|
2119
|
+
default:
|
|
2120
|
+
return [
|
|
2121
|
+
p1[2] * p2[1] - p1[1] * p2[2],
|
|
2122
|
+
p2[2] - p1[2],
|
|
2123
|
+
p1[1] - p2[1]
|
|
2124
|
+
];
|
|
2095
2125
|
}
|
|
2096
|
-
return 0;
|
|
2097
2126
|
};
|
|
2098
2127
|
|
|
2099
2128
|
tangent = board.create(
|
|
2100
2129
|
"line",
|
|
2101
2130
|
[
|
|
2102
2131
|
function () {
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2132
|
+
var t;
|
|
2133
|
+
|
|
2134
|
+
if (p.type === Const.OBJECT_TYPE_GLIDER) {
|
|
2135
|
+
t = p.position;
|
|
2136
|
+
} else {
|
|
2137
|
+
t = Geometry.projectPointToCurve(p, c, board)[1];
|
|
2138
|
+
}
|
|
2139
|
+
|
|
2140
|
+
return getCurveTangentDir(t, c);
|
|
2110
2141
|
}
|
|
2111
2142
|
],
|
|
2112
2143
|
attr
|
|
@@ -2121,33 +2152,14 @@ JXG.createTangent = function (board, parents, attributes) {
|
|
|
2121
2152
|
"line",
|
|
2122
2153
|
[
|
|
2123
2154
|
function () {
|
|
2124
|
-
var i
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
if (el.type === Const.OBJECT_TYPE_CURVE) {
|
|
2131
|
-
if (i < el.numberPoints) {
|
|
2132
|
-
break;
|
|
2133
|
-
}
|
|
2134
|
-
|
|
2135
|
-
i -= el.numberPoints;
|
|
2136
|
-
}
|
|
2137
|
-
}
|
|
2138
|
-
|
|
2139
|
-
if (i === el.numberPoints - 1) {
|
|
2140
|
-
i--;
|
|
2141
|
-
}
|
|
2142
|
-
|
|
2143
|
-
if (i < 0) {
|
|
2144
|
-
return 1;
|
|
2155
|
+
var i, t;
|
|
2156
|
+
if (p.type === Const.OBJECT_TYPE_GLIDER) {
|
|
2157
|
+
t = p.position;
|
|
2158
|
+
} else {
|
|
2159
|
+
t = Geometry.projectPointToTurtle(p, c, board)[1];
|
|
2145
2160
|
}
|
|
2146
2161
|
|
|
2147
|
-
|
|
2148
|
-
},
|
|
2149
|
-
function () {
|
|
2150
|
-
var i = Math.floor(p.position);
|
|
2162
|
+
i = Math.floor(t);
|
|
2151
2163
|
|
|
2152
2164
|
// run through all curves of this turtle
|
|
2153
2165
|
for (j = 0; j < c.objects.length; j++) {
|
|
@@ -2162,37 +2174,19 @@ JXG.createTangent = function (board, parents, attributes) {
|
|
|
2162
2174
|
}
|
|
2163
2175
|
}
|
|
2164
2176
|
|
|
2165
|
-
if (i === el.numberPoints - 1) {
|
|
2166
|
-
i--;
|
|
2167
|
-
}
|
|
2168
|
-
if (i < 0) {
|
|
2169
|
-
return 0;
|
|
2170
|
-
}
|
|
2171
|
-
|
|
2172
|
-
return el.Y(i + 1) - el.Y(i);
|
|
2173
|
-
},
|
|
2174
|
-
function () {
|
|
2175
|
-
var i = Math.floor(p.position);
|
|
2176
|
-
|
|
2177
|
-
// run through all curves of this turtle
|
|
2178
|
-
for (j = 0; j < c.objects.length; j++) {
|
|
2179
|
-
el = c.objects[j];
|
|
2180
|
-
if (el.type === Const.OBJECT_TYPE_CURVE) {
|
|
2181
|
-
if (i < el.numberPoints) {
|
|
2182
|
-
break;
|
|
2183
|
-
}
|
|
2184
|
-
i -= el.numberPoints;
|
|
2185
|
-
}
|
|
2186
|
-
}
|
|
2187
2177
|
if (i === el.numberPoints - 1) {
|
|
2188
2178
|
i--;
|
|
2189
2179
|
}
|
|
2190
2180
|
|
|
2191
2181
|
if (i < 0) {
|
|
2192
|
-
return 0;
|
|
2182
|
+
return [1, 0, 0];
|
|
2193
2183
|
}
|
|
2194
2184
|
|
|
2195
|
-
return
|
|
2185
|
+
return [
|
|
2186
|
+
el.Y(i) * el.X(i + 1) - el.X(i) * el.Y(i + 1),
|
|
2187
|
+
el.Y(i + 1) - el.Y(i),
|
|
2188
|
+
el.X(i) - el.X(i + 1)
|
|
2189
|
+
];
|
|
2196
2190
|
}
|
|
2197
2191
|
],
|
|
2198
2192
|
attr
|
|
@@ -2211,13 +2205,7 @@ JXG.createTangent = function (board, parents, attributes) {
|
|
|
2211
2205
|
"line",
|
|
2212
2206
|
[
|
|
2213
2207
|
function () {
|
|
2214
|
-
return Mat.matVecMult(c.quadraticform, p.coords.usrCoords)
|
|
2215
|
-
},
|
|
2216
|
-
function () {
|
|
2217
|
-
return Mat.matVecMult(c.quadraticform, p.coords.usrCoords)[1];
|
|
2218
|
-
},
|
|
2219
|
-
function () {
|
|
2220
|
-
return Mat.matVecMult(c.quadraticform, p.coords.usrCoords)[2];
|
|
2208
|
+
return Mat.matVecMult(c.quadraticform, p.coords.usrCoords);
|
|
2221
2209
|
}
|
|
2222
2210
|
],
|
|
2223
2211
|
attr
|
package/src/base/polygon.js
CHANGED
|
@@ -1533,7 +1533,7 @@ JXG.createParallelogram = function (board, parents, attributes) {
|
|
|
1533
1533
|
);
|
|
1534
1534
|
}
|
|
1535
1535
|
|
|
1536
|
-
attr_pp = Type.copyAttributes(attributes, board.options, "parallelogram",
|
|
1536
|
+
attr_pp = Type.copyAttributes(attributes, board.options, "parallelogram", "parallelpoint");
|
|
1537
1537
|
pp = board.create('parallelpoint', points, attr_pp);
|
|
1538
1538
|
attr = Type.copyAttributes(attributes, board.options, "parallelogram");
|
|
1539
1539
|
el = board.create('polygon', [points[0], points[1], pp, points[2]], attr);
|
package/src/base/text.js
CHANGED
|
@@ -1142,7 +1142,8 @@ JXG.extend(
|
|
|
1142
1142
|
getNumberOfConflicts: function (x, y, w, h) {
|
|
1143
1143
|
var count = 0,
|
|
1144
1144
|
i, obj, le,
|
|
1145
|
-
savePointPrecision
|
|
1145
|
+
savePointPrecision,
|
|
1146
|
+
saveHasInnerPoints;
|
|
1146
1147
|
|
|
1147
1148
|
// Set the precision of hasPoint to half the max if label isn't too long
|
|
1148
1149
|
savePointPrecision = this.board.options.precision.hasPoint;
|
|
@@ -1152,6 +1153,8 @@ JXG.extend(
|
|
|
1152
1153
|
// Make it compatible with the objects' visProp.precision attribute
|
|
1153
1154
|
for (i = 0, le = this.board.objectsList.length; i < le; i++) {
|
|
1154
1155
|
obj = this.board.objectsList[i];
|
|
1156
|
+
saveHasInnerPoints = obj.visProp.hasinnerpoints;
|
|
1157
|
+
obj.visProp.hasinnerpoints = false;
|
|
1155
1158
|
if (
|
|
1156
1159
|
obj.visPropCalc.visible &&
|
|
1157
1160
|
obj.elType !== "axis" &&
|
|
@@ -1162,6 +1165,7 @@ JXG.extend(
|
|
|
1162
1165
|
) {
|
|
1163
1166
|
count++;
|
|
1164
1167
|
}
|
|
1168
|
+
obj.visProp.hasinnerpoints = saveHasInnerPoints;
|
|
1165
1169
|
}
|
|
1166
1170
|
this.board.options.precision.hasPoint = savePointPrecision;
|
|
1167
1171
|
|
package/src/element/button.js
CHANGED
|
@@ -52,9 +52,12 @@ var priv = {
|
|
|
52
52
|
/**
|
|
53
53
|
* @class This element is used to provide a constructor for special texts containing a
|
|
54
54
|
* form button element.
|
|
55
|
-
* <p>
|
|
56
55
|
* For this element, the attribute "display" has to have the value 'html' (which is the default).
|
|
57
|
-
*
|
|
56
|
+
*
|
|
57
|
+
* <p><b>Setting a CSS class:</b> The attribute <tt>cssClass</tt> affects the HTML div element that contains the button element. To change the CSS properties of the HTML button element a selector of the form
|
|
58
|
+
* <tt>.mybutton > button { ... }</tt> has to be used. See the example below.
|
|
59
|
+
*
|
|
60
|
+
* <p><b>Access the button element with JavaScript:</b>
|
|
58
61
|
* The underlying HTML button element can be accessed through the sub-object 'rendNodeButton', e.g. to
|
|
59
62
|
* add event listeners.
|
|
60
63
|
*
|
|
@@ -158,15 +161,15 @@ var priv = {
|
|
|
158
161
|
* </script><pre>
|
|
159
162
|
*
|
|
160
163
|
* @example
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
*
|
|
164
|
+
* var i1 = board.create('input', [-3, 4, 'sin(x)', 'f(x)='], {cssStyle: 'width:4em', maxlength: 2});
|
|
165
|
+
* var c1 = board.create('checkbox', [-3, 2, 'label 1'], {});
|
|
166
|
+
* var b1 = board.create('button', [-3, -1, 'Change texts', function () {
|
|
167
|
+
* i1.setText('g(x)');
|
|
168
|
+
* i1.set('cos(x)');
|
|
169
|
+
* c1.setText('label 2');
|
|
170
|
+
* b1.setText('Texts are changed');
|
|
171
|
+
* }],
|
|
172
|
+
* {cssStyle: 'width:200px'});
|
|
170
173
|
*
|
|
171
174
|
* </pre><div id="JXG11cac8ff-2354-47e7-9da4-eb928e53de05" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
172
175
|
* <script type="text/javascript">
|
|
@@ -181,7 +184,54 @@ var priv = {
|
|
|
181
184
|
* c1.setText('label 2');
|
|
182
185
|
* b1.setText('Texts are changed');
|
|
183
186
|
* }],
|
|
184
|
-
* {cssStyle: 'width:
|
|
187
|
+
* {cssStyle: 'width:200px'});
|
|
188
|
+
*
|
|
189
|
+
* })();
|
|
190
|
+
*
|
|
191
|
+
* </script><pre>
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* // Set the CSS class of the button
|
|
195
|
+
*
|
|
196
|
+
* // CSS:
|
|
197
|
+
* <style>
|
|
198
|
+
* .mybutton > button {
|
|
199
|
+
* background-color: #04AA6D;
|
|
200
|
+
* border: none;
|
|
201
|
+
* color: white;
|
|
202
|
+
* padding: 1px 3px;
|
|
203
|
+
* text-align: center;
|
|
204
|
+
* text-decoration: none;
|
|
205
|
+
* display: inline-block;
|
|
206
|
+
* font-size: 16px;
|
|
207
|
+
* }
|
|
208
|
+
* </style>
|
|
209
|
+
*
|
|
210
|
+
* // JavaScript:
|
|
211
|
+
* var button = board.create('button',
|
|
212
|
+
* [1, 4, 'answers', function () {}],
|
|
213
|
+
* {cssClass:'mybutton', highlightCssClass: 'mybutton'});
|
|
214
|
+
*
|
|
215
|
+
* </pre>
|
|
216
|
+
* <style>
|
|
217
|
+
* .mybutton > button {
|
|
218
|
+
* background-color: #04AA6D;
|
|
219
|
+
* border: none;
|
|
220
|
+
* color: white;
|
|
221
|
+
* padding: 1px 3px;
|
|
222
|
+
* text-align: center;
|
|
223
|
+
* text-decoration: none;
|
|
224
|
+
* display: inline-block;
|
|
225
|
+
* font-size: 16px;
|
|
226
|
+
* }
|
|
227
|
+
* </style>
|
|
228
|
+
* <div id="JXG2da6cf73-8c2e-495c-bd31-42de43b71cf8" class="jxgbox" style="width: 300px; height: 300px;"></div>
|
|
229
|
+
* <script type="text/javascript">
|
|
230
|
+
* (function() {
|
|
231
|
+
* var board = JXG.JSXGraph.initBoard('JXG2da6cf73-8c2e-495c-bd31-42de43b71cf8',
|
|
232
|
+
* {boundingbox: [-8, 8, 8,-8], axis: true, showcopyright: false, shownavigation: false});
|
|
233
|
+
* var button = board.create('button', [1, 4, 'answers', function () {
|
|
234
|
+
* }], {cssClass:'mybutton', highlightCssClass: 'mybutton'});
|
|
185
235
|
*
|
|
186
236
|
* })();
|
|
187
237
|
*
|
package/src/element/checkbox.js
CHANGED
|
@@ -54,9 +54,13 @@ var priv = {
|
|
|
54
54
|
/**
|
|
55
55
|
* @class This element is used to provide a constructor for special texts containing a
|
|
56
56
|
* form checkbox element.
|
|
57
|
-
* <p>
|
|
58
57
|
* For this element, the attribute "display" has to have the value 'html' (which is the default).
|
|
59
|
-
*
|
|
58
|
+
*
|
|
59
|
+
* <p><b>Setting a CSS class:</b> The attribute <tt>cssClass</tt> affects the HTML div element that contains the checkbox element. To change the CSS properties of the HTML checkbox element a selector of the form
|
|
60
|
+
* <tt>.mycheck > checkbox { ... }</tt> has to be used. See the analog example for buttons:
|
|
61
|
+
* {@link Button}.
|
|
62
|
+
*
|
|
63
|
+
* <p><b>Access the checkbox element with JavaScript:</b>
|
|
60
64
|
* The underlying HTML checkbox element can be accessed through the sub-object 'rendNodeCheck', e.g. to
|
|
61
65
|
* add event listeners.
|
|
62
66
|
*
|
package/src/element/grid.js
CHANGED
|
@@ -216,10 +216,10 @@ import Const from "../base/constants.js";
|
|
|
216
216
|
* </script><pre>
|
|
217
217
|
*/
|
|
218
218
|
JXG.createGrid = function (board, parents, attributes) {
|
|
219
|
-
|
|
220
|
-
maxLines = 5000
|
|
219
|
+
var eps = Mat.eps, // to avoid rounding errors
|
|
220
|
+
maxLines = 5000, // maximum number of vertical or horizontal grid elements (abort criterion for performance reasons)
|
|
221
221
|
|
|
222
|
-
|
|
222
|
+
majorGrid, // main object which will be returned as grid
|
|
223
223
|
minorGrid, // sub-object
|
|
224
224
|
parentAxes, // {Array} array of user defined axes (allowed length 0, 1 or 2)
|
|
225
225
|
|
|
@@ -913,9 +913,9 @@ JXG.createGrid = function (board, parents, attributes) {
|
|
|
913
913
|
|
|
914
914
|
} else {
|
|
915
915
|
if ((
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
916
|
+
YdisTo0 - minorRadius[1] - majorRadius[1] < eps ||
|
|
917
|
+
YdisFrom0 - minorRadius[1] - majorRadius[1] < eps
|
|
918
|
+
)) {
|
|
919
919
|
// if major grid elements (on 0 or axes) are not existing, minor grid elements have to exist. Otherwise:
|
|
920
920
|
if ((
|
|
921
921
|
majorDrawZeroOrigin ||
|
package/src/element/input.js
CHANGED
|
@@ -59,13 +59,16 @@ var priv = {
|
|
|
59
59
|
/**
|
|
60
60
|
* @class This element is used to provide a constructor for special texts containing a
|
|
61
61
|
* HTML form input element.
|
|
62
|
-
* <p>
|
|
63
|
-
* If the width of element is set with the attribute "cssStyle", the width of the
|
|
64
|
-
* label must be added.
|
|
65
|
-
* <p>
|
|
66
62
|
* For this element, the attribute "display" has to have the value 'html' (which is the default).
|
|
67
|
-
*
|
|
68
|
-
*
|
|
63
|
+
* If the width of element is set with the attribute "cssStyle", the width of the
|
|
64
|
+
* label must be added because cssStyle affects the surrounding div element.
|
|
65
|
+
*
|
|
66
|
+
* <p><b>Setting a CSS class:</b> The attribute <tt>cssClass</tt> affects the HTML div element that contains the input element. To change the CSS properties of the HTML input element a selector of the form
|
|
67
|
+
* <tt>.myinput > input { ... }</tt> has to be used. See the analog example for buttons:
|
|
68
|
+
* {@link Button}.
|
|
69
|
+
*
|
|
70
|
+
* <p><b>Access the input element with JavaScript:</b>
|
|
71
|
+
* The underlying HTML button element can be accessed through the sub-object 'rendNodeInput', e.g. to
|
|
69
72
|
* add event listeners.
|
|
70
73
|
*
|
|
71
74
|
* @pseudo
|
package/src/element/slider.js
CHANGED
|
@@ -254,7 +254,7 @@ JXG.createSlider = function (board, parents, attributes) {
|
|
|
254
254
|
p3.Value = function () {
|
|
255
255
|
var d = this._smax - this._smin,
|
|
256
256
|
ev_sw = Type.evaluate(this.visProp.snapwidth);
|
|
257
|
-
|
|
257
|
+
// snapValues, i, v;
|
|
258
258
|
|
|
259
259
|
// snapValues = Type.evaluate(this.visProp.snapvalues);
|
|
260
260
|
// if (Type.isArray(snapValues)) {
|
|
@@ -354,48 +354,48 @@ JXG.createSlider = function (board, parents, attributes) {
|
|
|
354
354
|
if (withText) {
|
|
355
355
|
// attr = Type.copyAttributes(attributes, board.options, 'slider', 'label');
|
|
356
356
|
t = board.create('text', [
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (sl !== null) {
|
|
376
|
-
n = sl;
|
|
377
|
-
} else if (p3.name && p3.name !== "") {
|
|
378
|
-
n = p3.name + " = ";
|
|
379
|
-
} else {
|
|
380
|
-
n = "";
|
|
381
|
-
}
|
|
357
|
+
function () {
|
|
358
|
+
return (p2.X() - p1.X()) * 0.05 + p2.X();
|
|
359
|
+
},
|
|
360
|
+
function () {
|
|
361
|
+
return (p2.Y() - p1.Y()) * 0.05 + p2.Y();
|
|
362
|
+
},
|
|
363
|
+
function () {
|
|
364
|
+
var n,
|
|
365
|
+
d = Type.evaluate(p3.visProp.digits),
|
|
366
|
+
sl = Type.evaluate(p3.visProp.suffixlabel),
|
|
367
|
+
ul = Type.evaluate(p3.visProp.unitlabel),
|
|
368
|
+
pl = Type.evaluate(p3.visProp.postlabel);
|
|
369
|
+
|
|
370
|
+
if (d === 2 && Type.evaluate(p3.visProp.precision) !== 2) {
|
|
371
|
+
// Backwards compatibility
|
|
372
|
+
d = Type.evaluate(p3.visProp.precision);
|
|
373
|
+
}
|
|
382
374
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
375
|
+
if (sl !== null) {
|
|
376
|
+
n = sl;
|
|
377
|
+
} else if (p3.name && p3.name !== "") {
|
|
378
|
+
n = p3.name + " = ";
|
|
379
|
+
} else {
|
|
380
|
+
n = "";
|
|
381
|
+
}
|
|
388
382
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
383
|
+
if (p3.useLocale()) {
|
|
384
|
+
n += p3.formatNumberLocale(p3.Value(), d);
|
|
385
|
+
} else {
|
|
386
|
+
n += Type.toFixed(p3.Value(), d);
|
|
387
|
+
}
|
|
395
388
|
|
|
396
|
-
|
|
389
|
+
if (ul !== null) {
|
|
390
|
+
n += ul;
|
|
397
391
|
}
|
|
398
|
-
|
|
392
|
+
if (pl !== null) {
|
|
393
|
+
n += pl;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
return n;
|
|
397
|
+
}
|
|
398
|
+
],
|
|
399
399
|
attr.label
|
|
400
400
|
);
|
|
401
401
|
|
|
@@ -527,6 +527,9 @@ JXG.createSlider = function (board, parents, attributes) {
|
|
|
527
527
|
highLine: l2
|
|
528
528
|
};
|
|
529
529
|
p3.inherits.push(p1, p2, l1, l2);
|
|
530
|
+
// Remove inherits to avoid circular inherits.
|
|
531
|
+
l1.inherits = [];
|
|
532
|
+
l2.inherits = [];
|
|
530
533
|
|
|
531
534
|
if (withTicks) {
|
|
532
535
|
ti.dump = false;
|
package/src/jsxgraph.js
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
import JXG from "./jxg.js";
|
|
43
43
|
import Env from "./utils/env.js";
|
|
44
44
|
import Type from "./utils/type.js";
|
|
45
|
-
import Mat from "./math/math.js";
|
|
45
|
+
// import Mat from "./math/math.js";
|
|
46
46
|
import Board from "./base/board.js";
|
|
47
47
|
import FileReader from "./reader/file.js";
|
|
48
48
|
import Options from "./options.js";
|
|
@@ -350,8 +350,10 @@ JXG.JSXGraph = {
|
|
|
350
350
|
// Size of HTML div.
|
|
351
351
|
// If zero, the size is set to a small value to avoid
|
|
352
352
|
// division by zero.
|
|
353
|
-
w = Math.max(parseInt(dimensions.width, 10), Mat.eps);
|
|
354
|
-
h = Math.max(parseInt(dimensions.height, 10), Mat.eps);
|
|
353
|
+
// w = Math.max(parseInt(dimensions.width, 10), Mat.eps);
|
|
354
|
+
// h = Math.max(parseInt(dimensions.height, 10), Mat.eps);
|
|
355
|
+
w = parseInt(dimensions.width, 10);
|
|
356
|
+
h = parseInt(dimensions.height, 10);
|
|
355
357
|
|
|
356
358
|
if (Type.exists(bbox) && attr.keepaspectratio) {
|
|
357
359
|
/*
|