Skip to content

Commit

Permalink
docs(lowdisc): add tool script for dot anims
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Apr 14, 2021
1 parent 3ad6672 commit 6703383
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
36 changes: 36 additions & 0 deletions packages/lowdisc/tools/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { cosineGradient, COSINE_GRADIENTS } from "@thi.ng/color";
import { asSvg, circle, svgDoc } from "@thi.ng/geom";
import { setPrecision } from "@thi.ng/hiccup-svg";
import { Z4 } from "@thi.ng/strings";
import { mapIndexed, take } from "@thi.ng/transducers";
import { writeFileSync } from "fs";
import { plasticND } from "../src";

const W = 600;
const R = 0.005;
const NUM_COL = 256;

const grad = cosineGradient(NUM_COL, COSINE_GRADIENTS["blue-magenta-orange"]);

// hiccup-svg output precision
setPrecision(4);

for (let i = 100, j = 0; i < 5000; i += 100, j++) {
writeFileSync(
`export/ld-${Z4(j)}.svg`,
asSvg(
svgDoc(
{
width: W,
height: W,
viewBox: "0 0 1 1",
},
...mapIndexed(
(k, p: number[]) =>
circle(p, R, { fill: grad[k % NUM_COL] }),
take(i, plasticND(2))
)
)
)
);
}
10 changes: 10 additions & 0 deletions packages/lowdisc/tools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "../build",
"module": "commonjs",
"noUnusedLocals": false,
"noUnusedParameters": false
},
"include": ["./**/*.ts", "../src/**/*.ts"]
}

0 comments on commit 6703383

Please sign in to comment.