getClip method

  1. @override
Path getClip(
  1. Size size
)
override

Returns a description of the clip given that the render object being clipped is of the given size.

Implementation

@override
Path getClip(Size size) {
  //叶片尺寸
  final double fragmentSize = _handleFragmentSize(size);

  final Path path = Path();

  for (int i = 0; i < fragment; i++) {
    double left = 0;
    double top = fragmentSize * i;
    double width = size.width;
    double height = fragmentSize * animation.value;

    if (activeAlignment == FillAlignment.left) {
      left = fragmentSize * i;
      top = 0;
      width = fragmentSize * animation.value;
      height = size.height;
    } else if (activeAlignment == FillAlignment.bottom) {
      left = 0;
      top = fragmentSize * (i + 1 - animation.value);
      width = size.width;
      height = fragmentSize * animation.value;
    } else if (activeAlignment == FillAlignment.right) {
      left = fragmentSize * (i + 1 - animation.value);
      top = 0;
      width = fragmentSize * animation.value;
      height = size.height;
    }

    path.addRect(Rect.fromLTWH(left, top, width, height));
  }

  return path;
}