paint method
Paints the particle at the given position along the connection path.
Parameters:
canvas: The canvas to draw onposition: The center position of the particletangent: The path tangent at this position (for directional particles)basePaint: The base paint from the connection (color, style, etc.)
Implementation
@override
void paint(Canvas canvas, Offset position, Tangent tangent, Paint basePaint) {
final particlePaint = Paint()
..color = color ?? basePaint.color
..style = PaintingStyle.fill;
// Calculate rotation angle from tangent
final angle = math.atan2(tangent.vector.dy, tangent.vector.dx);
// Save canvas state
canvas.save();
// Translate to position and rotate
canvas.translate(position.dx, position.dy);
canvas.rotate(angle);
// Draw simple triangle arrow (pointing right by default)
final arrowPath = Path()
..moveTo(length / 2, 0) // Arrow tip (front)
..lineTo(-length / 2, -width / 2) // Top back corner
..lineTo(-length / 2, width / 2) // Bottom back corner
..close();
canvas.drawPath(arrowPath, particlePaint);
// Restore canvas state
canvas.restore();
}