function badgeCode(g, context, frameNumber) {
const order = [1, 2, 2, 3, 3, 4, 5, 6, 7, 8][frameNumber - 1];
const hilbertData = {
start: 0,
length: Math.pow(4, order)
};
const canvasSize = Math.min(width, height);
hilbert
.order(order)
.canvasWidth(canvasSize)
.simplifyCurves(false)
.layout(hilbertData);
const gradient = g.append('defs')
.append('linearGradient')
.attr('id', 'hilbert-gradient')
.attr('x1', '41%')
.attr('x2', '59%')
.attr('y1', '0%')
.attr('y2', '100%');
const colorInterpol = d3ScaleChromatic.interpolateSpectral;
const stops = gradient.selectAll('stop').data(d3.range(0, 1, 0.01));
stops.merge(stops.enter())
.append('stop')
.attr('offset', d => `${d * 100}%`)
.style('stop-color', d => colorInterpol(1 - d));
const hilbertCanvas = g.append('g')
.attr('transform', `translate(-${(canvasSize - width) / 2}, ${-canvasSize + height})`)
hilbertCanvas.append('path')
.datum(hilbertData)
.attr('d', d => getHilbertPath(d.pathVertices))
.attr('transform', d => `scale(${d.cellWidth}) translate(${d.startCell[0] +.5}, ${d.startCell[1] +.5})`)
.style('fill', 'none')
.style('stroke', 'url(#hilbert-gradient)')
.style('stroke-width', 0.35)
.style('stroke-linecap', 'square');
context.fillStyle = '#000018';
context.fillRect(0, 0, width, height);
}