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) {
  double width = size.width;

  double halfWidth = width / 2;

  double bigRadius = halfWidth;

  double radius = halfWidth / 2;

  double degreesPerStep = _degToRad(360 / numberOfPoints) as double;

  double halfDegreesPerStep = degreesPerStep / 2;

  var path = Path();

  double max = 2 * math.pi;

  path.moveTo(width, halfWidth);

  for (double step = 0; step < max; step += degreesPerStep) {
    path.lineTo(halfWidth + bigRadius * math.cos(step),
        halfWidth + bigRadius * math.sin(step));
    path.lineTo(halfWidth + radius * math.cos(step + halfDegreesPerStep),
        halfWidth + radius * math.sin(step + halfDegreesPerStep));
  }

  path.close();
  return path;
}