shapesLayer = ({ points, w, h }) => {
const ctx = DOM.context2d(w, h)
const groups = _.groupBy(points, 'color')
ctx.clearRect(0, 0, w, h)
ctx.lineWidth = 0.5
ctx.fillStyle = 'black'
ctx.font = '16px sans-serif'
d3.range(IP_RANGE[0], IP_RANGE[1] + 1).forEach((o, i) => {
const y = i * (CELL_NUM / 256) + MARGIN_TOP;
ctx.fillText(String(o), 100, y + 5);
ctx.beginPath();
ctx.moveTo(100, y);
ctx.lineTo(800, y);
ctx.stroke();
})
ctx.font = '16px sans-serif';
d3.range(Math.floor(CIDR_RANGE[0] / 4),Math.floor((CIDR_RANGE[1])/ 4 + 1)).forEach(cidr => {
ctx.fillText(`${String(cidr*4)}/`, cidr*24*4, 15);
})
_.keys(groups).forEach(color => {
ctx.beginPath()
ctx.shadowColor = null;
ctx.fillStyle = color
ctx.strokeStyle = color
ctx.strokeWidth = 0;
ctx.globalAlpha = 1
groups[color].forEach(function (p) { roundRect({ctx,p}) })
ctx.stroke()
ctx.globalAlpha = 0.3
ctx.fill()
})
return ctx.canvas
}