const draw = function draw(opts) {
  const {
    context,
    px = d => d,
    draw: drawCallback,
    fill,
    stroke,
    strokeWidth = 1,
    alpha = 1
  } = opts;
  if (!draw) return;
  context.save();
  context.globalAlpha = alpha;
  context.beginPath();
  drawCallback({
    context,
    px
  });
  if (fill) {
    context.fillStyle = fill;
    context.fill();
  }
  if (stroke) {
    context.strokeStyle = stroke;
    context.lineWidth = px(strokeWidth);
    context.stroke();
  }
  context.restore();
};
export default draw;