fourDirections = {
const svg = d3.create("svg").attr("viewBox", [-400, 0, width * 2, height]);
const box = 265;
const bar = box / upperLeftColors.length;
const trapezoid = box / lowerLeftLeftColors.length;
svg
.append("rect")
.attr("x", 0)
.attr("y", 0)
.attr("width", width)
.attr("height", height)
.attr("fill", "#f6efe3");
svg
.append("rect")
.attr("x", 100)
.attr("y", 100)
.attr("width", 600)
.attr("height", 600)
.attr("fill", "black");
svg
.selectAll(".upperLeft")
.data(upperLeftColors)
.enter()
.append("rect")
.attr("x", (d, i) => 100 + (i + 1) * bar)
.attr("y", 100 + bar)
.attr("width", bar)
.attr("height", box)
.style("fill", (d) => randomColorFromArray(upperLeftColors))
.attr("class", "upperLeft");
svg
.selectAll(".upperRight")
.data(upperRightColors)
.enter()
.append("rect")
.attr("x", (d, i) => 100 + box + bar * 2)
.attr("y", (d, i) => 100 + (i + 1) * bar)
.attr("width", box)
.attr("height", bar)
.style("fill", (d) => randomColorFromArray(upperRightColors))
.attr("class", "upperRight");
svg
.selectAll(".lowerLeftLeft")
.data(lowerLeftLeftColors)
.enter()
.append("polyline")
.attr("points", (d, i) => [
[100 + bar, 100 + box + bar * 2],
[100 + bar + trapezoid * (8 - i), 100 + box + bar * 2],
[100 + bar, 100 + box + bar * 2 + trapezoid * (8 - i)]
])
.style("fill", (d) => randomColorFromArray(lowerLeftLeftColors))
.attr("class", "lowerLeftLeft");
svg
.selectAll(".lowerLeftRight")
.data(lowerLeftRightColors)
.enter()
.append("polyline")
.attr("points", (d, i) => [
[100 + bar + box, 100 + box * 2 + bar * 2],
[100 + bar + box, 100 + box + bar * 2 + trapezoid * i],
[100 + bar + trapezoid * i, 100 + box * 2 + bar * 2]
])
.style("fill", (d) => randomColorFromArray(lowerLeftRightColors))
.attr("class", "lowerLeftRight");
svg
.selectAll(".lowerRightLeft")
.data(lowerRightLeftColors)
.enter()
.append("polyline")
.attr("points", (d, i) => [
[100 + box + bar * 2, 100 + box * 2 + bar * 2],
[100 + box + bar * 2, 100 + box + bar * 2 + trapezoid * i],
[100 + box + bar * 2 + trapezoid * (8 - i), 100 + box * 2 + bar * 2]
])
.style("fill", (d) => randomColorFromArray(lowerRightLeftColors))
.attr("class", "lowerRightLeft");
svg
.selectAll(".lowerRightRight")
.data(lowerRightRightColors)
.enter()
.append("polyline")
.attr("points", (d, i) => [
[100 + box * 2 + bar * 2, 100 + box + bar * 2],
[100 + box + bar * 2 + trapezoid * i, 100 + box + bar * 2],
[100 + box * 2 + bar * 2, 100 + box + bar * 2 + trapezoid * (8 - i)]
])
.style("fill", (d) => randomColorFromArray(lowerRightRightColors))
.attr("class", "lowerRightRight");
return svg.node();
}