diff --git a/packages/core/src/path.js b/packages/core/src/path.js index 2133464918f..d4981828207 100644 --- a/packages/core/src/path.js +++ b/packages/core/src/path.js @@ -1,6 +1,6 @@ import Attributes from './attributes' import Point from './point' -import Bezier from 'bezier-js' +import { Bezier } from 'bezier-js' import { linesIntersect, lineIntersectsCurve, diff --git a/packages/core/src/round.js b/packages/core/src/round.js new file mode 100644 index 00000000000..1f734b3cccb --- /dev/null +++ b/packages/core/src/round.js @@ -0,0 +1,3 @@ +export default function round(value) { + return Math.round(value * 1e2) / 1e2 +} diff --git a/packages/core/src/splitcurve.js b/packages/core/src/splitcurve.js new file mode 100644 index 00000000000..4e9873fbce7 --- /dev/null +++ b/packages/core/src/splitcurve.js @@ -0,0 +1,21 @@ +import Path from './path' + +/** Splits a curve on a point */ +export default function splitCurve(start, cp1, cp2, end, split) { + let [c1, c2] = new Path().move(start).curve(cp1, cp2, end).split(split) + + return [ + { + start: c1.ops[0].to, + cp1: c1.ops[1].cp1, + cp2: c1.ops[1].cp2, + end: c1.ops[1].to + }, + { + start: c2.ops[0].to, + cp1: c2.ops[1].cp1, + cp2: c2.ops[1].cp2, + end: c2.ops[1].to + } + ] +} diff --git a/packages/core/src/utils.js b/packages/core/src/utils.js index dd15e7654e0..4af54480bed 100644 --- a/packages/core/src/utils.js +++ b/packages/core/src/utils.js @@ -1,6 +1,6 @@ import Path from './path' import Point from './point' -import Bezier from 'bezier-js' +import { Bezier } from 'bezier-js' export function capitalize(string) { return string.charAt(0).toUpperCase() + string.slice(1) @@ -349,4 +349,4 @@ export function rad2deg(radians) { } // Export bezier-js so plugins can use it -export { default as Bezier } from 'bezier-js' +export { Bezier }