code: function shapeBox(shape) {
    let minX = shape[0][0],
      minY = shape[0][1],
      maxX = minX,
      maxY = minY;
    shape.forEach((curve) => {
      const x1 = curve[0],
        x2 = curve[2],
        x3 = curve[4],
        x4 = curve[6],
        y1 = curve[1],
        y2 = curve[3],
        y3 = curve[5],
        y4 = curve[7];
  
      minX = Math.min(minX, x1, x2, x3, x4);
      minY = Math.min(minY, y1, y2, y3, y4);
      maxX = Math.max(maxX, x1, x2, x3, x4);
      maxY = Math.max(maxY, y1, y2, y3, y4);
    });
  
    return [minX, minY, maxX, maxY];
  }
docs: https://github.com/AlloyTeam/pasition