|
Wavelength
Privacy-focused, cross-platform, and open-source communication application
|
Implements the Idle state behavior for the Blob animation. More...
#include <idle_state.h>
Public Member Functions | |
| void | Apply (std::vector< QPointF > &control_points, std::vector< QPointF > &velocity, QPointF &blob_center, const BlobConfig::BlobParameters ¶ms) override |
| Applies the idle animation effects (waves, rotation, centering) or the initial heartbeat effect. Called periodically by the animation loop when this state is active. If is_initializing_ is true, applies the heartbeat effect. Otherwise, applies the standard idle wave and rotation. | |
| void | ApplyForce (const QVector2D &force, std::vector< QPointF > &velocity, QPointF &blob_center, const std::vector< QPointF > &control_points, double blob_radius) override |
| Applies an external force to the blob with dampening specific to the Idle state. The force is scaled based on the distance of each control point from the center and applied primarily to velocity. A small portion of the force is also applied directly to the blob's center position. | |
| void | ApplyHeartbeatEffect (const std::vector< QPointF > &control_points, std::vector< QPointF > &velocity, const QPointF &blob_center, const BlobConfig::BlobParameters ¶ms) |
| Applies a pulsating "heartbeat" effect to the blob. Used during the initial phase after entering the Idle state. The effect runs for a defined number of beats (kRequiredHeartbeats). Modifies control point velocities to create expansion and contraction. | |
| IdleState () | |
| Constructs an IdleState object. Initializes phase offsets. | |
| void | ResetInitialization () |
| Resets the initialization state, causing the heartbeat effect to play again. Sets is_initializing_ to true and resets heartbeat counters. | |
| void | UpdatePhases () |
| Updates the internal phase variables used for the wave and rotation animations. Increments wave_phase, second_phase_, and rotation_phase_, wrapping them around 2*PI. | |
Public Member Functions inherited from BlobState | |
| virtual | ~BlobState ()=default |
| Virtual destructor. Ensures proper cleanup when deleting derived state objects through a base class pointer. | |
Private Attributes | |
| int | heartbeat_count_ = 0 |
| Counter for the number of heartbeats completed during initialization. | |
| double | heartbeat_phase_ = 0.0 |
| Current phase of the heartbeat animation cycle (0 to 2*PI). | |
| BlobConfig::IdleParameters | idle_params_ |
| Parameters specific to the idle animation (wave amplitude, frequency, phase). | |
| bool | is_initializing_ = true |
| Flag indicating if the state is currently running the initial heartbeat animation. | |
| double | rotation_phase_ = 0.0 |
| Phase offset for the rotational effect. | |
| double | second_phase_ = 0.0 |
| Phase offset for the secondary wave effect. | |
Static Private Attributes | |
| static constexpr int | kRequiredHeartbeats = 1 |
| The number of heartbeat cycles to perform during initialization. | |
Implements the Idle state behavior for the Blob animation.
This state applies subtle wave and rotation effects to the blob when it's not actively moving or resizing. It also includes an initial "heartbeat" animation upon entering the state. Forces applied in this state are dampened compared to other states.
| IdleState::IdleState | ( | ) |
Constructs an IdleState object. Initializes phase offsets.
|
overridevirtual |
Applies the idle animation effects (waves, rotation, centering) or the initial heartbeat effect. Called periodically by the animation loop when this state is active. If is_initializing_ is true, applies the heartbeat effect. Otherwise, applies the standard idle wave and rotation.
| control_points | Reference to the vector of current control point positions (modified). |
| velocity | Reference to the vector of current control point velocities (modified). |
| blob_center | Reference to the blob's center position (modified). |
| params | Blob appearance parameters (read-only). |
Implements BlobState.
|
overridevirtual |
Applies an external force to the blob with dampening specific to the Idle state. The force is scaled based on the distance of each control point from the center and applied primarily to velocity. A small portion of the force is also applied directly to the blob's center position.
| force | The external force vector to apply. |
| velocity | Reference to the vector of current control point velocities (modified). |
| blob_center | Reference to the blob's center position (modified). |
| control_points | Reference to the vector of current control point positions (read-only). |
| blob_radius | The current average radius of the blob (read-only). |
Implements BlobState.
| void IdleState::ApplyHeartbeatEffect | ( | const std::vector< QPointF > & | control_points, |
| std::vector< QPointF > & | velocity, | ||
| const QPointF & | blob_center, | ||
| const BlobConfig::BlobParameters & | params ) |
Applies a pulsating "heartbeat" effect to the blob. Used during the initial phase after entering the Idle state. The effect runs for a defined number of beats (kRequiredHeartbeats). Modifies control point velocities to create expansion and contraction.
| control_points | Reference to the vector of current control point positions (read-only). |
| velocity | Reference to the vector of current control point velocities (modified). |
| blob_center | The current center position of the blob (read-only). |
| params | Blob appearance parameters (read-only). |
| void IdleState::ResetInitialization | ( | ) |
Resets the initialization state, causing the heartbeat effect to play again. Sets is_initializing_ to true and resets heartbeat counters.
| void IdleState::UpdatePhases | ( | ) |
Updates the internal phase variables used for the wave and rotation animations. Increments wave_phase, second_phase_, and rotation_phase_, wrapping them around 2*PI.
|
private |
Counter for the number of heartbeats completed during initialization.
|
private |
Current phase of the heartbeat animation cycle (0 to 2*PI).
|
private |
Parameters specific to the idle animation (wave amplitude, frequency, phase).
|
private |
Flag indicating if the state is currently running the initial heartbeat animation.
|
staticconstexprprivate |
The number of heartbeat cycles to perform during initialization.
|
private |
Phase offset for the rotational effect.
|
private |
Phase offset for the secondary wave effect.