d_zero_particles 0.1.4
d_zero_particles: ^0.1.4 copied to clipboard
Ultra high-performance, zero-allocation SIMD particle simulation, confetti, and live-stream reaction fountain for Flutter and Impeller.
⚡️ d_zero_particles #
Ultra high-performance, zero-allocation SIMD particle simulation and confetti batch rendering for Flutter and Impeller.
💡 Architecture: Structure-of-Arrays (SoA) & 4-Lane SIMD #
Traditional object-oriented particle engines (List<Particle>) suffer from CPU cache misses (pointer chasing) and thousands of Canvas.drawCircle / Paint / Offset allocations per frame.
d_zero_particles eliminates both bottlenecks:
- Contiguous SoA Memory (
ZeroParticleBuffer): Stores positions, velocities, and lifespans in flat, 16-byte alignedFloat32List/Float32x4Listviews. - Branchless 4-Lane SIMD Physics (
Float32x4): Steps 2 particles (4 floats:x0, y0, x1, y1) per CPU instruction using vector comparisons (lessThan,greaterThan,select,clamp). - Single-Call GPU Batching: Flushes up to
10,000+particles to Impeller in a singleCanvas.drawRawPoints(PointMode.points, positions, paint)call.
📦 Distributed Z Widgets & Controllers #
| Symbol | Kind | Description |
|---|---|---|
ZParticles |
Widget | Simulates and renders thousands of particles at 120fps in a single Canvas.drawRawPoints call (legacy: ZeroParticles). |
ZeroParticleController |
Controller | Manages ZeroParticleBuffer lifecycle, ZeroParticleConfig (gravity, bounce, friction, maxSpeed), and safe post-dispose fallbacks. |
ZConfetti |
Widget | Multi-palette celebration confetti overlay rendered in batched point/ribbon passes with zero per-frame object allocations (legacy: ZeroConfetti). |
ZeroConfettiController |
Controller | Triggers directional/radial confetti bursts (burst(count: 80)) backed by SoA Float32List buffers. |
ZReactionStream |
Widget | Live-stream floating hearts/reactions fountain (ZFloatingHearts, legacy: ZeroReactionStream) backed by SoA Float32List physics and batched Canvas.drawRawPoints. |
ZeroReactionController |
Controller | Spawns floating reaction particles (spawn(count)) and steps upward sine-wave drift in place with zero heap allocations. |
🚀 Installation & Usage #
dependencies:
d_zero_particles: ^0.1.0
import 'package:flutter/material.dart';
import 'package:d_zero_particles/d_zero_particles.dart';
final particleCtrl = ZeroParticleController(
capacity: 5000,
config: const ZeroParticleConfig(gravity: 98.0, bounce: 0.85),
);
final confettiCtrl = ZeroConfettiController(capacity: 160);
Stack(
children: [
ZParticles(
controller: particleCtrl,
color: const Color(0xFF00E5FF),
pointSize: 2.5,
),
ZConfetti(
controller: confettiCtrl,
isRunning: true,
),
],
);
// Trigger a celebration burst at any time with 0 heap allocations:
confettiCtrl.burst(count: 80);
📱 High-Load Comparison Benchmark App (example/) #
The example/ app lets you switch between 2,000, 5,000, and 10,000 simultaneous particles comparing ZParticles (SIMD SoA + drawRawPoints) against traditional List<Particle> + drawCircle, displaying live FPS, UI CPU Load (%), RSS Memory (MB), Rebuilds, and Allocations.
cd packages/d_zero_particles/example
flutter run
📄 License #
MIT License © 2026 fexcy