2#include "../../Utils/Math/Mathematics.h"
7 if (
ratio <= 0.001f)
return;
19 float mpiR1G = mpiR1R + phase120;
20 float mpiR2G = mpiR2R + phase120;
21 float mpiR1B = mpiR1R + phase240;
22 float mpiR2B = mpiR2R + phase240;
24 for (uint16_t i = 0; i < pixelCount; i++) {
25 uint16_t indexR, indexG, indexB;
26 bool validR, validG, validB;
32 float sineR = sinf(coordX + mpiR1R * offset1) + cosf(coordY + mpiR2R * offset2);
33 float sineG = sinf(coordX + mpiR1G * offset1) + cosf(coordY + mpiR2G * offset2);
34 float sineB = sinf(coordX + mpiR1B * offset1) + cosf(coordY + mpiR2B * offset2);
40 validR = pixelGroup->
GetRadialIndex(i, &indexR, blurRangeR, rotation);
41 validG = pixelGroup->
GetRadialIndex(i, &indexG, blurRangeG, rotation + 120.0f);
42 validB = pixelGroup->
GetRadialIndex(i, &indexB, blurRangeB, rotation + 240.0f);
45 colorBuffer[i].
R = pixelColors[indexR].
R;
50 colorBuffer[i].
G = pixelColors[indexG].
G;
55 colorBuffer[i].
B = pixelColors[indexB].
B;
60 for (uint16_t i = 0; i < pixelCount; i++) {
61 pixelColors[i].
R = colorBuffer[i].
R;
62 pixelColors[i].
G = colorBuffer[i].
G;
63 pixelColors[i].
B = colorBuffer[i].
B;
Defines the PhaseOffsetR effect class for applying rotational phase offsets to pixel groups.
float ratio
A scaling ratio used for dynamic effect adjustments.
float Update()
Updates and calculates the next value of the waveform.
Interface for managing and interacting with a collection of pixels.
virtual RGBColor * GetColors()=0
Retrieves the array of colors for the pixel group.
virtual RGBColor * GetColorBuffer()=0
Retrieves the color buffer for the pixel group.
virtual Vector2D GetCoordinate(uint16_t count)=0
Retrieves the coordinate of a specific pixel.
virtual uint16_t GetPixelCount()=0
Retrieves the total number of pixels in the group.
virtual bool GetRadialIndex(uint16_t count, uint16_t *index, int pixels, float angle)=0
Retrieves a radial index for a given pixel based on distance and angle.
static const float MPI
Mathematical constant (3.14159265358979323846...).
static T Map(T value, T inLow, T inMax, T outMin, T outMax)
Maps a value from one range to another.
static T Constrain(T value, T minimum, T maximum)
Constrains a value between minimum and maximum.
FunctionGenerator fGenPhase2
Function generator for the second phase offset.
void ApplyEffect(IPixelGroup *pixelGroup) override
Applies the rotational phase offset effect to the given pixel group.
PhaseOffsetR(uint8_t pixels)
Constructs a PhaseOffsetR effect instance.
FunctionGenerator fGenRotation
Function generator for rotation transformations.
FunctionGenerator fGenPhase1
Function generator for the first phase offset.
const uint8_t pixels
Number of pixels to apply the effect to.
Represents an RGB color and provides methods for manipulation.
uint8_t B
Blue component of the color (0-255).
uint8_t G
Green component of the color (0-255).
uint8_t R
Red component of the color (0-255).
float X
The X-component of the 2D vector.
float Y
The Y-component of the 2D vector.