function draw(mouseEvent = {}) {
const hiddenCanvasColor = rgbColorGenerator();
const colorToPoint = {};
const { offsetX = null, offsetY = null } = mouseEvent;
context.clearRect(0, 0, width, height);
hiddenContext.clearRect(0, 0, width, height);
hiddenContextSelection.clearRect(0, 0, width, height);
points.forEach(point => {
const circle = new Path2D();
circle.arc(point.x, point.y, 10, 0, 2 * Math.PI);
const color = hiddenCanvasColor.next().value;
colorToPoint[color] = point;
hiddenContext.fillStyle = color;
hiddenContext.fill(circle);
hiddenContextSelection.fillStyle = color;
hiddenContextSelection.fill(circle);
if (offsetX && offsetY) {
const circle = new Path2D();
circle.arc(offsetX, offsetY, 5, 0, 2 * Math.PI);
hiddenContextSelection.fillStyle = '#4bf442';
hiddenContextSelection.fill(circle);
}
context.fillStyle = point.color;
context.fill(circle);
});
return colorToPoint;
}