Created
February 8, 2020 20:33
-
-
Save stargazing-dino/b8c4cb59df2e48aa3e9c960d6f25663d to your computer and use it in GitHub Desktop.
Compares lines between canvas.drawLine and canvas.drawVertices
This file contains hidden or 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
| class MyPainter extends CustomPainter { | |
| @override | |
| void paint(Canvas canvas, Size size) { | |
| final brush = Paint() | |
| ..color = Colors.blue | |
| ..strokeWidth = 4 | |
| ..style = PaintingStyle.stroke; | |
| canvas.drawVertices( | |
| UI.Vertices( | |
| VertexMode.triangleStrip, | |
| [ | |
| Offset(0, 0), | |
| Offset(0, size.height), | |
| Offset(size.width, 0), | |
| ], | |
| ), | |
| BlendMode.dstIn, | |
| brush, | |
| ); | |
| canvas.drawLine( | |
| Offset(0, 0), | |
| Offset(size.width, size.height), | |
| brush, | |
| ); | |
| } | |
| @override | |
| bool shouldRepaint(CustomPainter oldDelegate) => true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment