illo = {
var yellow = "#ED0";
var gold = "#EA0";
var orange = "#E62";
var garnet = "#C25";
const TAU = Zdog.TAU;
let isSpinning = anim;
const illo = new Zdog.Illustration({
element: DOM.canvas(width, width * (yCount / xCount)),
dragRotate: true,
zoom: zoom,
onDragStart: function () {
isSpinning = false;
}
});
illo.element.style.backgroundColor = "#FDB";
illo.element.style.cursor = "move";
let arc = new Zdog.Shape({
path: [
{ x: -tileScale / 2, y: -tileScale / 2 },
{
arc: [
{ x: tileScale / 2, y: -tileScale / 2 },
{ x: tileScale / 2, y: tileScale / 2 }
]
},
{ line: { x: -tileScale / 2, y: tileScale / 2 } }
],
closed: true,
stroke: stroke,
color: "#636"
});
let rect = new Zdog.Rect({
width: tileScale,
height: tileScale,
stroke: stroke / 2,
color: "#E62"
});
const modes = [
{ mode: 0, x: -tileScale / 2, y: tileScale / 2, theta: 0 },
{ mode: 1, x: -tileScale / 2, y: -tileScale / 2, theta: TAU / 4 },
{ mode: 2, x: tileScale / 2, y: -tileScale / 2, theta: TAU / 2 },
{ mode: 3, x: tileScale / 2, y: tileScale / 2, theta: (3 * TAU) / 4 }
];
d3.range(yCount).map((y) =>
d3.range(xCount).map((x) => {
const mode = modes[Math.floor(Math.random() * modes.length)];
if (Math.random() < filledPercentage) {
arc.copy({
addTo: illo,
translate: {
x: x * tileScale - (xCount * tileScale) / 2,
y: y * tileScale - (yCount * tileScale) / 2,
z: (Math.random() - 0.5) * zMove
},
rotate: { z: mode.theta },
scale: scale
});
}
})
);
let rotX = 0;
function animate() {
rotX += 0.00001;
if (isSpinning) {
illo.rotate.y += 0.01;
illo.rotate.x += Math.sin(rotX);
}
illo.updateRenderGraph();
requestAnimationFrame(animate);
}
animate();
while (true) {
illo.updateRenderGraph();
yield illo.element;
}
}