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) {
  /// tangent of the tilt angle
  final tanTheta = math.tan(tiltAngle);

  /// tangent of the (pi - shadow's tilt angle)
  final tanAlpha = math.tan(math.pi - plunkAngle);
  final height = size.height;
  final width = size.width;

  // Corner points of the button
  final a = Offset(height / tanTheta, 0);
  final b = Offset(width - (height / tanTheta), 0);
  final c = Offset(width, height);
  final d = Offset(0, height);
  final e = Offset((depth / tanAlpha).abs(), height + depth);
  final f = Offset(c.dx - (depth / tanAlpha).abs(), height + depth);

  final Path path = Path()..addPolygon([a, b, c, f, e, d], true);
  return path;
}