From 644a478a87e33b8de229e95c3c662c5d5a999cab Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Tue, 18 Jun 2024 16:15:36 +0200 Subject: [PATCH] refactor(geom): minor internal updates --- packages/geom/src/as-cubic.ts | 18 ++++-------------- packages/geom/src/cubic.ts | 14 +++++++------- packages/geom/src/cubic3.ts | 10 +++++----- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/packages/geom/src/as-cubic.ts b/packages/geom/src/as-cubic.ts index 220b46212e..f9adf13fb2 100644 --- a/packages/geom/src/as-cubic.ts +++ b/packages/geom/src/as-cubic.ts @@ -227,22 +227,12 @@ export const asCubic = ( 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)), ], } ) diff --git a/packages/geom/src/cubic.ts b/packages/geom/src/cubic.ts index 162eff6e0d..fd6b8ed4ea 100644 --- a/packages/geom/src/cubic.ts +++ b/packages/geom/src/cubic.ts @@ -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"; @@ -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); diff --git a/packages/geom/src/cubic3.ts b/packages/geom/src/cubic3.ts index b36ee28bbf..80271bff3c 100644 --- a/packages/geom/src/cubic3.ts +++ b/packages/geom/src/cubic3.ts @@ -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"; @@ -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);