Skip to content

Commit

Permalink
refactor(geom): minor internal updates
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jun 18, 2024
1 parent e978fab commit 644a478
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
18 changes: 4 additions & 14 deletions packages/geom/src/as-cubic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,22 +227,12 @@ export const asCubic = <AsCubicFn>(
break: openCubicFromBreakPoints,
}),

quadratic: ({ points, attribs }: Quadratic, opts) => [
cubicFromQuadratic(
points[0],
points[1],
points[2],
__attribs(opts, attribs)
),
quadratic: ({ points: [a, b, c], attribs }: Quadratic, opts) => [
cubicFromQuadratic(a, b, c, __attribs(opts, attribs)),
],

quadratic3: ({ points, attribs }: Quadratic3, opts) => [
cubicFromQuadratic3(
points[0],
points[1],
points[2],
__attribs(opts, attribs)
),
quadratic3: ({ points: [a, b, c], attribs }: Quadratic3, opts) => [
cubicFromQuadratic3(a, b, c, __attribs(opts, attribs)),
],
}
)
Expand Down
14 changes: 7 additions & 7 deletions packages/geom/src/cubic.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { Attribs } from "./api.js";
import { cubicFromArc as _arc } from "@thi.ng/geom-splines/cubic-arc";
import { cubicFromLine as _line } from "@thi.ng/geom-splines/cubic-line";
import { cubicFromQuadratic as _quad } from "@thi.ng/geom-splines/cubic-quadratic";
import { cubicFromArc as $arc } from "@thi.ng/geom-splines/cubic-arc";
import { cubicFromLine as $line } from "@thi.ng/geom-splines/cubic-line";
import { cubicFromQuadratic as $quad } from "@thi.ng/geom-splines/cubic-quadratic";
import type { Vec } from "@thi.ng/vectors";
import type { Attribs } from "./api.js";
import type { Arc } from "./api/arc.js";
import { Cubic } from "./api/cubic.js";
import { __copyAttribs } from "./internal/copy.js";
Expand All @@ -15,12 +15,12 @@ export function cubic(...args: any[]) {
}

export const cubicFromArc = (arc: Arc) =>
_arc(arc.pos, arc.r, arc.axis, arc.start, arc.end).map(
$arc(arc.pos, arc.r, arc.axis, arc.start, arc.end).map(
(c) => new Cubic(c, __copyAttribs(arc.attribs))
);

export const cubicFromLine = (a: Vec, b: Vec, attribs?: Attribs) =>
new Cubic(_line(a, b), attribs);
new Cubic($line(a, b), attribs);

export const cubicFromQuadratic = (a: Vec, b: Vec, c: Vec, attribs?: Attribs) =>
new Cubic(_quad(a, b, c), attribs);
new Cubic($quad(a, b, c), attribs);
10 changes: 5 additions & 5 deletions packages/geom/src/cubic3.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Attribs } from "./api.js";
import { cubicFromLine as _line } from "@thi.ng/geom-splines/cubic-line";
import { cubicFromQuadratic as _quad } from "@thi.ng/geom-splines/cubic-quadratic";
import { cubicFromLine as $line } from "@thi.ng/geom-splines/cubic-line";
import { cubicFromQuadratic as $quad } from "@thi.ng/geom-splines/cubic-quadratic";
import type { Vec } from "@thi.ng/vectors";
import type { Attribs } from "./api.js";
import { Cubic3 } from "./api/cubic3.js";
import { __pclike } from "./internal/pclike.js";

Expand All @@ -18,11 +18,11 @@ export function cubic3(...args: any[]) {
}

export const cubicFromLine3 = (a: Vec, b: Vec, attribs?: Attribs) =>
new Cubic3(_line(a, b), attribs);
new Cubic3($line(a, b), attribs);

export const cubicFromQuadratic3 = (
a: Vec,
b: Vec,
c: Vec,
attribs?: Attribs
) => new Cubic3(_quad(a, b, c), attribs);
) => new Cubic3($quad(a, b, c), attribs);

0 comments on commit 644a478

Please sign in to comment.