-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
42f18dc
commit 5b00573
Showing
2 changed files
with
76 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import 'dart:math'; | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
class RipplePainter extends CustomPainter { | ||
final double animationValue; | ||
final Color color; | ||
const RipplePainter({ | ||
required this.color, | ||
required this.animationValue, | ||
}); | ||
@override | ||
void paint(Canvas canvas, Size size) { | ||
final double opacity = ((1 - animationValue)).clamp(0, 0.2); | ||
canvas.drawCircle( | ||
Offset(size.width / 2, size.height / 2), | ||
animationValue * size.height * 0.3, | ||
Paint()..color = color.withOpacity(pow(opacity, 2).toDouble())); | ||
canvas.drawCircle( | ||
Offset(size.width / 2, size.height / 2), | ||
animationValue * size.height * 0.25, | ||
Paint()..color = color.withOpacity(pow(opacity, 1.5).toDouble())); | ||
canvas.drawCircle( | ||
Offset(size.width / 2, size.height / 2), | ||
animationValue * size.height * 0.2, | ||
Paint()..color = color.withOpacity(opacity)); | ||
} | ||
|
||
@override | ||
bool shouldRepaint(RipplePainter oldDelegate) => true; | ||
|
||
@override | ||
bool shouldRebuildSemantics(RipplePainter oldDelegate) => false; | ||
} |