summaryrefslogtreecommitdiff
path: root/client/lib
diff options
context:
space:
mode:
Diffstat (limited to 'client/lib')
-rw-r--r--client/lib/scales.js73
1 files changed, 73 insertions, 0 deletions
diff --git a/client/lib/scales.js b/client/lib/scales.js
new file mode 100644
index 0000000..87dcb0e
--- /dev/null
+++ b/client/lib/scales.js
@@ -0,0 +1,73 @@
+/**
+ * Scales
+ * @module client/lib/scales.js;
+ */
+
+import "core-js/stable";
+import "regenerator-runtime/runtime";
+
+import {
+ Arithmetic,
+ Collatz,
+ Fibonacci,
+ Geometric,
+ Power,
+ Prime,
+ Triangle,
+} from "../vendor/number-sequences/dist/index.js";
+
+let a, b;
+
+export const scales = [
+ { name: "integer", get: (i, j) => [i + 1, j + 1] },
+ { name: "subharmonic", get: (i, j) => [i + 1, i + j + 2] },
+ { name: "harmonic", get: (i, j) => [i + j + 2, j + 1] },
+ {
+ name: "prime",
+ reset: (x, y, w, h) => {
+ a = Prime().skip(x).take(w).toJS();
+ b = Prime().skip(y).take(h).toJS();
+ },
+ get: (ii, jj, i, j) => [a[i], b[j]],
+ },
+ {
+ name: "arithmetic",
+ reset: (x, y, w, h) => {
+ a = Arithmetic(x + 1, x + 1)
+ .take(w)
+ .toJS();
+ b = Arithmetic(y + 1, y + 1)
+ .take(h)
+ .toJS();
+ console.log(a);
+ },
+ get: (ii, jj, i, j) => [a[i], b[j]],
+ },
+ // {
+ // name: "triangle",
+ // reset: (x, y, w, h) => {
+ // a = Triangle().skip(x).take(w).toJS();
+ // b = Triangle().skip(y).take(h).toJS();
+ // },
+ // get: (ii, jj, i, j) => [a[i], b[j]],
+ // },
+ {
+ name: "collatz",
+ reset: (x, y, w, h) => {
+ a = Collatz(x + 1)
+ .take(w)
+ .toJS();
+ b = Collatz(y + 1)
+ .take(h)
+ .toJS();
+ },
+ get: (ii, jj, i, j) => [a[i], b[j]],
+ },
+ {
+ name: "pythagorean",
+ get: (i, j) =>
+ i < j
+ ? [3 ** (i + 1), 2 ** (j + Math.ceil(Math.max(0, (i * 1.0) / 2)))]
+ : [2 ** (i + Math.ceil(Math.max(0, (j * 1.2) / 2))), 3 ** j],
+ },
+];