const rect = function rect(opts) {
  const {
    context,
    px = d => d,
    x,
    y,
    width,
    height,
    fill,
    stroke,
    strokeWidth = 1,
    alpha = 1
  } = opts;
  context.save();
  context.globalAlpha = alpha;
  context.beginPath();
  context.rect(x, y, width, height);
  context.fillStyle = fill;
  context.fill();
  if (stroke) {
    context.strokeStyle = stroke;
    context.lineWidth = px(strokeWidth);
    context.stroke();
  }
  context.restore();
};
export default rect;