mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 05:58:11 +08:00
Implement bezier library's De Casteljau points function (#715)
* pre-rebase * broken wasm * hull lines * update rust lib description * update comments, handle match statement better, pass Point type to vue * cleanup * add linear case * More idiomatic code * Further simplifications to the algorithm and removal of more heap allocations * Rename to de_casteljau_points and use colors for the iterations * Small comment changes * Improve colors Co-authored-by: Jackie Chen <jackiechen73> Co-authored-by: Keavon Chambers <keavon@keavon.com> Co-authored-by: Hannah Li <hannahli2010@gmail.com>
This commit is contained in:
co-authored by
Jackie Chen
Keavon Chambers
Hannah Li
parent
cafa2e61dc
commit
8c888e39c7
@@ -281,6 +281,29 @@ export default defineComponent({
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "De Casteljau Points",
|
||||
callback: (canvas: HTMLCanvasElement, bezier: WasmBezierInstance, options: Record<string, number>): void => {
|
||||
const hullPoints: Point[][] = JSON.parse(bezier.de_casteljau_points(options.t));
|
||||
hullPoints.reverse().forEach((iteration: Point[], iterationIndex) => {
|
||||
const colorLight = `hsl(${90 * iterationIndex}, 100%, 50%)`;
|
||||
|
||||
iteration.forEach((point: Point, index) => {
|
||||
// Skip the anchor and handle points which are already drawn in black
|
||||
if (iterationIndex !== hullPoints.length - 1) {
|
||||
drawPoint(getContextFromCanvas(canvas), point, 4, colorLight);
|
||||
}
|
||||
|
||||
if (index !== 0) {
|
||||
const prevPoint: Point = iteration[index - 1];
|
||||
drawLine(getContextFromCanvas(canvas), point, prevPoint, colorLight);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
template: markRaw(SliderExample),
|
||||
templateOptions: { sliders: [tSliderOptions] },
|
||||
},
|
||||
{
|
||||
name: "Rotate",
|
||||
callback: (canvas: HTMLCanvasElement, bezier: WasmBezierInstance, options: Record<string, number>): void => {
|
||||
|
||||
Reference in New Issue
Block a user