Skip to content

Instantly share code, notes, and snippets.

@stargazing-dino
Created February 8, 2020 20:33
Show Gist options
  • Select an option

  • Save stargazing-dino/b8c4cb59df2e48aa3e9c960d6f25663d to your computer and use it in GitHub Desktop.

Select an option

Save stargazing-dino/b8c4cb59df2e48aa3e9c960d6f25663d to your computer and use it in GitHub Desktop.
Compares lines between canvas.drawLine and canvas.drawVertices
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