Particle class

The Particle class represents a single particle in the particle network. It contains properties for position, velocity, color, size, and visibility.

Uses primitive doubles internally for zero-allocation per-frame physics updates while providing Offset accessors for 100% API compatibility.

Constructors

Particle({required Offset position, required Offset velocity, required Color color, required double size, bool isVisible = true})
Constructor to initialize the particle's properties.

Properties

acceleration ↔ Offset
Accumulated acceleration from forces applied during this frame as an Offset.
getter/setter pair
ax ↔ double
Accumulated acceleration on X axis.
getter/setter pair
ay ↔ double
Accumulated acceleration on Y axis.
getter/setter pair
color ↔ Color
The color of the particle.
getter/setter pair
decayRate ↔ double
The decay rate used when returning to default velocity after touch acceleration.
getter/setter pair
defaultVelocity ↔ Offset
The default velocity of the particle as an Offset, used to reset its speed.
getter/setter pair
defaultVx ↔ double
Default X velocity component, used to reset its speed.
getter/setter pair
defaultVy ↔ double
Default Y velocity component, used to reset its speed.
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
isVisible ↔ bool
A flag indicating whether the particle is visible within the viewport.
getter/setter pair
mass → double
The mass of the particle, affects how much force is needed to move it.
final
position ↔ Offset
The current position of the particle as an Offset.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
size ↔ double
The size of the particle.
getter/setter pair
velocity ↔ Offset
The current velocity of the particle as an Offset.
getter/setter pair
vx ↔ double
Raw X velocity component.
getter/setter pair
vy ↔ double
Raw Y velocity component.
getter/setter pair
wasAccelerated ↔ bool
A flag indicating whether the particle was affected by touch interaction.
getter/setter pair
x ↔ double
Raw X position coordinate.
getter/setter pair
y ↔ double
Raw Y position coordinate.
getter/setter pair

Methods

applyForce(Offset force) → void
Applies a force to the particle based on F = ma (a = F/m).
applyForceRaw(double fx, double fy) → void
Applies a force using primitive scalar components with zero heap allocations.
handleScreenBoundaries(Size bounds) → void
Handles collisions with the screen boundaries by reversing the velocity.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
update(Size bounds) → void
Updates the particle's position and velocity based on its current state with zero allocations.
updateVisibility(Size bounds) → void
Updates the visibility status of the particle based on its position.

Operators

operator ==(Object other) → bool
The equality operator.
inherited