ParticleEmitter constructor

ParticleEmitter({
  1. int maxParticles = 1024,
  2. double rate = 0,
  3. List<EmitterBurst> bursts = const [],
  4. double? duration,
  5. bool loop = false,
  6. ParticleRange lifespan = (1, 1),
  7. EmitterShape shape = const PointEmitterShape(),
  8. ParticleRange speed = (0, 0),
  9. double direction = 0,
  10. double spread = tau,
  11. Vector2? gravity,
  12. double drag = 0,
  13. ParticleRange size = (8, 8),
  14. ParticleRange rotation = (0, 0),
  15. ParticleRange spin = (0, 0),
  16. bool rotateToVelocity = false,
  17. ParticleCurve? scaleOverLife,
  18. ParticleCurve? opacityOverLife,
  19. ColorRamp? colorOverLife,
})

Creates an emitter preset.

Emission is continuous through rate (particles per second) and/or discrete through bursts. An emitter with only bursts finishes after the last burst has fired; an emitter with a positive rate keeps emitting until duration has passed, or forever when duration is null. With loop enabled the emission timeline restarts after duration, which must then be set.

Implementation

ParticleEmitter({
  this.maxParticles = 1024,
  this.rate = 0,
  this.bursts = const [],
  this.duration,
  this.loop = false,
  this.lifespan = (1, 1),
  this.shape = const PointEmitterShape(),
  this.speed = (0, 0),
  this.direction = 0,
  this.spread = tau,
  Vector2? gravity,
  this.drag = 0,
  this.size = (8, 8),
  this.rotation = (0, 0),
  this.spin = (0, 0),
  this.rotateToVelocity = false,
  this.scaleOverLife,
  this.opacityOverLife,
  this.colorOverLife,
}) : assert(maxParticles > 0, 'maxParticles must be positive'),
     assert(rate >= 0, 'rate must not be negative'),
     assert(spread >= 0, 'spread must not be negative'),
     assert(drag >= 0, 'drag must not be negative'),
     assert(duration == null || duration > 0, 'duration must be positive'),
     assert(
       !loop || duration != null,
       'loop requires duration to be set',
     ),
     gravity = gravity ?? Vector2.zero();