Bezier-rs: Remove unused legacy drawing components and structs (#853)

* Removed unused legacy drawing components

* Removed Point abstraction from frontend code

* Code review fixes

* Helper lambdas to functions

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Rob Nadal
2022-11-18 00:34:52 -08:00
committed by Keavon Chambers
co-authored by Keavon Chambers
parent 2994afa6b8
commit a220bfa759
11 changed files with 47 additions and 660 deletions
+6 -20
View File
@@ -6,17 +6,6 @@
<div v-for="(feature, index) in bezierFeatures" :key="index">
<BezierExamplePane :name="feature.name" :callback="feature.callback" :exampleOptions="feature.exampleOptions" :triggerOnMouseMove="feature.triggerOnMouseMove" />
</div>
<!-- TODO: Remove the below and all associated canvas-related code, then rename `bezierFeatures` to `features` -->
<div v-for="(feature, index) in ([] as any)" :key="index">
<ExamplePane
:template="feature.template"
:templateOptions="feature.templateOptions"
:name="feature.name"
:callback="feature.callback"
:curveDegrees="feature.curveDegrees"
:customPoints="feature.customPoints"
/>
</div>
<h2>Subpaths</h2>
<div v-for="(feature, index) in subpathFeatures" :key="index">
<SubpathExamplePane :name="feature.name" :callback="feature.callback" />
@@ -28,10 +17,9 @@
import { defineComponent } from "vue";
import { WasmBezier } from "@/../wasm/pkg";
import { BezierCurveType, ExampleOptions, Point, WasmBezierInstance, WasmSubpathInstance } from "@/utils/types";
import { BezierCurveType, ExampleOptions, WasmBezierInstance, WasmSubpathInstance } from "@/utils/types";
import BezierExamplePane from "@/components/BezierExamplePane.vue";
import ExamplePane from "@/components/ExamplePane.vue";
import SubpathExamplePane from "@/components/SubpathExamplePane.vue";
const tSliderOptions = {
@@ -61,12 +49,11 @@ export default defineComponent({
{
name: "Bezier Through Points",
callback: (bezier: WasmBezierInstance, options: Record<string, number>): string => {
const points: Point[] = JSON.parse(bezier.get_points());
const formattedPoints: number[][] = points.map((p) => [p.x, p.y]);
const points = JSON.parse(bezier.get_points());
if (Object.values(options).length === 1) {
return WasmBezier.quadratic_through_points(formattedPoints, options.t);
return WasmBezier.quadratic_through_points(points, options.t);
}
return WasmBezier.cubic_through_points(formattedPoints, options.t, options["midpoint separation"]);
return WasmBezier.cubic_through_points(points, options.t, options["midpoint separation"]);
},
exampleOptions: {
[BezierCurveType.Linear]: {
@@ -233,8 +220,8 @@ export default defineComponent({
},
{
name: "Project",
callback: (bezier: WasmBezierInstance, _: Record<string, number>, mouseLocation: Point): string =>
mouseLocation ? bezier.project(mouseLocation.x, mouseLocation.y) : bezier.to_svg(),
callback: (bezier: WasmBezierInstance, _: Record<string, number>, mouseLocation?: [number, number]): string =>
mouseLocation ? bezier.project(mouseLocation[0], mouseLocation[1]) : bezier.to_svg(),
triggerOnMouseMove: true,
},
{
@@ -529,7 +516,6 @@ export default defineComponent({
},
components: {
BezierExamplePane,
ExamplePane,
SubpathExamplePane,
},
});