Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
blob_renderer.h
Go to the documentation of this file.
1#ifndef BLOB_RENDERER_H
2#define BLOB_RENDERER_H
3
4#include <QPainterPath>
5#include <QPixmap>
6
8#include "../blob_config.h"
9
23
34public:
44 // markers_manager_ = new PathMarkersManager();
45 }
46
52 delete markers_manager_;
53 markers_manager_ = nullptr;
54 }
55
63 void RenderBlob(QPainter &painter,
64 const std::vector<QPointF> &control_points,
65 const QPointF &blob_center,
66 const BlobConfig::BlobParameters &params);
67
77 void UpdateGridBuffer(const QColor &background_color,
78 const QColor &grid_color,
79 int grid_spacing,
80 int width, int height);
81
93 void DrawBackground(QPainter &painter,
94 const QColor &background_color,
95 const QColor &grid_color,
96 int grid_spacing,
97 int width, int height);
98
116 void RenderScene(QPainter &painter,
117 const std::vector<QPointF> &control_points,
118 const QPointF &blob_center,
119 const BlobConfig::BlobParameters &params,
120 const BlobRenderState &render_state,
121 int width, int height,
122 QPixmap &background_cache,
123 QSize &last_background_size,
124 QColor &last_background_color,
125 QColor &last_grid_color,
126 int &last_grid_spacing);
127
133 void InitializeIdleState();
134
145 void DrawCompleteHUD(QPainter &painter, const QPointF &blob_center, double blob_radius, const QColor &hud_color,
146 int width,
147 int height) const;
148
153 grid_buffer_ = QPixmap();
154 }
155
159 void ResetHUD() {
160 idle_hud_initialized_ = false;
161 static_hud_buffer_ = QPixmap();
162 }
163
173 void ForceHUDInitialization(const QPointF &blob_center, double blob_radius,
174 const QColor &hud_color, int width, int height);
175
176private:
201
206
209
213 QPainterPath last_glow_path_;
220
230 void DrawGlowEffect(QPainter &painter,
231 const QPainterPath &blob_path,
232 const QColor &border_color,
233 int glow_radius);
234
243 static void RenderGlowEffect(QPainter &painter, const QPainterPath &blob_path, const QColor &border_color,
244 int glow_radius);
245
254 static void DrawBorder(QPainter &painter,
255 const QPainterPath &blob_path,
256 const QColor &border_color,
257 int border_width);
258
268 static void DrawFilling(QPainter &painter,
269 const QPainterPath &blob_path,
270 const QPointF &blob_center,
271 double blob_radius,
272 const QColor &border_color);
273};
274
275#endif // BLOB_RENDERER_H
static void RenderGlowEffect(QPainter &painter, const QPainterPath &blob_path, const QColor &border_color, int glow_radius)
Renders the multi-layered glow effect using QPainter drawPath operations with varying pen widths and ...
Definition blob_renderer.cpp:162
QColor last_grid_color_
Stores the grid color used for the last grid_buffer_ update.
Definition blob_renderer.h:186
void ForceHUDInitialization(const QPointF &blob_center, double blob_radius, const QColor &hud_color, int width, int height)
Forces the immediate initialization and buffering of the static HUD elements for the Idle state....
Definition blob_renderer.cpp:403
void DrawCompleteHUD(QPainter &painter, const QPointF &blob_center, double blob_radius, const QColor &hud_color, int width, int height) const
Draws the complete static Heads-Up Display (HUD) elements used in the Idle state. Includes corner mar...
Definition blob_renderer.cpp:363
void ResetHUD()
Resets the HUD buffers and flags, forcing reinitialization on the next transition to Idle state.
Definition blob_renderer.h:159
double idle_amplitude_
Calculated amplitude value displayed in the Idle state HUD.
Definition blob_renderer.h:196
QPixmap grid_buffer_
Cached pixmap containing the rendered grid lines. Updated when grid parameters or size change.
Definition blob_renderer.h:182
QSize last_glow_size_
Stores the viewport size used for the last glow_buffer_ update.
Definition blob_renderer.h:219
QColor last_background_color_
Stores the background color used for the last grid_buffer_ update.
Definition blob_renderer.h:184
QString idle_timestamp_
Timestamp string displayed in the Idle state HUD (potentially dynamic, currently static after init).
Definition blob_renderer.h:198
BlobRenderer()
Constructs a BlobRenderer object. Initializes member variables to default states.
Definition blob_renderer.h:39
static void DrawFilling(QPainter &painter, const QPainterPath &blob_path, const QPointF &blob_center, double blob_radius, const QColor &border_color)
Draws the filling inside the blob path using a radial gradient. The gradient fades from a lighter,...
Definition blob_renderer.cpp:248
BlobConfig::AnimationState last_animation_state_
Stores the animation state from the previous frame, used for detecting state changes.
Definition blob_renderer.h:205
static void DrawBorder(QPainter &painter, const QPainterPath &blob_path, const QColor &border_color, int border_width)
Draws the border outline of the blob. Includes a main border and a thinner, lighter inner line for a ...
Definition blob_renderer.cpp:227
void ResetGridBuffer()
Resets the internal grid buffer pixmap, forcing it to be redrawn on the next frame.
Definition blob_renderer.h:152
int last_glow_radius_
Stores the glow radius used for the last glow_buffer_ update.
Definition blob_renderer.h:217
void UpdateGridBuffer(const QColor &background_color, const QColor &grid_color, int grid_spacing, int width, int height)
Updates the internal buffer containing the rendered background grid. Called when grid parameters (col...
Definition blob_renderer.cpp:22
QColor last_glow_color_
Stores the border color used for the last glow_buffer_ update.
Definition blob_renderer.h:215
QSize last_size_
Stores the size used for the last grid_buffer_ update.
Definition blob_renderer.h:190
QPixmap glow_buffer_
Cached pixmap containing the rendered glow effect. Updated based on blob shape, color,...
Definition blob_renderer.h:211
void RenderScene(QPainter &painter, const std::vector< QPointF > &control_points, const QPointF &blob_center, const BlobConfig::BlobParameters &params, const BlobRenderState &render_state, int width, int height, QPixmap &background_cache, QSize &last_background_size, QColor &last_background_color, QColor &last_grid_color, int &last_grid_spacing)
Renders the entire scene, including a background, blob, and potentially HUD. Orchestrates the drawing...
Definition blob_renderer.cpp:274
int last_grid_spacing_
Stores the grid spacing used for the last grid_buffer_ update.
Definition blob_renderer.h:188
bool is_rendering_active_
Flag indicating if rendering is currently active (used for state transition logic).
Definition blob_renderer.h:203
bool idle_hud_initialized_
Flag indicating if the static HUD elements for the Idle state have been initialized and buffered.
Definition blob_renderer.h:200
void RenderBlob(QPainter &painter, const std::vector< QPointF > &control_points, const QPointF &blob_center, const BlobConfig::BlobParameters &params)
Renders the blob shape itself (filling, border, glow).
Definition blob_renderer.cpp:9
void DrawGlowEffect(QPainter &painter, const QPainterPath &blob_path, const QColor &border_color, int glow_radius)
Draws the glow effect around the blob path. Uses internal caching (glow_buffer_) to optimize renderin...
Definition blob_renderer.cpp:119
QPixmap static_background_texture_
Cached pixmap containing a static background texture (e.g., gradient, noise). Initialized once.
Definition blob_renderer.h:178
void InitializeIdleState()
Initializes parameters specific to the Idle state HUD display. Generates random ID,...
Definition blob_renderer.cpp:353
bool static_background_initialized_
Flag indicating if static_background_texture_ has been initialized.
Definition blob_renderer.h:180
~BlobRenderer()
Destructor for BlobRenderer. Cleans up allocated resources.
Definition blob_renderer.h:51
QString idle_blob_id_
Randomly generated ID string displayed in the Idle state HUD.
Definition blob_renderer.h:194
QPainterPath last_glow_path_
Stores the blob path used for the last glow_buffer_ update.
Definition blob_renderer.h:213
QPixmap static_hud_buffer_
Cached pixmap containing the static elements of the HUD rendered during Idle state initialization.
Definition blob_renderer.h:208
void DrawBackground(QPainter &painter, const QColor &background_color, const QColor &grid_color, int grid_spacing, int width, int height)
Draws the background, including a static texture and the dynamic grid. Uses internal caching (grid_bu...
Definition blob_renderer.cpp:48
PathMarkersManager * markers_manager_
Markers Manager for drawing animated markers alongside blob border (currently unused).
Definition blob_renderer.h:192
Manages the creation, update, and rendering of animated markers along a QPainterPath.
Definition path_markers_manager.h:20
Namespace containing configuration structures and enums for the Blob animation.
Definition blob_config.h:12
AnimationState
Defines the possible animation states for the blob.
Definition blob_config.h:16
@ kIdle
The blob is stationary or exhibiting subtle idle animations.
Definition blob_config.h:17
Structure holding parameters related to the blob's visual appearance and basic geometry.
Definition blob_config.h:25
Structure holding state information relevant for rendering decisions.
Definition blob_renderer.h:13
double opacity
Overall opacity multiplier for the blob.
Definition blob_renderer.h:18
bool is_absorbing
True if the blob is currently absorbing another instance.
Definition blob_renderer.h:15
bool is_closing_after_absorption
True if the application is closing after being absorbed.
Definition blob_renderer.h:16
bool is_being_absorbed
True if the blob is currently being absorbed by another instance.
Definition blob_renderer.h:14
BlobConfig::AnimationState animation_state
The current animation state (Idle, Moving, Resizing).
Definition blob_renderer.h:20
double scale
Overall scale multiplier for the blob.
Definition blob_renderer.h:19
bool is_pulse_active
True if a pulse effect should be rendered.
Definition blob_renderer.h:17