From 67033837b2f1d0341589f6ad4051e3c8e2b0c7e3 Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Wed, 14 Apr 2021 11:04:28 +0100 Subject: [PATCH] docs(lowdisc): add tool script for dot anims --- packages/lowdisc/tools/index.ts | 36 ++++++++++++++++++++++++++++ packages/lowdisc/tools/tsconfig.json | 10 ++++++++ 2 files changed, 46 insertions(+) create mode 100644 packages/lowdisc/tools/index.ts create mode 100644 packages/lowdisc/tools/tsconfig.json diff --git a/packages/lowdisc/tools/index.ts b/packages/lowdisc/tools/index.ts new file mode 100644 index 0000000000..6c9d8e3018 --- /dev/null +++ b/packages/lowdisc/tools/index.ts @@ -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)) + ) + ) + ) + ); +} diff --git a/packages/lowdisc/tools/tsconfig.json b/packages/lowdisc/tools/tsconfig.json new file mode 100644 index 0000000000..9655cbea10 --- /dev/null +++ b/packages/lowdisc/tools/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../tsconfig.json", + "compilerOptions": { + "outDir": "../build", + "module": "commonjs", + "noUnusedLocals": false, + "noUnusedParameters": false + }, + "include": ["./**/*.ts", "../src/**/*.ts"] +}