Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
idle_state.h
Go to the documentation of this file.
1#ifndef IDLESTATE_H
2#define IDLESTATE_H
3
4#include "blob_state.h"
5
13class IdleState final : public BlobState {
14public:
19 IdleState();
20
30 void Apply(std::vector<QPointF> &control_points,
31 std::vector<QPointF> &velocity,
32 QPointF &blob_center,
33 const BlobConfig::BlobParameters &params) override;
34
45 void ApplyForce(const QVector2D &force,
46 std::vector<QPointF> &velocity,
47 QPointF &blob_center,
48 const std::vector<QPointF> &control_points,
49 double blob_radius) override;
50
55 void UpdatePhases();
56
62
72 void ApplyHeartbeatEffect(const std::vector<QPointF> &control_points,
73 std::vector<QPointF> &velocity,
74 const QPointF &blob_center,
75 const BlobConfig::BlobParameters &params);
76
77private:
81 double second_phase_ = 0.0;
83 double rotation_phase_ = 0.0;
85 bool is_initializing_ = true;
89 double heartbeat_phase_ = 0.0;
91 static constexpr int kRequiredHeartbeats = 1;
92};
93
94#endif // IDLESTATE_H
Abstract base class defining the interface for different blob animation states.
Definition blob_state.h:16
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 ...
Definition idle_state.cpp:93
double second_phase_
Phase offset for the secondary wave effect.
Definition idle_state.h:81
IdleState()
Constructs an IdleState object. Initializes phase offsets.
Definition idle_state.cpp:5
void UpdatePhases()
Updates the internal phase variables used for the wave and rotation animations. Increments wave_phase...
Definition idle_state.cpp:8
double heartbeat_phase_
Current phase of the heartbeat animation cycle (0 to 2*PI).
Definition idle_state.h:89
void ResetInitialization()
Resets the initialization state, causing the heartbeat effect to play again. Sets is_initializing_ to...
Definition idle_state.cpp:25
static constexpr int kRequiredHeartbeats
The number of heartbeat cycles to perform during initialization.
Definition idle_state.h:91
void 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 ...
Definition idle_state.cpp:114
bool is_initializing_
Flag indicating if the state is currently running the initial heartbeat animation.
Definition idle_state.h:85
BlobConfig::IdleParameters idle_params_
Parameters specific to the idle animation (wave amplitude, frequency, phase).
Definition idle_state.h:79
double rotation_phase_
Phase offset for the rotational effect.
Definition idle_state.h:83
void Apply(std::vector< QPointF > &control_points, std::vector< QPointF > &velocity, QPointF &blob_center, const BlobConfig::BlobParameters &params) override
Applies the idle animation effects (waves, rotation, centering) or the initial heartbeat effect....
Definition idle_state.cpp:31
int heartbeat_count_
Counter for the number of heartbeats completed during initialization.
Definition idle_state.h:87
Structure holding parameters related to the blob's visual appearance and basic geometry.
Definition blob_config.h:25
Structure holding parameters specific to the Idle state animation.
Definition blob_config.h:73