function badgeCode(g, ctx, frameNumber) {
ctx.fillStyle = '#000';
ctx.fillRect(0, 0, width, height);
data.forEach((d, i) => {
d.i = i
d.frameIndex = numOfFrames - Math.floor(i/numOfFrames)
})
var s = width*height/count/count
d3j.select(g.node()).appendMany('rect', data)
.translate(d => d)
.at({
width: s,
height: s,
opacity: d => d.frameIndex > frameNumber ? 1 : 0,
fill: d => d.frameIndex % 1000 ? '#f0f' : '#000',
stroke: d => d.frameIndex % 1000 ? '#000' : '#f0f',
})
}