1
0
Fork 0

chore: Changes required for ES6 version of bezier-js

This commit is contained in:
Joost De Cock 2020-11-04 20:06:19 +01:00
parent 5c014d8143
commit 12692e1a64
4 changed files with 27 additions and 3 deletions

View file

@ -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,

View file

@ -0,0 +1,3 @@
export default function round(value) {
return Math.round(value * 1e2) / 1e2
}

View file

@ -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
}
]
}

View file

@ -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 }