OptimizedNetworkPainter constructor
OptimizedNetworkPainter({
- required int particleCount,
- required List<
Particle> particles, - required Offset? touchPoint,
- required double lineDistance,
- required Color particleColor,
- required Color lineColor,
- required Color touchColor,
- required bool touchActivation,
- required double lineWidth,
- required bool isComplex,
- required bool fill,
- required bool drawNetwork,
- 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,
);
}