Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

proto-arrows

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proto-arrows - npm Package Compare versions

Comparing version 0.1.0 to 0.1.2

260

dist/index.js

@@ -1,119 +0,11 @@

"use strict";
Object.defineProperty(module.exports, "__esModule", {
value: true
});
Object.defineProperty(module.exports, "getBoxToBoxCurve", {
enumerable: true,
get: function get() {
return $e36d37c870599370$exports.getBoxToBoxCurve;
}
});
Object.defineProperty(module.exports, "getCubicBezierSVGPath", {
enumerable: true,
get: function get() {
return $e36d37c870599370$exports.getCubicBezierSVGPath;
}
});
Object.defineProperty(module.exports, "getCurve", {
enumerable: true,
get: function get() {
return $e36d37c870599370$exports.getCurve;
}
});
Object.defineProperty(module.exports, "interpolateCubicBezier", {
enumerable: true,
get: function get() {
return $e04c30edd61f2bf8$exports.interpolateCubicBezier;
}
});
Object.defineProperty(module.exports, "interpolateCubicBezierAngle", {
enumerable: true,
get: function get() {
return $e04c30edd61f2bf8$exports.interpolateCubicBezierAngle;
}
});
var $e36d37c870599370$exports = {};
"use strict";
Object.defineProperty($e36d37c870599370$exports, "__esModule", {
value: true
});
$e36d37c870599370$exports.getBoxToBoxCurve = $e36d37c870599370$var$getBoxToBoxCurve;
$e36d37c870599370$exports.getCubicBezierSVGPath = $e36d37c870599370$var$getCubicBezierSVGPath;
$e36d37c870599370$exports.getCurve = $e36d37c870599370$var$getCurve;
$e36d37c870599370$exports.getLineCenter = $e36d37c870599370$var$getLineCenter;
var $4ae3635cd3704c0c$exports = {};
"use strict";
Object.defineProperty($4ae3635cd3704c0c$exports, "__esModule", {
value: true
});
$4ae3635cd3704c0c$exports.getBoxBounds = $4ae3635cd3704c0c$var$getBoxBounds;
$4ae3635cd3704c0c$exports.getIdealBoxSides = $4ae3635cd3704c0c$var$getIdealBoxSides;
$4ae3635cd3704c0c$exports.isPointOnLeftOrRightSide = $4ae3635cd3704c0c$var$isPointOnLeftOrRightSide;
function $4ae3635cd3704c0c$var$_createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = $4ae3635cd3704c0c$var$_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function F() {
};
return {
s: F,
n: function n() {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function e(_e) {
throw _e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true, didErr = false, err;
return {
s: function s() {
it = it.call(o);
},
n: function n() {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function e(_e2) {
didErr = true;
err = _e2;
},
f: function f() {
try {
if (!normalCompletion && it["return"] != null) it["return"]();
} finally{
if (didErr) throw err;
}
}
};
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
function $4ae3635cd3704c0c$var$_unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return $4ae3635cd3704c0c$var$_arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return $4ae3635cd3704c0c$var$_arrayLikeToArray(o, minLen);
}
function $4ae3635cd3704c0c$var$_arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
return arr2;
}
/**
* Get a list of points set up at the center
* of every side of the box (left, right, top, bottom)
*/ function $4ae3635cd3704c0c$var$getBoxBounds(box) {
$parcel$export(module.exports, "getBoxToBoxCurve", () => $e36d37c870599370$export$583831dfdc6aa49e);
$parcel$export(module.exports, "getCurve", () => $e36d37c870599370$export$2ed0ba18b91344cd);
$parcel$export(module.exports, "getCubicBezierSVGPath", () => $e36d37c870599370$export$191a6a2cb97e8f9d);
$parcel$export(module.exports, "interpolateCubicBezier", () => $e04c30edd61f2bf8$export$40a3f00fa2073bd4);
$parcel$export(module.exports, "interpolateCubicBezierAngle", () => $e04c30edd61f2bf8$export$9af95b4269585c7a);
function $4ae3635cd3704c0c$export$ceae783a035931a1(box) {
return [

@@ -138,11 +30,6 @@ {

}
/**
* Find the ideal points to draw an edge
* between the two boxes by finding the
* shortest linear distance between the
* two.
*/ function $4ae3635cd3704c0c$var$getIdealBoxSides(startBox, endBox) {
var startPts = $4ae3635cd3704c0c$var$getBoxBounds(startBox);
var endPts = $4ae3635cd3704c0c$var$getBoxBounds(endBox);
var minDistanceSource = [
function $4ae3635cd3704c0c$export$1d2e8002406473be(startBox, endBox) {
const startPts = $4ae3635cd3704c0c$export$ceae783a035931a1(startBox);
const endPts = $4ae3635cd3704c0c$export$ceae783a035931a1(endBox);
let minDistanceSource = [
Infinity,

@@ -154,3 +41,3 @@ {

];
var minDistanceTarget = [
let minDistanceTarget = [
Infinity,

@@ -162,30 +49,12 @@ {

];
var _iterator = $4ae3635cd3704c0c$var$_createForOfIteratorHelper(startPts), _step;
try {
for(_iterator.s(); !(_step = _iterator.n()).done;){
var pointA = _step.value;
var _iterator2 = $4ae3635cd3704c0c$var$_createForOfIteratorHelper(endPts), _step2;
try {
for(_iterator2.s(); !(_step2 = _iterator2.n()).done;){
var pointB = _step2.value;
var distance = Math.hypot(pointA.x - pointB.x, pointA.y - pointB.y);
if (distance < minDistanceSource[0]) minDistanceSource = [
distance,
pointA
];
if (distance < minDistanceTarget[0]) minDistanceTarget = [
distance,
pointB
];
}
} catch (err) {
_iterator2.e(err);
} finally{
_iterator2.f();
}
}
} catch (err) {
_iterator.e(err);
} finally{
_iterator.f();
for (const pointA of startPts)for (const pointB of endPts){
const distance = Math.hypot(pointA.x - pointB.x, pointA.y - pointB.y);
if (distance < minDistanceSource[0]) minDistanceSource = [
distance,
pointA
];
if (distance < minDistanceTarget[0]) minDistanceTarget = [
distance,
pointB
];
}

@@ -197,5 +66,3 @@ return {

}
/**
* Infer if a point is on the left or right side of a box
*/ function $4ae3635cd3704c0c$var$isPointOnLeftOrRightSide(point, box) {
function $4ae3635cd3704c0c$export$4a1768cdd491cbf1(point, box) {
return point.x === box.x || point.x === box.x + box.w;

@@ -205,6 +72,3 @@ }

/**
* Find the center of two points using rudimentary
* linear interpolation.
*/ function $e36d37c870599370$var$getLineCenter(pointA, pointB) {
function $e36d37c870599370$export$555f963a5b620001(pointA, pointB) {
return {

@@ -215,19 +79,13 @@ x: (pointA.x + pointB.x) / 2,

}
/**
* Given a cubic bezier curve, produce its corresponding
* SVG path string.
*/ function $e36d37c870599370$var$getCubicBezierSVGPath(bezier) {
var start = bezier.start, control1 = bezier.control1, control2 = bezier.control2, end = bezier.end;
function $e36d37c870599370$export$191a6a2cb97e8f9d(bezier) {
const { start: start , control1: control1 , control2: control2 , end: end } = bezier;
return [
"M".concat(start.x, ",").concat(start.y),
"C".concat(control1.x, ",").concat(control1.y, " ").concat(control2.x, ",").concat(control2.y),
"".concat(end.x, ",").concat(end.y)
`M${start.x},${start.y}`,
`C${control1.x},${control1.y} ${control2.x},${control2.y}`,
`${end.x},${end.y}`
].join(' ');
}
/**
* Given two points, produce a cubic bezier curve that
* links them.
*/ function $e36d37c870599370$var$getCurve(start, end, options) {
var center = $e36d37c870599370$var$getLineCenter(start, end);
var controlPoints = options !== null && options !== void 0 && options.flip ? [
function $e36d37c870599370$export$2ed0ba18b91344cd(start, end, options) {
const center = $e36d37c870599370$export$555f963a5b620001(start, end);
const controlPoints = options?.flip ? [
{

@@ -258,8 +116,5 @@ x: center.x,

}
/**
* Given two boxes, produce a cubic bezier curve that
* links them.
*/ function $e36d37c870599370$var$getBoxToBoxCurve(startBox, endBox) {
var _getIdealBoxSides = (0, $4ae3635cd3704c0c$exports.getIdealBoxSides)(startBox, endBox), startPoint = _getIdealBoxSides.startPoint, endPoint = _getIdealBoxSides.endPoint;
return $e36d37c870599370$var$getCurve(startPoint, endPoint, {
function $e36d37c870599370$export$583831dfdc6aa49e(startBox, endBox) {
const { startPoint: startPoint , endPoint: endPoint } = $4ae3635cd3704c0c$export$1d2e8002406473be(startBox, endBox);
return $e36d37c870599370$export$2ed0ba18b91344cd(startPoint, endPoint, {
// Flip the curve if the `startPoint` is on the left/right

@@ -270,3 +125,3 @@ // side of the `startBox` AND the `endPoint` is on the

// In the future we'll make this an option.
flip: (0, $4ae3635cd3704c0c$exports.isPointOnLeftOrRightSide)(startPoint, startBox) && (0, $4ae3635cd3704c0c$exports.isPointOnLeftOrRightSide)(endPoint, endBox)
flip: $4ae3635cd3704c0c$export$4a1768cdd491cbf1(startPoint, startBox) && $4ae3635cd3704c0c$export$4a1768cdd491cbf1(endPoint, endBox)
});

@@ -276,21 +131,3 @@ }

var $e04c30edd61f2bf8$exports = {};
"use strict";
Object.defineProperty($e04c30edd61f2bf8$exports, "__esModule", {
value: true
});
$e04c30edd61f2bf8$exports.interpolateCubicBezier = $e04c30edd61f2bf8$var$interpolateCubicBezier;
$e04c30edd61f2bf8$exports.interpolateCubicBezierAngle = $e04c30edd61f2bf8$var$interpolateCubicBezierAngle;
/**
* Given the definition of a cubic bezier: a start point, two control points,
* and end point, get the point at a given time `t` (where `0 <= t <= 1`).
*
* For example, at t = 0, this function returns the point at the start of the
* curve, at t = 0.5, it returns the point midway through the curve and at
* t = 1 it returns the point at the end of the curve.
*
* B(t) = (1 - t)^3P0 + 3(1 - t)^2tP1 + 3(1 - t)t^2P2 + t^3P3
* Adapted from https://github.com/pbeshai/vis-utils
*/ function $e04c30edd61f2bf8$var$interpolateCubicBezier(_ref, t) {
var start = _ref.start, control1 = _ref.control1, control2 = _ref.control2, end = _ref.end;
function $e04c30edd61f2bf8$export$40a3f00fa2073bd4({ start: start , control1: control1 , control2: control2 , end: end }, t) {
/**

@@ -306,16 +143,3 @@ * Get the point on the curve at a given t,

}
/**
* Given the definition of a cubic bezier: a start point, two control points,
* and end point, get the angle at a given time `t` (where `0 <= t <= 1`).
*
* For example, at t = 0, this function returns the angle at the start
* point, at t = 0.5, it returns the angle midway through the curve and at
* t = 1 it returns the angle at the end of the curve (useful for things like
* arrowheads). The angles are in degrees.
*
* B'(t) = 3(1- t)^2(P1 - P0) + 6(1 - t)t(P2 - P1) + 3t^2(P3 - P2)
*
* Adapted from https://github.com/pbeshai/vis-utils
*/ function $e04c30edd61f2bf8$var$interpolateCubicBezierAngle(_ref2, t) {
var start = _ref2.start, control1 = _ref2.control1, control2 = _ref2.control2, end = _ref2.end;
function $e04c30edd61f2bf8$export$9af95b4269585c7a({ start: start , control1: control1 , control2: control2 , end: end }, t) {
/**

@@ -326,4 +150,4 @@ * Get the angle of the point on the curve at a given t,

* 0 is the start point, 1 is the end point.
*/ var tangentX = 3 * Math.pow(1 - t, 2) * (control1.x - start.x) + 6 * (1 - t) * t * (control2.x - control1.x) + 3 * Math.pow(t, 2) * (end.x - control2.x);
var tangentY = 3 * Math.pow(1 - t, 2) * (control1.y - start.y) + 6 * (1 - t) * t * (control2.y - control1.y) + 3 * Math.pow(t, 2) * (end.y - control2.y);
*/ const tangentX = 3 * Math.pow(1 - t, 2) * (control1.x - start.x) + 6 * (1 - t) * t * (control2.x - control1.x) + 3 * Math.pow(t, 2) * (end.x - control2.x);
const tangentY = 3 * Math.pow(1 - t, 2) * (control1.y - start.y) + 6 * (1 - t) * t * (control2.y - control1.y) + 3 * Math.pow(t, 2) * (end.y - control2.y);
return Math.atan2(tangentY, tangentX) * (180 / Math.PI);

@@ -330,0 +154,0 @@ }

@@ -1,120 +0,2 @@

var $149c1bd638913645$exports = {};
"use strict";
Object.defineProperty($149c1bd638913645$exports, "__esModule", {
value: true
});
Object.defineProperty($149c1bd638913645$exports, "getBoxToBoxCurve", {
enumerable: true,
get: function get() {
return $a616f5ce02773612$exports.getBoxToBoxCurve;
}
});
Object.defineProperty($149c1bd638913645$exports, "getCubicBezierSVGPath", {
enumerable: true,
get: function get() {
return $a616f5ce02773612$exports.getCubicBezierSVGPath;
}
});
Object.defineProperty($149c1bd638913645$exports, "getCurve", {
enumerable: true,
get: function get() {
return $a616f5ce02773612$exports.getCurve;
}
});
Object.defineProperty($149c1bd638913645$exports, "interpolateCubicBezier", {
enumerable: true,
get: function get() {
return $1c7872e4c4047182$exports.interpolateCubicBezier;
}
});
Object.defineProperty($149c1bd638913645$exports, "interpolateCubicBezierAngle", {
enumerable: true,
get: function get() {
return $1c7872e4c4047182$exports.interpolateCubicBezierAngle;
}
});
var $a616f5ce02773612$exports = {};
"use strict";
Object.defineProperty($a616f5ce02773612$exports, "__esModule", {
value: true
});
$a616f5ce02773612$exports.getBoxToBoxCurve = $a616f5ce02773612$var$getBoxToBoxCurve;
$a616f5ce02773612$exports.getCubicBezierSVGPath = $a616f5ce02773612$var$getCubicBezierSVGPath;
$a616f5ce02773612$exports.getCurve = $a616f5ce02773612$var$getCurve;
$a616f5ce02773612$exports.getLineCenter = $a616f5ce02773612$var$getLineCenter;
var $8877e354ea3c846d$exports = {};
"use strict";
Object.defineProperty($8877e354ea3c846d$exports, "__esModule", {
value: true
});
$8877e354ea3c846d$exports.getBoxBounds = $8877e354ea3c846d$var$getBoxBounds;
$8877e354ea3c846d$exports.getIdealBoxSides = $8877e354ea3c846d$var$getIdealBoxSides;
$8877e354ea3c846d$exports.isPointOnLeftOrRightSide = $8877e354ea3c846d$var$isPointOnLeftOrRightSide;
function $8877e354ea3c846d$var$_createForOfIteratorHelper(o, allowArrayLike) {
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
if (!it) {
if (Array.isArray(o) || (it = $8877e354ea3c846d$var$_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function F() {
};
return {
s: F,
n: function n() {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function e(_e) {
throw _e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true, didErr = false, err;
return {
s: function s() {
it = it.call(o);
},
n: function n() {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function e(_e2) {
didErr = true;
err = _e2;
},
f: function f() {
try {
if (!normalCompletion && it["return"] != null) it["return"]();
} finally{
if (didErr) throw err;
}
}
};
}
function $8877e354ea3c846d$var$_unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return $8877e354ea3c846d$var$_arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return $8877e354ea3c846d$var$_arrayLikeToArray(o, minLen);
}
function $8877e354ea3c846d$var$_arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
return arr2;
}
/**
* Get a list of points set up at the center
* of every side of the box (left, right, top, bottom)
*/ function $8877e354ea3c846d$var$getBoxBounds(box) {
function $8877e354ea3c846d$export$ceae783a035931a1(box) {
return [

@@ -139,11 +21,6 @@ {

}
/**
* Find the ideal points to draw an edge
* between the two boxes by finding the
* shortest linear distance between the
* two.
*/ function $8877e354ea3c846d$var$getIdealBoxSides(startBox, endBox) {
var startPts = $8877e354ea3c846d$var$getBoxBounds(startBox);
var endPts = $8877e354ea3c846d$var$getBoxBounds(endBox);
var minDistanceSource = [
function $8877e354ea3c846d$export$1d2e8002406473be(startBox, endBox) {
const startPts = $8877e354ea3c846d$export$ceae783a035931a1(startBox);
const endPts = $8877e354ea3c846d$export$ceae783a035931a1(endBox);
let minDistanceSource = [
Infinity,

@@ -155,3 +32,3 @@ {

];
var minDistanceTarget = [
let minDistanceTarget = [
Infinity,

@@ -163,30 +40,12 @@ {

];
var _iterator = $8877e354ea3c846d$var$_createForOfIteratorHelper(startPts), _step;
try {
for(_iterator.s(); !(_step = _iterator.n()).done;){
var pointA = _step.value;
var _iterator2 = $8877e354ea3c846d$var$_createForOfIteratorHelper(endPts), _step2;
try {
for(_iterator2.s(); !(_step2 = _iterator2.n()).done;){
var pointB = _step2.value;
var distance = Math.hypot(pointA.x - pointB.x, pointA.y - pointB.y);
if (distance < minDistanceSource[0]) minDistanceSource = [
distance,
pointA
];
if (distance < minDistanceTarget[0]) minDistanceTarget = [
distance,
pointB
];
}
} catch (err) {
_iterator2.e(err);
} finally{
_iterator2.f();
}
}
} catch (err) {
_iterator.e(err);
} finally{
_iterator.f();
for (const pointA of startPts)for (const pointB of endPts){
const distance = Math.hypot(pointA.x - pointB.x, pointA.y - pointB.y);
if (distance < minDistanceSource[0]) minDistanceSource = [
distance,
pointA
];
if (distance < minDistanceTarget[0]) minDistanceTarget = [
distance,
pointB
];
}

@@ -198,5 +57,3 @@ return {

}
/**
* Infer if a point is on the left or right side of a box
*/ function $8877e354ea3c846d$var$isPointOnLeftOrRightSide(point, box) {
function $8877e354ea3c846d$export$4a1768cdd491cbf1(point, box) {
return point.x === box.x || point.x === box.x + box.w;

@@ -206,6 +63,3 @@ }

/**
* Find the center of two points using rudimentary
* linear interpolation.
*/ function $a616f5ce02773612$var$getLineCenter(pointA, pointB) {
function $a616f5ce02773612$export$555f963a5b620001(pointA, pointB) {
return {

@@ -216,19 +70,13 @@ x: (pointA.x + pointB.x) / 2,

}
/**
* Given a cubic bezier curve, produce its corresponding
* SVG path string.
*/ function $a616f5ce02773612$var$getCubicBezierSVGPath(bezier) {
var start = bezier.start, control1 = bezier.control1, control2 = bezier.control2, end = bezier.end;
function $a616f5ce02773612$export$191a6a2cb97e8f9d(bezier) {
const { start: start , control1: control1 , control2: control2 , end: end } = bezier;
return [
"M".concat(start.x, ",").concat(start.y),
"C".concat(control1.x, ",").concat(control1.y, " ").concat(control2.x, ",").concat(control2.y),
"".concat(end.x, ",").concat(end.y)
`M${start.x},${start.y}`,
`C${control1.x},${control1.y} ${control2.x},${control2.y}`,
`${end.x},${end.y}`
].join(' ');
}
/**
* Given two points, produce a cubic bezier curve that
* links them.
*/ function $a616f5ce02773612$var$getCurve(start, end, options) {
var center = $a616f5ce02773612$var$getLineCenter(start, end);
var controlPoints = options !== null && options !== void 0 && options.flip ? [
function $a616f5ce02773612$export$2ed0ba18b91344cd(start, end, options) {
const center = $a616f5ce02773612$export$555f963a5b620001(start, end);
const controlPoints = options?.flip ? [
{

@@ -259,8 +107,5 @@ x: center.x,

}
/**
* Given two boxes, produce a cubic bezier curve that
* links them.
*/ function $a616f5ce02773612$var$getBoxToBoxCurve(startBox, endBox) {
var _getIdealBoxSides = (0, $8877e354ea3c846d$exports.getIdealBoxSides)(startBox, endBox), startPoint = _getIdealBoxSides.startPoint, endPoint = _getIdealBoxSides.endPoint;
return $a616f5ce02773612$var$getCurve(startPoint, endPoint, {
function $a616f5ce02773612$export$583831dfdc6aa49e(startBox, endBox) {
const { startPoint: startPoint , endPoint: endPoint } = $8877e354ea3c846d$export$1d2e8002406473be(startBox, endBox);
return $a616f5ce02773612$export$2ed0ba18b91344cd(startPoint, endPoint, {
// Flip the curve if the `startPoint` is on the left/right

@@ -271,3 +116,3 @@ // side of the `startBox` AND the `endPoint` is on the

// In the future we'll make this an option.
flip: (0, $8877e354ea3c846d$exports.isPointOnLeftOrRightSide)(startPoint, startBox) && (0, $8877e354ea3c846d$exports.isPointOnLeftOrRightSide)(endPoint, endBox)
flip: $8877e354ea3c846d$export$4a1768cdd491cbf1(startPoint, startBox) && $8877e354ea3c846d$export$4a1768cdd491cbf1(endPoint, endBox)
});

@@ -277,21 +122,3 @@ }

var $1c7872e4c4047182$exports = {};
"use strict";
Object.defineProperty($1c7872e4c4047182$exports, "__esModule", {
value: true
});
$1c7872e4c4047182$exports.interpolateCubicBezier = $1c7872e4c4047182$var$interpolateCubicBezier;
$1c7872e4c4047182$exports.interpolateCubicBezierAngle = $1c7872e4c4047182$var$interpolateCubicBezierAngle;
/**
* Given the definition of a cubic bezier: a start point, two control points,
* and end point, get the point at a given time `t` (where `0 <= t <= 1`).
*
* For example, at t = 0, this function returns the point at the start of the
* curve, at t = 0.5, it returns the point midway through the curve and at
* t = 1 it returns the point at the end of the curve.
*
* B(t) = (1 - t)^3P0 + 3(1 - t)^2tP1 + 3(1 - t)t^2P2 + t^3P3
* Adapted from https://github.com/pbeshai/vis-utils
*/ function $1c7872e4c4047182$var$interpolateCubicBezier(_ref, t) {
var start = _ref.start, control1 = _ref.control1, control2 = _ref.control2, end = _ref.end;
function $1c7872e4c4047182$export$40a3f00fa2073bd4({ start: start , control1: control1 , control2: control2 , end: end }, t) {
/**

@@ -307,16 +134,3 @@ * Get the point on the curve at a given t,

}
/**
* Given the definition of a cubic bezier: a start point, two control points,
* and end point, get the angle at a given time `t` (where `0 <= t <= 1`).
*
* For example, at t = 0, this function returns the angle at the start
* point, at t = 0.5, it returns the angle midway through the curve and at
* t = 1 it returns the angle at the end of the curve (useful for things like
* arrowheads). The angles are in degrees.
*
* B'(t) = 3(1- t)^2(P1 - P0) + 6(1 - t)t(P2 - P1) + 3t^2(P3 - P2)
*
* Adapted from https://github.com/pbeshai/vis-utils
*/ function $1c7872e4c4047182$var$interpolateCubicBezierAngle(_ref2, t) {
var start = _ref2.start, control1 = _ref2.control1, control2 = _ref2.control2, end = _ref2.end;
function $1c7872e4c4047182$export$9af95b4269585c7a({ start: start , control1: control1 , control2: control2 , end: end }, t) {
/**

@@ -327,4 +141,4 @@ * Get the angle of the point on the curve at a given t,

* 0 is the start point, 1 is the end point.
*/ var tangentX = 3 * Math.pow(1 - t, 2) * (control1.x - start.x) + 6 * (1 - t) * t * (control2.x - control1.x) + 3 * Math.pow(t, 2) * (end.x - control2.x);
var tangentY = 3 * Math.pow(1 - t, 2) * (control1.y - start.y) + 6 * (1 - t) * t * (control2.y - control1.y) + 3 * Math.pow(t, 2) * (end.y - control2.y);
*/ const tangentX = 3 * Math.pow(1 - t, 2) * (control1.x - start.x) + 6 * (1 - t) * t * (control2.x - control1.x) + 3 * Math.pow(t, 2) * (end.x - control2.x);
const tangentY = 3 * Math.pow(1 - t, 2) * (control1.y - start.y) + 6 * (1 - t) * t * (control2.y - control1.y) + 3 * Math.pow(t, 2) * (end.y - control2.y);
return Math.atan2(tangentY, tangentX) * (180 / Math.PI);

@@ -336,3 +150,3 @@ }

export {$149c1bd638913645$exports as default};
export {$a616f5ce02773612$export$583831dfdc6aa49e as getBoxToBoxCurve, $a616f5ce02773612$export$2ed0ba18b91344cd as getCurve, $a616f5ce02773612$export$191a6a2cb97e8f9d as getCubicBezierSVGPath, $1c7872e4c4047182$export$40a3f00fa2073bd4 as interpolateCubicBezier, $1c7872e4c4047182$export$9af95b4269585c7a as interpolateCubicBezierAngle};
//# sourceMappingURL=module.js.map

2

package.json
{
"name": "proto-arrows",
"version": "0.1.0",
"version": "0.1.2",
"description": "Utility functions for drawing beautiful arrows using cubic bezier paths",

@@ -5,0 +5,0 @@ "source": "src/index.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc