Bezier-rs: Add function to smoothly join bezier curves (#1037)

* Added bezier join

* Stylistic changes per review
This commit is contained in:
Rob Nadal
2023-02-28 18:59:06 -05:00
committed by Keavon Chambers
parent 8d3daeae78
commit 8bc290fde9
3 changed files with 108 additions and 5 deletions
@@ -483,6 +483,56 @@ const bezierFeatures = {
},
chooseTVariant: true,
},
join: {
name: "Join",
callback: (bezier: WasmBezierInstance): string => {
const points = JSON.parse(bezier.get_points());
let examplePoints = [];
if (points.length === 2) {
examplePoints = [
[120, 155],
[40, 155],
];
} else if (points.length === 3) {
examplePoints = [
[40, 150],
[95, 195],
[155, 145],
];
} else {
examplePoints = [
[140, 150],
[85, 110],
[65, 180],
[30, 140],
];
}
return bezier.join(examplePoints);
},
demoOptions: {
Linear: {
customPoints: [
[45, 40],
[130, 90],
],
},
Quadratic: {
customPoints: [
[153, 40],
[40, 20],
[75, 85],
],
},
Cubic: {
customPoints: [
[20, 80],
[40, 20],
[90, 100],
[130, 55],
],
},
},
},
};
export type BezierFeatureKey = keyof typeof bezierFeatures;