Skip to content

Commit

Permalink
refactor(examples): minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Nov 28, 2019
1 parent 74d68e5 commit b5f5bc2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
5 changes: 2 additions & 3 deletions examples/mandelbrot/src/gradient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { partial } from "@thi.ng/compose/partial";
import { TAU } from "@thi.ng/math/api";
import { clamp01 } from "@thi.ng/math/interval";
import { partial } from "@thi.ng/compose";
import { clamp01, TAU } from "@thi.ng/math";
import {
comp,
map,
Expand Down
2 changes: 1 addition & 1 deletion examples/mandelbrot/src/worker.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fit01 } from "@thi.ng/math/fit";
import { fit01 } from "@thi.ng/math";
import { GRADIENTS } from "./gradient";

// host message listener & responder
Expand Down
20 changes: 16 additions & 4 deletions examples/poly-spline/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const slider = (
...attribs
}
],
stream.deref().toFixed(1)
stream.deref()!.toFixed(1)
];

// main app component / stream transformer
Expand All @@ -90,12 +90,19 @@ const app = (
});
// visualize control points as circles
const controlPoints = iterator(
comp(mapcat((x) => x.points), map((p) => circle(p, 0.75))),
comp(
mapcat((x) => x.points),
map((p) => circle(p, 0.75))
),
cubics
);
// visualize control point handles
const handles = iterator(
comp(mapcat((x) => x.points), partition(2), map(line)),
comp(
mapcat((x) => x.points),
partition(2),
map(line)
),
cubics
);
return [
Expand Down Expand Up @@ -174,7 +181,12 @@ const scale = stream<number>();
const uniScale = stream<number>();

// re-usable transducer implementing a toggle switch
const toggle = scan(reducer(() => true, (acc) => !acc));
const toggle = scan(
reducer(
() => true,
(acc) => !acc
)
);

// main stream combinator
const main = sync<any, any>({
Expand Down

0 comments on commit b5f5bc2

Please sign in to comment.