OptimizedNetworkPainter constructor

OptimizedNetworkPainter({
  1. required int particleCount,
  2. required List<Particle> particles,
  3. required Offset? touchPoint,
  4. required double lineDistance,
  5. required Color particleColor,
  6. required Color lineColor,
  7. required Color touchColor,
  8. required bool touchActivation,
  9. required double lineWidth,
  10. required bool isComplex,
  11. required bool fill,
  12. required bool drawNetwork,
  13. bool showQuadTree = false,
})

Constructor with dependency initialization

Implementation

OptimizedNetworkPainter({
  required this.particleCount,
  required this.particles,
  required this.touchPoint,
  required this.lineDistance,
  required this.particleColor,
  required this.lineColor,
  required this.touchColor,
  required this.touchActivation,
  required this.lineWidth,
  required this.isComplex,
  required this.fill,
  required this.drawNetwork,
  this.showQuadTree = false, // Default to false
}) {
  // Get viewport dimensions for QuadTree initialization
  // final mw = MediaQuery.of(context).size.width + 10;
  // final mh = double.infinity ;

  // final s = Size(width, height)

  // Initialize QuadTree with viewport bounds
  _quadTree = CompressedQuadTree(
    Rectangle(
      -5,
      -5,
      double.maxFinite,
      double.maxFinite,
    ), // Placeholder, will be updated in paint
  );
  // Initialize particle paint with anti-aliasing for smooth rendering
  particlePaint = Paint()
    ..style = fill ? PaintingStyle.fill : PaintingStyle.stroke
    ..color = particleColor
    ..isAntiAlias = true;

  // Initialize line paint with stroke configuration and smooth rendering
  linePaint = Paint()
    ..style = fill ? PaintingStyle.stroke : PaintingStyle.fill
    ..strokeWidth = lineWidth
    ..color = lineColor
    ..isAntiAlias = true // Enable anti-aliasing for smoother lines
    ..strokeCap = StrokeCap.round // Round line endings for smoother appearance
    ..strokeJoin = StrokeJoin.round; // Smooth line joints

  // Initialize sub-components with dependency injection
  _distanceCalculator = DistanceCalculator();
  _touchHandler = TouchInteractionHandler(
    particles: particles,
    touchPoint: touchPoint,
    lineDistance: lineDistance,
    touchColor: touchColor,
    linePaint: linePaint,
  );
}