const paintSpeechBubble = (ctx, x, y, width, height, col, borderCol) => {
  ctx.save();
  let rad1;
  let arrowHeight = height / 3;
  height = height - arrowHeight;
  if (height < 1) height = 1;
  if (typeof rad1 == "undefined") rad1 = 5;
  if (rad1 > Math.min(height, width) / 2) rad1 = Math.min(height, width) / 2;
  let halfArrowWidth = Math.min(arrowHeight, width / 2 - rad1);
  ctx.moveTo(x + rad1, y);
  ctx.arcTo(x + width, y, x + width, y + height, rad1);
  ctx.arcTo(x + width, y + height, x, y + height, rad1);
  ctx.lineTo(x + width / 2 + halfArrowWidth, y + height);
  ctx.lineTo(x + width / 2, y + height + arrowHeight);
  ctx.lineTo(x + width / 2 - halfArrowWidth, y + height);
  ctx.arcTo(x, y + height, x, y, rad1);
  ctx.arcTo(x, y, x + width, y, rad1);
  ctx.fillStyle = col;
  ctx.fill();
  ctx.strokeStyle = borderCol || col;
  ctx.stroke();
  ctx.restore();
};

export default paintSpeechBubble;