buildBoxBySpineType method

Path buildBoxBySpineType(
  1. Canvas canvas,
  2. SpineType spineType,
  3. double width,
  4. double height,
)

Implementation

Path buildBoxBySpineType(
    Canvas canvas,
    SpineType spineType,
    double width,
    double height,
    ) {
  double lineHeight, lineWidth;

  switch (spineType) {
    case SpineType.top:
      lineHeight = height - spineHeight;
      canvas.translate(0, spineHeight);
      lineWidth = width;
      break;
    case SpineType.left:
      lineWidth = width - spineHeight;
      lineHeight = height;
      canvas.translate(spineHeight, 0);
      break;
    case SpineType.right:
      lineWidth = width - spineHeight;
      lineHeight = height;
      break;
    case SpineType.bottom:
      lineHeight = height - spineHeight;
      lineWidth = width;
      break;
  }

  Rect box = Rect.fromCenter(
      center: Offset(lineWidth / 2, lineHeight / 2),
      width: lineWidth,
      height: lineHeight);

  return Path()..addRRect(RRect.fromRectXY(box, radius, radius));
}