ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Fisheye.h
Go to the documentation of this file.
1/**
2 * @file Fisheye.h
3 * @brief Defines the `Fisheye` effect class for applying fisheye distortions to pixel groups.
4 *
5 * The `Fisheye` class applies a dynamic, time-variant fisheye distortion effect to pixel groups,
6 * modifying their positions and colors based on mathematical transformations.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "Effect.h"
16#include "../../Utils/Signals/FunctionGenerator.h"
17#include "../../Utils/Math/Vector2D.h"
18
19/**
20 * @class Fisheye
21 * @brief Implements a fisheye distortion effect for pixel groups.
22 *
23 * The `Fisheye` effect dynamically distorts pixel positions around a specified offset
24 * using sinusoidal function generators for smooth, animated transformations.
25 */
26class Fisheye : public Effect {
27private:
28 Vector2D offset = Vector2D(0.0f, 0.0f); ///< Offset for the fisheye distortion center.
29 float amplitude; ///< Amplitude of the distortion effect.
30 FunctionGenerator fGenSize = FunctionGenerator(FunctionGenerator::Sine, 1.0f, 48.0f, 2.3f); ///< Controls the size modulation.
31 FunctionGenerator fGenX = FunctionGenerator(FunctionGenerator::Sine, -96.0f, 96.0f, 2.7f); ///< Controls X-axis displacement.
32 FunctionGenerator fGenY = FunctionGenerator(FunctionGenerator::Sine, -96.0f, 96.0f, 1.7f); ///< Controls Y-axis displacement.
33 FunctionGenerator fGenWarp = FunctionGenerator(FunctionGenerator::Sine, 1.0f, 100.0f, 3.7f); ///< Controls warp effect.
34
35public:
36 /**
37 * @brief Constructs a `Fisheye` effect with a specified amplitude.
38 *
39 * @param amplitude The amplitude of the fisheye distortion. Default is 0.5.
40 */
41 Fisheye(float amplitude = 0.5f);
42
43 /**
44 * @brief Sets the distortion center offset.
45 *
46 * @param offset The new offset for the fisheye effect center.
47 */
49
50 /**
51 * @brief Sets the amplitude of the distortion.
52 *
53 * @param amplitude The new amplitude for the fisheye effect.
54 */
55 void SetAmplitude(float amplitude);
56
57 /**
58 * @brief Applies the fisheye effect to the given pixel group.
59 *
60 * This method modifies the positions of the pixels in the group based on the
61 * fisheye distortion formula, using the amplitude, offset, and function generators.
62 *
63 * @param pixelGroup Pointer to the `IPixelGroup` to which the effect will be applied.
64 */
65 void ApplyEffect(IPixelGroup* pixelGroup) override;
66};
67
Defines the base Effect class for applying transformations or effects to pixel groups.
Abstract base class for applying visual effects to pixel groups.
Definition Effect.h:26
Implements a fisheye distortion effect for pixel groups.
Definition Fisheye.h:26
FunctionGenerator fGenX
Controls X-axis displacement.
Definition Fisheye.h:31
float amplitude
Amplitude of the distortion effect.
Definition Fisheye.h:29
void SetAmplitude(float amplitude)
Sets the amplitude of the distortion.
Definition Fisheye.cpp:9
void SetPosition(Vector2D offset)
Sets the distortion center offset.
Definition Fisheye.cpp:5
void ApplyEffect(IPixelGroup *pixelGroup) override
Applies the fisheye effect to the given pixel group.
Definition Fisheye.cpp:13
FunctionGenerator fGenWarp
Controls warp effect.
Definition Fisheye.h:33
FunctionGenerator fGenSize
Controls the size modulation.
Definition Fisheye.h:30
Vector2D offset
Offset for the fisheye distortion center.
Definition Fisheye.h:28
FunctionGenerator fGenY
Controls Y-axis displacement.
Definition Fisheye.h:32
A class to generate various waveform functions with customizable parameters.
@ Sine
Sine waveform.
Interface for managing and interacting with a collection of pixels.
Definition IPixelGroup.h:25
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Definition Vector2D.h:27