mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-08 04:58:11 +08:00
Bezier-rs: Add function to smoothly join bezier curves (#1037)
* Added bezier join * Stylistic changes per review
This commit is contained in:
committed by
Keavon Chambers
parent
8d3daeae78
commit
8bc290fde9
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user