export const getArrowPath = (
  // 原始容器宽高
  containerWidth: number,
  containerHeight: number,
  // 旋转后容器宽高
  width: number,
  height: number,
  // 线条宽度
  strokeWidth: number
) => {
  let arrowheadWidth = 0, arrowHandleHeight = 0
  if (width > height) {
    arrowheadWidth = height / 2
    arrowHandleHeight = height / 2
  } else {
    arrowheadWidth = width / 2
    arrowHandleHeight = height / 2
  }

  //箭头从左上开始，依次计算各个点坐标 
  const getArrowPath = () => {
    const getOffset = ([x, y]) => {
      return [
        x + (containerWidth - width) / 2,
        y + (containerHeight - height) / 2
      ]
    }

    const p1 = getOffset([strokeWidth / 2, height / 2 - arrowHandleHeight / 2])
    const p2 = getOffset([width - arrowheadWidth, height / 2 - arrowHandleHeight / 2])
    const p3 = getOffset([width - arrowheadWidth, strokeWidth])
    const p4 = getOffset([width - strokeWidth, height / 2])
    const p5 = getOffset([width - arrowheadWidth, height - strokeWidth])
    const p6 = getOffset([width - arrowheadWidth, height / 2 + arrowHandleHeight / 2])
    const p7 = getOffset([strokeWidth / 2, height / 2 + arrowHandleHeight / 2])

    return [p1, p2, p3, p4, p5, p6, p7]
  }

  const [p1, p2, p3, p4, p5, p6, p7] = getArrowPath()
  const arrowPath = `M${p1[0]} ${p1[1]} L${p2[0]} ${p2[1]} L${p3[0]} ${p3[1]}  L${p4[0]} ${p4[1]} L${p5[0]} ${p5[1]} L${p6[0]} ${p6[1]} L${p7[0]} ${p7[1]} Z`
  return arrowPath
}