/// Created by @Haoyi on 2020/12/29

part of 'tips.dart';

class TipsPainter extends CustomPainter {
  final CustomClipper<Path> clipper;

/*  final gradient = LinearGradient(
    begin: Alignment.topCenter,
    end: Alignment.bottomCenter,
    colors: <Color>[Color(0xFFDADAFB), Color(0xFFFFFFFF)],
  );*/

  final Gradient? gradient;
  final Color? backgroundColor;

  final _paint = Paint()
    ..isAntiAlias = true
    ..style = PaintingStyle.fill;

  TipsPainter(
      {required this.clipper, this.backgroundColor = const Color(0xE5000000), this.gradient});

  @override
  void paint(Canvas canvas, Size size) {
    if (gradient != null) {
      _paint.shader = gradient?.createShader(Rect.fromLTWH(0, 0, size.width, size.height));
    } else {
      _paint.color = backgroundColor ?? const Color(0xE5000000);
    }
    // _paint.shader = gradient.createShader(Rect.fromLTWH(0, 0, size.width, size.height));
    canvas.drawPath(clipper.getClip(size), _paint);

    // canvas.drawRect(Rect.fromLTWH(0, 0, size.width, size.height), _paint);
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return false;
  }
}
