EmitterConfig

data class EmitterConfig(val id: String = "", val particlesCount: Int = 10, val emitDurationMillis: Long = 0, val particleLifespanMillis: Long = 2000, val initialForce: Int = 100, val gravityStrength: Float = 1.0f, val gravityAngle: Int = 0, val spread: IntRange = IntRange(-180, 180), val maxHorizontalDisplacementDp: Int = 2000, val rotationMultiplier: Float = 1.0f, val randomStartPoint: Boolean = true, val particle: @Composable () -> Unit)(source)

Configuration for ParticlesEmitter (and, in turn, MultiEmitter) — the layout-based emitter whose particles are arbitrary @Composable content supplied via particle.

Unlike CanvasEmitterConfig, this config emits a fixed particlesCount of particles in a single run rather than continuously: all at once when emitDurationMillis is 0, or spread evenly over that duration otherwise. Each particle follows a kinematic trajectory derived from initialForce, a spread-sampled launch angle, and the gravityStrength/gravityAngle gravity vector.

Parameters

id

identifier used to key the particle in composition; set by MultiEmitter to distinguish concurrent emitters. Leave as the default for a single emitter.

particlesCount

number of particles emitted in one run.

emitDurationMillis

how long emission takes, in milliseconds. 0 emits every particle at once; a positive value staggers emission evenly across the duration. This is the duration of the emitter, not of the whole animation — the entire animation lasts emitDurationMillis plus the particleLifespanMillis of the last emitted Particle.

particleLifespanMillis

how long each particle stays on screen, in milliseconds.

initialForce

launch-velocity multiplier for each particle (default 100); higher values fling particles farther from the start point.

gravityStrength

strength of gravitational force applied to particles in Dp/s². A value of 0 means no gravity. Higher values create stronger pull.

gravityAngle

direction of gravity in degrees. 0 degrees points downward (bottom of the screen), 90 degrees points left, -90 degrees points right, 180 degrees points upward.

spread

range of launch angles (degrees) sampled randomly per particle. 0° points toward the top of the screen (vertical).

maxHorizontalDisplacementDp

horizontal boundary, in Dp, that a particle may travel from its start point. 0 means no boundary.

rotationMultiplier

scales how much each particle spins over its lifespan: 0f disables rotation, 1f (default) is one full back-and-forth turn, higher values spin faster.

randomStartPoint

when true (default) each particle starts at a random point within the emitter bounds; when false all particles start from the center.

particle

the @Composable content drawn for every particle.

Constructors

Link copied to clipboard
constructor(id: String = "", particlesCount: Int = 10, emitDurationMillis: Long = 0, particleLifespanMillis: Long = 2000, initialForce: Int = 100, gravityStrength: Float = 1.0f, gravityAngle: Int = 0, spread: IntRange = IntRange(-180, 180), maxHorizontalDisplacementDp: Int = 2000, rotationMultiplier: Float = 1.0f, randomStartPoint: Boolean = true, particle: @Composable () -> Unit)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val id: String
Link copied to clipboard
Link copied to clipboard
val particle: @Composable () -> Unit
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard