Skip to content

Commit

Permalink
refactor: update wrapSides/tween call sites in various pkgs
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Nov 4, 2019
1 parent c207653 commit ee8200c
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions packages/color/src/cosine-gradients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { IObjectOf } from "@thi.ng/api";
import { partial } from "@thi.ng/compose";
import { clamp01, TAU } from "@thi.ng/math";
import {
interpolate,
map,
normRange,
push,
transduce,
tween,
zip
} from "@thi.ng/transducers";
import { Color, CosGradientSpec, ReadonlyColor } from "./api";
Expand Down Expand Up @@ -183,12 +183,12 @@ export const cosineCoeffs = (from: ReadonlyColor, to: ReadonlyColor) => {
* )
* ```
*
* @see thi.ng/transducers/iter/interpolate
* @see thi.ng/transducers/iter/tween
*
* @param n
* @param stops
*/
export const multiCosineGradient = (
n: number,
...stops: [number, ReadonlyColor][]
): Color[] => [...interpolate(n, 0, 1, cosineCoeffs, cosineColor, ...stops)];
): Color[] => [...tween(n, 0, 1, cosineCoeffs, cosineColor, ...stops)];
10 changes: 5 additions & 5 deletions packages/geom-subdiv-curve/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SubdivKernel } from "@thi.ng/geom-api";
import { wrap } from "@thi.ng/transducers";
import { wrapSides } from "@thi.ng/transducers";
import { mixN, ReadonlyVec } from "@thi.ng/vectors";
import { kernel3 } from "./kernels";

Expand All @@ -15,8 +15,8 @@ const THIRDS = ([a, b]: ReadonlyVec[]) => [
mixN([], a, b, 2 / 3)
];

const wrap2 = (pts: ReadonlyVec[]) => wrap(pts, 1, false, true);
const wrap3 = (pts: ReadonlyVec[]) => wrap(pts, 1, true, true);
const wrap2 = (pts: ReadonlyVec[]) => wrapSides(pts, 0, 1);
const wrap3 = (pts: ReadonlyVec[]) => wrapSides(pts, 1, 1);

/**
* Splits each curve / line segment into halves at midpoint. Version for
Expand Down Expand Up @@ -64,8 +64,8 @@ export const SUBDIV_CHAIKIN_OPEN: SubdivKernel = {
i == 0
? [pts[0], ...CHAIKIN_FIRST(pts)]
: i === n - 3
? [...CHAIKIN_LAST(pts), pts[2]]
: CHAIKIN_MAIN(pts),
? [...CHAIKIN_LAST(pts), pts[2]]
: CHAIKIN_MAIN(pts),
size: 3
};

Expand Down
4 changes: 2 additions & 2 deletions packages/geom-tessellate/src/edge-split.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
partition,
push,
transduce,
wrap
wrapSides
} from "@thi.ng/transducers";
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";

Expand All @@ -21,6 +21,6 @@ export const edgeSplit: Tessellator = (points: ReadonlyVec[]) => {
})
),
push(),
wrap(points, 1, false, true)
wrapSides(points, 0, 1)
);
};
6 changes: 3 additions & 3 deletions packages/geom-tessellate/src/inset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
partition,
push,
transduce,
zip,
wrap
wrapSides,
zip
} from "@thi.ng/transducers";
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";

Expand All @@ -20,6 +20,6 @@ export const tesselInset = (inset = 0.5, keepInterior = false): Tessellator => (
comp(partition<Vec[]>(2, 1), map(([[a, b], [c, d]]) => [a, b, d, c])),
push(),
keepInterior ? [inner] : [],
wrap([...zip(points, inner)], 1, false, true)
wrapSides([...zip(points, inner)], 0, 1)
);
};
4 changes: 2 additions & 2 deletions packages/geom-tessellate/src/quad-fan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
partition,
push,
transduce,
wrap
wrapSides
} from "@thi.ng/transducers";
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";

Expand All @@ -18,6 +18,6 @@ export const quadFan: Tessellator = (points: ReadonlyVec[]) => {
map(([a, b, c]) => [mixN([], a, b, 0.5), b, mixN([], b, c, 0.5), p])
),
push(),
wrap(points, 1, true, true)
wrapSides(points)
);
};
6 changes: 3 additions & 3 deletions packages/geom-tessellate/src/rim-tris.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
partition,
push,
transduce,
wrap,
wrapSides,
zip
} from "@thi.ng/transducers";
import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors";
Expand All @@ -14,12 +14,12 @@ export const rimTris: Tessellator = (points: ReadonlyVec[]) => {
const edgeCentroids = transduce(
comp(partition<Vec>(2, 1), map((e) => mixN([], e[0], e[1], 0.5))),
push<Vec>(),
wrap(points, 1, false, true)
wrapSides(points, 0, 1)
);
return transduce(
comp(partition<Vec[]>(2, 1), map((t) => [t[0][0], t[1][1], t[1][0]])),
push(),
[edgeCentroids],
wrap([...zip(edgeCentroids, points)], 1, true, false)
wrapSides([...zip(edgeCentroids, points)], 1, 0)
);
};
4 changes: 2 additions & 2 deletions packages/geom-tessellate/src/tri-fan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
partition,
push,
transduce,
wrap
wrapSides
} from "@thi.ng/transducers";
import { ReadonlyVec, Vec } from "@thi.ng/vectors";

Expand All @@ -15,6 +15,6 @@ export const triFan: Tessellator = (points: ReadonlyVec[]) => {
return transduce(
comp(partition<Vec>(2, 1), map(([a, b]) => [a, b, c])),
push(),
wrap(points, 1, false, true)
wrapSides(points, 0, 1)
);
};
4 changes: 2 additions & 2 deletions packages/geom/src/internal/edges.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { partition, wrap } from "@thi.ng/transducers";
import { partition, wrapSides } from "@thi.ng/transducers";
import { ReadonlyVec, VecPair } from "@thi.ng/vectors";

export const edgeIterator = (vertices: Iterable<ReadonlyVec>, closed = false) =>
<IterableIterator<VecPair>>(
partition(2, 1, closed ? wrap(vertices, 1, false, true) : vertices)
partition(2, 1, closed ? wrapSides(vertices, 0, 1) : vertices)
);

0 comments on commit ee8200c

Please sign in to comment.