starStyle = new gridviz.Style({
drawFun: (cells, cg, resolution) => {
for (let cell of cells) {
if (!cell.ind) continue;
const min = d3.min(cells, (c) => +c.ind);
const max = d3.max(cells, (c) => +c.ind);
let t = (cell.ind - min) / (max - min);
t = scale(t);
cg.ctx.fillStyle = d3.interpolateYlOrRd(t);
const starOr_ = random ? 380 * Math.random() : starOr;
const nbBranches_ = random
? 3 + Math.ceil(Math.random() * 8)
: nbBranches;
const sbWidth_ = random ? 0.2 + 0.6 * Math.random() : sbWidth;
const r2 = resolution * 0.5;
const rad = r2 * starSize;
const pi2 = Math.PI * 0.5;
const daRad = (starOr_ * Math.PI) / 180;
for (
let angle = pi2 + daRad;
angle < Math.PI * 2 + pi2 + daRad;
angle += (Math.PI * 2) / nbBranches_
) {
cg.ctx.beginPath();
cg.ctx.moveTo(
cell.x + r2 + rad * Math.cos(angle),
cell.y + r2 + rad * Math.sin(angle)
);
cg.ctx.lineTo(
cell.x + r2 + sbWidth_ * rad * Math.cos(angle + pi2),
cell.y + r2 + sbWidth_ * rad * Math.sin(angle + pi2)
);
cg.ctx.lineTo(
cell.x + r2 + sbWidth_ * rad * Math.cos(angle - pi2),
cell.y + r2 + sbWidth_ * rad * Math.sin(angle - pi2)
);
cg.ctx.fill();
}
}
}
})