Skip to content

Commit eab2d18

Browse files
committed
collage
1 parent 2d8db27 commit eab2d18

1 file changed

Lines changed: 59 additions & 1 deletion

File tree

assets/js/collageGrid.js

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,68 @@ function makeCartesian() {
1818
}
1919

2020

21-
let order = getCollageOrder(tk)
21+
let order = getCollageOrder(tk)
2222

2323
console.log(order);
24+
console.log(typeof order)
25+
order.shift()
26+
let glyphs = []
2427

28+
for (let i = 0; i < order.length; i++) {
29+
let type = megaPalettes[order[i]].displayType
30+
31+
if (type === "range") {
32+
33+
let tmarks = Object.keys(megaPalettes[order[i]].encodings.range.marks)
34+
35+
glyphs.push([...tmarks])
36+
37+
}
38+
39+
40+
}
41+
42+
let all = cartesian(glyphs)
43+
console.log(glyphs);
44+
console.log(all);
45+
let test = cartesianProduct(glyphs)
46+
47+
console.log(test);
48+
49+
50+
for (let i = 0; i < test.length; i++) {
51+
52+
let tcan = document.createElement("canvas");
53+
54+
tcan.width = 400;
55+
tcan.height = 400;
56+
let tcon = tcan.getContext("2d");
57+
let base
58+
for (let j = 0; j < order.length; j++) {
59+
60+
let ref = megaPalettes[order[j]].encodings.get(order[j])
61+
62+
}
63+
64+
}
2565
}
2666

2767

68+
const cartesian = (...a) => a.reduce((a, b) => a.flatMap(d => b.map(e => [d, e].flat())));
69+
70+
71+
function cartesianProduct(a) { // a = array of array
72+
var i, j, l, m, a1, o = [];
73+
if (!a || a.length == 0) return a;
74+
75+
a1 = a.splice(0, 1)[0]; // the first array of a
76+
a = cartesianProduct(a);
77+
for (i = 0, l = a1.length; i < l; i++) {
78+
if (a && a.length)
79+
for (j = 0, m = a.length; j < m; j++)
80+
o.push([a1[i]].concat(a[j]));
81+
else
82+
o.push([a1[i]]);
83+
}
84+
return o;
85+
}

0 commit comments

Comments
 (0)