24 float theta = atan2f(dif.
Y, dif.
X);
25 float newDistance = (1.0f / distance) * 0.5f *
amplitude * 4.0f;
27 int offsetX = (int)(newDistance * cosf(theta));
28 int offsetY = (int)(newDistance * sinf(theta));
32 colorBuffer[i].
R = pixelColors[tIndex].
R;
33 colorBuffer[i].
G = pixelColors[tIndex].
G;
34 colorBuffer[i].
B = pixelColors[tIndex].
B;
43 pixelColors[i].
R = colorBuffer[i].
R;
44 pixelColors[i].
G = colorBuffer[i].
G;
45 pixelColors[i].
B = colorBuffer[i].
B;
Defines the Magnet effect class for creating magnetic distortion effects on pixel groups.
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 bool GetOffsetXYIndex(uint16_t count, uint16_t *index, int x1, int y1)=0
Retrieves an offset XY-axis index for a given pixel.
virtual uint16_t GetPixelCount()=0
Retrieves the total number of pixels in the group.
virtual Vector2D GetCenterCoordinate()=0
Retrieves the center coordinate of the pixel group.
float amplitude
The strength of the magnetic distortion.
void SetAmplitude(float amplitude)
Sets the amplitude of the magnetic distortion effect.
void SetPosition(Vector2D offset)
Sets the central position of the magnetic effect.
void ApplyEffect(IPixelGroup *pixelGroup) override
Applies the magnetic distortion effect to the given pixel group.
Magnet(float amplitude=0.5f)
Constructs a Magnet effect with a specified amplitude.
Vector2D offset
The central offset of the magnetic effect.
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).
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
float CalculateEuclideanDistance(const Vector2D &vector) const
Calculates the Euclidean distance between this vector and another Vector2D.
float X
The X-component of the 2D vector.
float Y
The Y-component of the 2D vector.