@jsplumb/util
Advanced tools
Comparing version 5.6.5 to 5.7.0
@@ -849,5 +849,9 @@ 'use strict'; | ||
B: B, | ||
C: A * line[0].x + B * line[0].y | ||
C: fixPrecision(A * line[0].x + B * line[0].y) | ||
}; | ||
} | ||
function fixPrecision(n, digits) { | ||
digits = digits == null ? 3 : digits; | ||
return Math.floor(n * Math.pow(10, digits)) / Math.pow(10, digits); | ||
} | ||
function lineIntersection(l1, l2) { | ||
@@ -861,13 +865,13 @@ var abc1 = toABC(l1), | ||
var candidate = { | ||
x: (abc2.B * abc1.C - abc1.B * abc2.C) / det, | ||
y: (abc1.A * abc2.C - abc2.A * abc1.C) / det | ||
x: Math.round((abc2.B * abc1.C - abc1.B * abc2.C) / det), | ||
y: Math.round((abc1.A * abc2.C - abc2.A * abc1.C) / det) | ||
}, | ||
l1xmin = Math.min(l1[0].x, l1[1].x), | ||
l1xmax = Math.max(l1[0].x, l1[1].x), | ||
l1ymin = Math.min(l1[0].y, l1[1].y), | ||
l1ymax = Math.max(l1[0].y, l1[1].y), | ||
l2xmin = Math.min(l2[0].x, l2[1].x), | ||
l2xmax = Math.max(l2[0].x, l2[1].x), | ||
l2ymin = Math.min(l2[0].y, l2[1].y), | ||
l2ymax = Math.max(l2[0].y, l2[1].y); | ||
l1xmin = Math.floor(Math.min(l1[0].x, l1[1].x)), | ||
l1xmax = Math.round(Math.max(l1[0].x, l1[1].x)), | ||
l1ymin = Math.floor(Math.min(l1[0].y, l1[1].y)), | ||
l1ymax = Math.round(Math.max(l1[0].y, l1[1].y)), | ||
l2xmin = Math.floor(Math.min(l2[0].x, l2[1].x)), | ||
l2xmax = Math.round(Math.max(l2[0].x, l2[1].x)), | ||
l2ymin = Math.floor(Math.min(l2[0].y, l2[1].y)), | ||
l2ymax = Math.round(Math.max(l2[0].y, l2[1].y)); | ||
if (candidate.x >= l1xmin && candidate.x <= l1xmax && candidate.y >= l1ymin && candidate.y <= l1ymax && candidate.x >= l2xmin && candidate.x <= l2xmax && candidate.y >= l2ymin && candidate.y <= l2ymax) { | ||
@@ -988,2 +992,3 @@ return candidate; | ||
exports.findWithFunction = findWithFunction; | ||
exports.fixPrecision = fixPrecision; | ||
exports.forEach = forEach; | ||
@@ -990,0 +995,0 @@ exports.fromArray = fromArray; |
@@ -845,5 +845,9 @@ function filterList(list, value, missingIsFalse) { | ||
B: B, | ||
C: A * line[0].x + B * line[0].y | ||
C: fixPrecision(A * line[0].x + B * line[0].y) | ||
}; | ||
} | ||
function fixPrecision(n, digits) { | ||
digits = digits == null ? 3 : digits; | ||
return Math.floor(n * Math.pow(10, digits)) / Math.pow(10, digits); | ||
} | ||
function lineIntersection(l1, l2) { | ||
@@ -857,13 +861,13 @@ var abc1 = toABC(l1), | ||
var candidate = { | ||
x: (abc2.B * abc1.C - abc1.B * abc2.C) / det, | ||
y: (abc1.A * abc2.C - abc2.A * abc1.C) / det | ||
x: Math.round((abc2.B * abc1.C - abc1.B * abc2.C) / det), | ||
y: Math.round((abc1.A * abc2.C - abc2.A * abc1.C) / det) | ||
}, | ||
l1xmin = Math.min(l1[0].x, l1[1].x), | ||
l1xmax = Math.max(l1[0].x, l1[1].x), | ||
l1ymin = Math.min(l1[0].y, l1[1].y), | ||
l1ymax = Math.max(l1[0].y, l1[1].y), | ||
l2xmin = Math.min(l2[0].x, l2[1].x), | ||
l2xmax = Math.max(l2[0].x, l2[1].x), | ||
l2ymin = Math.min(l2[0].y, l2[1].y), | ||
l2ymax = Math.max(l2[0].y, l2[1].y); | ||
l1xmin = Math.floor(Math.min(l1[0].x, l1[1].x)), | ||
l1xmax = Math.round(Math.max(l1[0].x, l1[1].x)), | ||
l1ymin = Math.floor(Math.min(l1[0].y, l1[1].y)), | ||
l1ymax = Math.round(Math.max(l1[0].y, l1[1].y)), | ||
l2xmin = Math.floor(Math.min(l2[0].x, l2[1].x)), | ||
l2xmax = Math.round(Math.max(l2[0].x, l2[1].x)), | ||
l2ymin = Math.floor(Math.min(l2[0].y, l2[1].y)), | ||
l2ymax = Math.round(Math.max(l2[0].y, l2[1].y)); | ||
if (candidate.x >= l1xmin && candidate.x <= l1xmax && candidate.y >= l1ymin && candidate.y <= l1ymax && candidate.x >= l2xmin && candidate.x <= l2xmax && candidate.y >= l2ymin && candidate.y <= l2ymax) { | ||
@@ -967,2 +971,2 @@ return candidate; | ||
export { EventGenerator, OptimisticEventGenerator, TWO_PI, add, addToDictionary, addToList, addWithFunction, arraysEqual, clone, each, encloses, extend, fastTrim, filterList, filterNull, findAllWithFunction, findWithFunction, forEach, fromArray, functionChain, getAllWithFunction, getFromSetWithFunction, getWithFunction, getsert, gradient, insertSorted, intersects, isAssignableFrom, isBoolean, isDate, isEmpty, isFunction, isNamedFunction, isNumber, isObject, isString, lineIntersection, lineLength, lineRectangleIntersection, log, logEnabled, map, merge, normal, objectsEqual, perpendicularLineTo, pointOnLine, populate, quadrant, remove, removeWithFunction, replace, rotateAnchorOrientation, rotatePoint, setToArray, sgn, snapToGrid, subtract, suggest, theta, uuid, wrap }; | ||
export { EventGenerator, OptimisticEventGenerator, TWO_PI, add, addToDictionary, addToList, addWithFunction, arraysEqual, clone, each, encloses, extend, fastTrim, filterList, filterNull, findAllWithFunction, findWithFunction, fixPrecision, forEach, fromArray, functionChain, getAllWithFunction, getFromSetWithFunction, getWithFunction, getsert, gradient, insertSorted, intersects, isAssignableFrom, isBoolean, isDate, isEmpty, isFunction, isNamedFunction, isNumber, isObject, isString, lineIntersection, lineLength, lineRectangleIntersection, log, logEnabled, map, merge, normal, objectsEqual, perpendicularLineTo, pointOnLine, populate, quadrant, remove, removeWithFunction, replace, rotateAnchorOrientation, rotatePoint, setToArray, sgn, snapToGrid, subtract, suggest, theta, uuid, wrap }; |
@@ -851,5 +851,9 @@ (function (global, factory) { | ||
B: B, | ||
C: A * line[0].x + B * line[0].y | ||
C: fixPrecision(A * line[0].x + B * line[0].y) | ||
}; | ||
} | ||
function fixPrecision(n, digits) { | ||
digits = digits == null ? 3 : digits; | ||
return Math.floor(n * Math.pow(10, digits)) / Math.pow(10, digits); | ||
} | ||
function lineIntersection(l1, l2) { | ||
@@ -863,13 +867,13 @@ var abc1 = toABC(l1), | ||
var candidate = { | ||
x: (abc2.B * abc1.C - abc1.B * abc2.C) / det, | ||
y: (abc1.A * abc2.C - abc2.A * abc1.C) / det | ||
x: Math.round((abc2.B * abc1.C - abc1.B * abc2.C) / det), | ||
y: Math.round((abc1.A * abc2.C - abc2.A * abc1.C) / det) | ||
}, | ||
l1xmin = Math.min(l1[0].x, l1[1].x), | ||
l1xmax = Math.max(l1[0].x, l1[1].x), | ||
l1ymin = Math.min(l1[0].y, l1[1].y), | ||
l1ymax = Math.max(l1[0].y, l1[1].y), | ||
l2xmin = Math.min(l2[0].x, l2[1].x), | ||
l2xmax = Math.max(l2[0].x, l2[1].x), | ||
l2ymin = Math.min(l2[0].y, l2[1].y), | ||
l2ymax = Math.max(l2[0].y, l2[1].y); | ||
l1xmin = Math.floor(Math.min(l1[0].x, l1[1].x)), | ||
l1xmax = Math.round(Math.max(l1[0].x, l1[1].x)), | ||
l1ymin = Math.floor(Math.min(l1[0].y, l1[1].y)), | ||
l1ymax = Math.round(Math.max(l1[0].y, l1[1].y)), | ||
l2xmin = Math.floor(Math.min(l2[0].x, l2[1].x)), | ||
l2xmax = Math.round(Math.max(l2[0].x, l2[1].x)), | ||
l2ymin = Math.floor(Math.min(l2[0].y, l2[1].y)), | ||
l2ymax = Math.round(Math.max(l2[0].y, l2[1].y)); | ||
if (candidate.x >= l1xmin && candidate.x <= l1xmax && candidate.y >= l1ymin && candidate.y <= l1ymax && candidate.x >= l2xmin && candidate.x <= l2xmax && candidate.y >= l2ymin && candidate.y <= l2ymax) { | ||
@@ -990,2 +994,3 @@ return candidate; | ||
exports.findWithFunction = findWithFunction; | ||
exports.fixPrecision = fixPrecision; | ||
exports.forEach = forEach; | ||
@@ -992,0 +997,0 @@ exports.fromArray = fromArray; |
{ | ||
"name": "@jsplumb/util", | ||
"version": "5.6.5", | ||
"version": "5.7.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "js/jsplumb.util.cjs.js", |
@@ -234,2 +234,9 @@ /** | ||
/** | ||
* Trim decimal points from a number. Defaults to 3 decimal points. | ||
* @param n | ||
* @param digits | ||
*/ | ||
export declare function fixPrecision(n: number, digits?: number): number; | ||
/** | ||
* Stand-in for the `forEach` method which is available on modern browsers but not on IE11. | ||
@@ -236,0 +243,0 @@ * @param a |
112959
3709