Documentation
¶
Index ¶
- type Emitter
- func (e *Emitter) AliveCount() int
- func (e *Emitter) Bounds() types.Rect
- func (e *Emitter) IsActive() bool
- func (e *Emitter) ParticleAlpha(i int) float32
- func (e *Emitter) ParticleColor(i int) (r, g, b float32)
- func (e *Emitter) ParticleLifeFraction(i int) float64
- func (e *Emitter) ParticlePos(i int) (x, y float64)
- func (e *Emitter) ParticleRenderData(i int) (x, y float64, scale, alpha, colorR, colorG, colorB float32)
- func (e *Emitter) ParticleScale(i int) float32
- func (e *Emitter) ParticleVelocity(i int) (vx, vy float64)
- func (e *Emitter) Reset()
- func (e *Emitter) Start()
- func (e *Emitter) Stop()
- func (e *Emitter) Update(dt float64)
- type EmitterConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Emitter ¶
type Emitter struct {
Config EmitterConfig
Particles []particle
Alive int
EmitAccum float64
Active bool
// World-space tracking: the emitter's last known world position,
// set by the update walk so particles can be spawned at world coords.
WorldX, WorldY float64
}
Emitter manages a pool of particles with CPU-based simulation.
func NewEmitter ¶
func NewEmitter(cfg EmitterConfig) *Emitter
NewEmitter creates an Emitter with a preallocated pool.
func (*Emitter) AliveCount ¶
AliveCount returns the number of alive particles.
func (*Emitter) Bounds ¶
Bounds returns the axis-aligned bounding box of all alive particles in the emitter's coordinate space (local for local-space, world for world-space). The returned rect includes particle scale so the full rendered extent is covered. Returns a zero Rect when no particles are alive.
func (*Emitter) IsActive ¶
IsActive reports whether the emitter is currently emitting new particles.
func (*Emitter) ParticleAlpha ¶
ParticleAlpha returns the alpha of the particle at the given index.
func (*Emitter) ParticleColor ¶
ParticleColor returns the RGB color of the particle at the given index.
func (*Emitter) ParticleLifeFraction ¶
ParticleLifeFraction returns the progress fraction (0..1) of the particle's lifetime.
func (*Emitter) ParticlePos ¶
ParticlePos returns the position of the particle at the given index.
func (*Emitter) ParticleRenderData ¶
func (e *Emitter) ParticleRenderData(i int) (x, y float64, scale, alpha, colorR, colorG, colorB float32)
ParticleRenderData returns position, scale, and color for particle at index i. Used by the render pipeline's batch submitter to build per-particle vertices.
func (*Emitter) ParticleScale ¶
ParticleScale returns the scale of the particle at the given index.
func (*Emitter) ParticleVelocity ¶
ParticleVelocity returns the velocity of the particle at the given index.
func (*Emitter) Reset ¶
func (e *Emitter) Reset()
Reset stops emitting and kills all alive particles.
type EmitterConfig ¶
type EmitterConfig struct {
// MaxParticles is the pool size. New particles are silently dropped when full.
MaxParticles int
// EmitRate is the number of particles spawned per second.
EmitRate float64
// Lifetime is the range of particle lifetimes in seconds.
Lifetime types.Range
// Speed is the range of initial particle speeds in pixels per second.
Speed types.Range
// Angle is the range of emission angles in radians.
Angle types.Range
// StartScale is the range of scale factors at birth, interpolated to EndScale over lifetime.
StartScale types.Range
// EndScale is the range of scale factors at death.
EndScale types.Range
// StartAlpha is the range of alpha values at birth, interpolated to EndAlpha over lifetime.
StartAlpha types.Range
// EndAlpha is the range of alpha values at death.
EndAlpha types.Range
// Gravity is the constant acceleration applied to all particles each frame.
Gravity types.Vec2
// StartColor is the tint at birth, interpolated to EndColor over lifetime.
StartColor types.Color
// EndColor is the tint at death.
EndColor types.Color
// Region is the TextureRegion used to render each particle.
Region types.TextureRegion
// BlendMode is the compositing operation for particle rendering.
BlendMode types.BlendMode
// WorldSpace, when true, causes particles to keep their world position
// once emitted rather than following the emitter node.
WorldSpace bool
}
EmitterConfig controls how particles are spawned and behave.