From ee8200cbf00cc026d7e2047197c8f55d0b92c09f Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Mon, 4 Nov 2019 15:04:25 +0000 Subject: [PATCH] refactor: update wrapSides/tween call sites in various pkgs --- packages/color/src/cosine-gradients.ts | 6 +++--- packages/geom-subdiv-curve/src/api.ts | 10 +++++----- packages/geom-tessellate/src/edge-split.ts | 4 ++-- packages/geom-tessellate/src/inset.ts | 6 +++--- packages/geom-tessellate/src/quad-fan.ts | 4 ++-- packages/geom-tessellate/src/rim-tris.ts | 6 +++--- packages/geom-tessellate/src/tri-fan.ts | 4 ++-- packages/geom/src/internal/edges.ts | 4 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/color/src/cosine-gradients.ts b/packages/color/src/cosine-gradients.ts index 69cc148018..669228b37e 100644 --- a/packages/color/src/cosine-gradients.ts +++ b/packages/color/src/cosine-gradients.ts @@ -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"; @@ -183,7 +183,7 @@ export const cosineCoeffs = (from: ReadonlyColor, to: ReadonlyColor) => { * ) * ``` * - * @see thi.ng/transducers/iter/interpolate + * @see thi.ng/transducers/iter/tween * * @param n * @param stops @@ -191,4 +191,4 @@ export const cosineCoeffs = (from: ReadonlyColor, to: ReadonlyColor) => { export const multiCosineGradient = ( n: number, ...stops: [number, ReadonlyColor][] -): Color[] => [...interpolate(n, 0, 1, cosineCoeffs, cosineColor, ...stops)]; +): Color[] => [...tween(n, 0, 1, cosineCoeffs, cosineColor, ...stops)]; diff --git a/packages/geom-subdiv-curve/src/api.ts b/packages/geom-subdiv-curve/src/api.ts index 0bbacac2b4..721735b952 100644 --- a/packages/geom-subdiv-curve/src/api.ts +++ b/packages/geom-subdiv-curve/src/api.ts @@ -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"; @@ -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 @@ -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 }; diff --git a/packages/geom-tessellate/src/edge-split.ts b/packages/geom-tessellate/src/edge-split.ts index 1af9b34bd2..8bd4487708 100644 --- a/packages/geom-tessellate/src/edge-split.ts +++ b/packages/geom-tessellate/src/edge-split.ts @@ -6,7 +6,7 @@ import { partition, push, transduce, - wrap + wrapSides } from "@thi.ng/transducers"; import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors"; @@ -21,6 +21,6 @@ export const edgeSplit: Tessellator = (points: ReadonlyVec[]) => { }) ), push(), - wrap(points, 1, false, true) + wrapSides(points, 0, 1) ); }; diff --git a/packages/geom-tessellate/src/inset.ts b/packages/geom-tessellate/src/inset.ts index a47805b00a..f42de07610 100644 --- a/packages/geom-tessellate/src/inset.ts +++ b/packages/geom-tessellate/src/inset.ts @@ -6,8 +6,8 @@ import { partition, push, transduce, - zip, - wrap + wrapSides, + zip } from "@thi.ng/transducers"; import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors"; @@ -20,6 +20,6 @@ export const tesselInset = (inset = 0.5, keepInterior = false): Tessellator => ( comp(partition(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) ); }; diff --git a/packages/geom-tessellate/src/quad-fan.ts b/packages/geom-tessellate/src/quad-fan.ts index 84abdaccad..2d422b1467 100644 --- a/packages/geom-tessellate/src/quad-fan.ts +++ b/packages/geom-tessellate/src/quad-fan.ts @@ -6,7 +6,7 @@ import { partition, push, transduce, - wrap + wrapSides } from "@thi.ng/transducers"; import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors"; @@ -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) ); }; diff --git a/packages/geom-tessellate/src/rim-tris.ts b/packages/geom-tessellate/src/rim-tris.ts index cc07c8b30e..9593111a69 100644 --- a/packages/geom-tessellate/src/rim-tris.ts +++ b/packages/geom-tessellate/src/rim-tris.ts @@ -5,7 +5,7 @@ import { partition, push, transduce, - wrap, + wrapSides, zip } from "@thi.ng/transducers"; import { mixN, ReadonlyVec, Vec } from "@thi.ng/vectors"; @@ -14,12 +14,12 @@ export const rimTris: Tessellator = (points: ReadonlyVec[]) => { const edgeCentroids = transduce( comp(partition(2, 1), map((e) => mixN([], e[0], e[1], 0.5))), push(), - wrap(points, 1, false, true) + wrapSides(points, 0, 1) ); return transduce( comp(partition(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) ); }; diff --git a/packages/geom-tessellate/src/tri-fan.ts b/packages/geom-tessellate/src/tri-fan.ts index a1d132b970..9ca640445b 100644 --- a/packages/geom-tessellate/src/tri-fan.ts +++ b/packages/geom-tessellate/src/tri-fan.ts @@ -6,7 +6,7 @@ import { partition, push, transduce, - wrap + wrapSides } from "@thi.ng/transducers"; import { ReadonlyVec, Vec } from "@thi.ng/vectors"; @@ -15,6 +15,6 @@ export const triFan: Tessellator = (points: ReadonlyVec[]) => { return transduce( comp(partition(2, 1), map(([a, b]) => [a, b, c])), push(), - wrap(points, 1, false, true) + wrapSides(points, 0, 1) ); }; diff --git a/packages/geom/src/internal/edges.ts b/packages/geom/src/internal/edges.ts index ea39aaa5f1..b1e0e5e9be 100644 --- a/packages/geom/src/internal/edges.ts +++ b/packages/geom/src/internal/edges.ts @@ -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, closed = false) => >( - partition(2, 1, closed ? wrap(vertices, 1, false, true) : vertices) + partition(2, 1, closed ? wrapSides(vertices, 0, 1) : vertices) );