Skip to content

Instantly share code, notes, and snippets.

@prasadsunny1
Created October 28, 2020 18:09
Show Gist options
  • Save prasadsunny1/0168b56e25c6d2bdd75f3922ae41a1c9 to your computer and use it in GitHub Desktop.
Save prasadsunny1/0168b56e25c6d2bdd75f3922ae41a1c9 to your computer and use it in GitHub Desktop.
class RPSCustomPainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
Paint paint = new Paint()
..color = Colors.blue
..style = PaintingStyle.stroke;
// Code for path
// From here ....
Path path = Path();
path.moveTo(size.width * 0.07, size.height * 0.08);
path.quadraticBezierTo(size.width * 0.07, size.height * 0.04,
size.width * 0.13, size.height * 0.04);
path.cubicTo(size.width * 0.32, size.height * 0.04, size.width * 0.68,
size.height * 0.04, size.width * 0.87, size.height * 0.04);
path.quadraticBezierTo(size.width * 0.93, size.height * 0.04,
size.width * 0.93, size.height * 0.08);
path.quadraticBezierTo(size.width * 0.93, size.height * 0.44,
size.width * 0.93, size.height * 0.56);
path.cubicTo(size.width * 0.93, size.height * 0.72, size.width * 0.61,
size.height * 0.81, size.width * 0.53, size.height * 0.84);
path.quadraticBezierTo(size.width * 0.49, size.height * 0.85,
size.width * 0.46, size.height * 0.84);
path.quadraticBezierTo(size.width * 0.07, size.height * 0.72,
size.width * 0.07, size.height * 0.56);
path.quadraticBezierTo(size.width * 0.07, size.height * 0.44,
size.width * 0.07, size.height * 0.08);
path.close();
// .... to here
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment