drawTouchLines method
Draws lines between touch point and nearby particles
canvas - The canvas to draw on
visibleParticles - List of indices of currently visible particles
Implementation
void drawTouchLines(Canvas canvas, List<int> visibleParticles) {
final Offset? touch = touchPoint;
if (touch == null) return; // Exit if no current touch
for (final int i in visibleParticles) {
final Particle p = particles[i];
// Calculate distance from particle to touch point
final double distance = (p.position - touch).distance - test;
// Only draw lines for particles within the connection distance
if (distance < lineDistance) {
// Calculate line opacity based on distance (further = more transparent)
final int opacity = ((1 - distance / lineDistance) * 255).toInt();
// Update paint color with calculated opacity
linePaint.color = touchColor.withAlpha(opacity.clamp(0, 255));
// Draw line from particle to touch point
canvas.drawLine(p.position, touch, linePaint);
}
}
}