Skip to content

Commit

Permalink
refactor(geom-tessellate): update imports
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Sep 10, 2021
1 parent a647d4d commit 69abd58
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 79 deletions.
9 changes: 5 additions & 4 deletions packages/geom-tessellate/src/earcut.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { Tessellator } from "@thi.ng/geom-api";
import { pointInTriangle2 } from "@thi.ng/geom-isec";
import { polyArea2 } from "@thi.ng/geom-poly-utils";
import { range } from "@thi.ng/transducers";
import { ReadonlyVec, signedArea2, Vec } from "@thi.ng/vectors";
import { pointInTriangle2 } from "@thi.ng/geom-isec/point";
import { polyArea2 } from "@thi.ng/geom-poly-utils/area";
import { range } from "@thi.ng/transducers/iter/range";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import { signedArea2 } from "@thi.ng/vectors/signed-area";

const snip = (
points: ReadonlyVec[],
Expand Down
19 changes: 9 additions & 10 deletions packages/geom-tessellate/src/edge-split.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { Tessellator } from "@thi.ng/geom-api";
import { centroid } from "@thi.ng/geom-poly-utils";
import {
comp,
mapcat,
partition,
push,
transduce,
wrapSides,
} from "@thi.ng/transducers";
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";
import { centroid } from "@thi.ng/geom-poly-utils/centroid";
import { comp } from "@thi.ng/transducers/func/comp";
import { wrapSides } from "@thi.ng/transducers/iter/wrap-sides";
import { push } from "@thi.ng/transducers/rfn/push";
import { transduce } from "@thi.ng/transducers/transduce";
import { mapcat } from "@thi.ng/transducers/xform/mapcat";
import { partition } from "@thi.ng/transducers/xform/partition";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import { mixN } from "@thi.ng/vectors/mixn";

export const edgeSplit: Tessellator = (points: ReadonlyVec[]) => {
const c = centroid(points);
Expand Down
51 changes: 25 additions & 26 deletions packages/geom-tessellate/src/inset.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
import type { Tessellator } from "@thi.ng/geom-api";
import { centroid } from "@thi.ng/geom-poly-utils";
import {
comp,
map,
partition,
push,
transduce,
wrapSides,
zip,
} from "@thi.ng/transducers";
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";
import { centroid } from "@thi.ng/geom-poly-utils/centroid";
import { comp } from "@thi.ng/transducers/func/comp";
import { wrapSides } from "@thi.ng/transducers/iter/wrap-sides";
import { zip } from "@thi.ng/transducers/iter/zip";
import { push } from "@thi.ng/transducers/rfn/push";
import { transduce } from "@thi.ng/transducers/transduce";
import { map } from "@thi.ng/transducers/xform/map";
import { partition } from "@thi.ng/transducers/xform/partition";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import { mixN } from "@thi.ng/vectors/mixn";

export const tesselInset = (inset = 0.5, keepInterior = false): Tessellator => (
points: ReadonlyVec[]
) => {
const c = centroid(points);
const inner = points.map((p) => mixN([], p, c, inset));
return transduce(
comp(
partition<Vec[]>(2, 1),
map(([[a, b], [c, d]]) => [a, b, d, c])
),
push(),
keepInterior ? [inner] : [],
wrapSides([...zip(points, inner)], 0, 1)
);
};
export const tesselInset =
(inset = 0.5, keepInterior = false): Tessellator =>
(points: ReadonlyVec[]) => {
const c = centroid(points);
const inner = points.map((p) => mixN([], p, c, inset));
return transduce(
comp(
partition<Vec[]>(2, 1),
map(([[a, b], [c, d]]) => [a, b, d, c])
),
push(),
keepInterior ? [inner] : [],
wrapSides([...zip(points, inner)], 0, 1)
);
};
19 changes: 9 additions & 10 deletions packages/geom-tessellate/src/quad-fan.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { Tessellator } from "@thi.ng/geom-api";
import { centroid } from "@thi.ng/geom-poly-utils";
import {
comp,
map,
partition,
push,
transduce,
wrapSides,
} from "@thi.ng/transducers";
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";
import { centroid } from "@thi.ng/geom-poly-utils/centroid";
import { comp } from "@thi.ng/transducers/func/comp";
import { wrapSides } from "@thi.ng/transducers/iter/wrap-sides";
import { push } from "@thi.ng/transducers/rfn/push";
import { transduce } from "@thi.ng/transducers/transduce";
import { map } from "@thi.ng/transducers/xform/map";
import { partition } from "@thi.ng/transducers/xform/partition";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import { mixN } from "@thi.ng/vectors/mixn";

export const quadFan: Tessellator = (points: ReadonlyVec[]) => {
const p = centroid(points);
Expand Down
19 changes: 9 additions & 10 deletions packages/geom-tessellate/src/rim-tris.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import type { Tessellator } from "@thi.ng/geom-api";
import {
comp,
map,
partition,
push,
transduce,
wrapSides,
zip,
} from "@thi.ng/transducers";
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";
import { comp } from "@thi.ng/transducers/func/comp";
import { wrapSides } from "@thi.ng/transducers/iter/wrap-sides";
import { zip } from "@thi.ng/transducers/iter/zip";
import { push } from "@thi.ng/transducers/rfn/push";
import { transduce } from "@thi.ng/transducers/transduce";
import { map } from "@thi.ng/transducers/xform/map";
import { partition } from "@thi.ng/transducers/xform/partition";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";
import { mixN } from "@thi.ng/vectors/mixn";

export const rimTris: Tessellator = (points: ReadonlyVec[]) => {
const edgeCentroids = transduce(
Expand Down
18 changes: 8 additions & 10 deletions packages/geom-tessellate/src/tessellate.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import { isFunction } from "@thi.ng/checks";
import { isFunction } from "@thi.ng/checks/is-function";
import type { Tessellator } from "@thi.ng/geom-api";
import {
last,
mapcat,
push,
reducer,
repeat,
scan,
transduce,
} from "@thi.ng/transducers";
import { repeat } from "@thi.ng/transducers/iter/repeat";
import { reducer } from "@thi.ng/transducers/reduce";
import { last } from "@thi.ng/transducers/rfn/last";
import { push } from "@thi.ng/transducers/rfn/push";
import { transduce } from "@thi.ng/transducers/transduce";
import { mapcat } from "@thi.ng/transducers/xform/mapcat";
import { scan } from "@thi.ng/transducers/xform/scan";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";

export function tessellate(
Expand Down
16 changes: 7 additions & 9 deletions packages/geom-tessellate/src/tri-fan.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import type { Tessellator } from "@thi.ng/geom-api";
import { centroid } from "@thi.ng/geom-poly-utils";
import {
comp,
map,
partition,
push,
transduce,
wrapSides,
} from "@thi.ng/transducers";
import { centroid } from "@thi.ng/geom-poly-utils/centroid";
import { comp } from "@thi.ng/transducers/func/comp";
import { wrapSides } from "@thi.ng/transducers/iter/wrap-sides";
import { push } from "@thi.ng/transducers/rfn/push";
import { transduce } from "@thi.ng/transducers/transduce";
import { map } from "@thi.ng/transducers/xform/map";
import { partition } from "@thi.ng/transducers/xform/partition";
import type { ReadonlyVec, Vec } from "@thi.ng/vectors";

export const triFan: Tessellator = (points: ReadonlyVec[]) => {
Expand Down

0 comments on commit 69abd58

Please sign in to comment.