Skip to content

Commit

Permalink
refactor(geom-tessellate): update to use geom-api types
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jan 23, 2019
1 parent 0964a95 commit f7ad4d3
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/geom-tessellate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"dependencies": {
"@thi.ng/checks": "^2.0.1",
"@thi.ng/geom-api": "^0.0.1",
"@thi.ng/geom-poly-utils": "^0.0.1",
"@thi.ng/transducers": "^3.0.1",
"@thi.ng/vectors": "^2.1.0"
Expand Down
3 changes: 0 additions & 3 deletions packages/geom-tessellate/src/api.ts

This file was deleted.

3 changes: 2 additions & 1 deletion packages/geom-tessellate/src/earcut.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Tessellator } from "@thi.ng/geom-api";
import { pointInTriangle2, polyArea2 } from "@thi.ng/geom-poly-utils";
import { range } from "@thi.ng/transducers";
import { ReadonlyVec, signedArea2, Vec } from "@thi.ng/vectors";
Expand Down Expand Up @@ -30,7 +31,7 @@ const snip = (
*
* @param points
*/
export const earCut2 =
export const earCut2: Tessellator =
(points: ReadonlyVec[]) => {
const tris: Vec[][] = [];
let n = points.length;
Expand Down
3 changes: 2 additions & 1 deletion packages/geom-tessellate/src/edge-split.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Tessellator } from "@thi.ng/geom-api";
import { centroid } from "@thi.ng/geom-poly-utils";
import {
comp,
Expand All @@ -9,7 +10,7 @@ import {
} from "@thi.ng/transducers";
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";

export const edgeSplit =
export const edgeSplit: Tessellator =
(points: ReadonlyVec[]) => {
const c = centroid(points);
return transduce(
Expand Down
1 change: 0 additions & 1 deletion packages/geom-tessellate/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./api";
export * from "./tessellate";

export * from "./earcut";
Expand Down
3 changes: 2 additions & 1 deletion packages/geom-tessellate/src/inset.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Tessellator } from "@thi.ng/geom-api";
import { centroid } from "@thi.ng/geom-poly-utils";
import {
comp,
Expand All @@ -11,7 +12,7 @@ import {
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";

export const tesselInset =
(inset = 0.5, keepInterior = false) =>
(inset = 0.5, keepInterior = false): Tessellator =>
(points: ReadonlyVec[]) => {
const c = centroid(points);
const inner = points.map((p) => mixN([], p, c, inset));
Expand Down
3 changes: 2 additions & 1 deletion packages/geom-tessellate/src/quad-fan.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Tessellator } from "@thi.ng/geom-api";
import { centroid } from "@thi.ng/geom-poly-utils";
import {
comp,
Expand All @@ -9,7 +10,7 @@ import {
} from "@thi.ng/transducers";
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";

export const quadFan =
export const quadFan: Tessellator =
(points: ReadonlyVec[]) => {
const p = centroid(points);
return transduce(
Expand Down
3 changes: 2 additions & 1 deletion packages/geom-tessellate/src/rim-tris.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Tessellator } from "@thi.ng/geom-api";
import {
comp,
map,
Expand All @@ -9,7 +10,7 @@ import {
} from "@thi.ng/transducers";
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";

export const rimTris =
export const rimTris: Tessellator =
(points: ReadonlyVec[]) => {
const edgeCentroids = transduce(
comp(
Expand Down
4 changes: 2 additions & 2 deletions packages/geom-tessellate/src/tessellate.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isFunction } from "@thi.ng/checks";
import { Tessellator } from "@thi.ng/geom-api";
import {
last,
mapcat,
Expand All @@ -9,11 +10,10 @@ import {
transduce
} from "@thi.ng/transducers";
import { ReadonlyVec, Vec } from "@thi.ng/vectors";
import { Tessellator } from "./api";

export function tessellate(points: ReadonlyVec[], tessFn: Tessellator, iter?: number): Vec[][];
export function tessellate(points: ReadonlyVec[], tessFns: Iterable<Tessellator>): Vec[][];
export function tessellate(...args): Vec[][] {
export function tessellate(...args) {
return transduce(
scan(
reducer(
Expand Down
3 changes: 2 additions & 1 deletion packages/geom-tessellate/src/tri-fan.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Tessellator } from "@thi.ng/geom-api";
import { centroid } from "@thi.ng/geom-poly-utils";
import {
comp,
Expand All @@ -9,7 +10,7 @@ import {
} from "@thi.ng/transducers";
import { ReadonlyVec, Vec } from "@thi.ng/vectors";

export const triFan =
export const triFan: Tessellator =
(points: ReadonlyVec[]) => {
const c = centroid(points);
return transduce(
Expand Down

0 comments on commit f7ad4d3

Please sign in to comment.