anim = {
const ctx = d3.select(vis).select('canvas').node().getContext('2d');
ctx.clearRect(0,0,width,height);
dots.forEach(d => {
if (cnt > d.start && cnt < d.end) {
ctx.beginPath();
ctx.fillStyle = d.race == 'white' ? 'teal' : 'orange';
const cur_l_f = d3.easeQuadInOut((cnt - d.start)/(d.end-d.start)) * d.pal.length;
const cur_l_i = Math.floor(cur_l_f);
const last_pt = d.pal.ptAtLen[cur_l_i];
const next_pt = d.pal.ptAtLen[cur_l_i+1] || last_pt;
const t = cur_l_f - cur_l_i;
const cur_pt = {
x: last_pt.x + (next_pt.x - last_pt.x) * t,
y: last_pt.y + (next_pt.y - last_pt.y) * t
};
if (cur_pt) {
ctx.arc(cur_pt.x, cur_pt.y + d.offset, 3, 0,2*Math.PI);
}
ctx.fill();
}
});
return cnt/max_cnt;
}