ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Test.cpp
Go to the documentation of this file.
1#include "Test.h"
2
4
5void Test::ApplyEffect(IPixelGroup* pixelGroup) {
6 uint16_t pixelCount = pixelGroup->GetPixelCount();
7 RGBColor* pixelColors = pixelGroup->GetColors();
8 RGBColor* colorBuffer = pixelGroup->GetColorBuffer();
9
10 for (uint16_t i = 0; i < pixelCount; i++) {
11 colorBuffer[i].R = 0;
12 colorBuffer[i].G = 0;
13 colorBuffer[i].B = 0;
14 }
15
16 for (uint16_t i = 0; i < pixelCount; i++) {
17 uint16_t leftIndex = i;
18 uint16_t rightIndex = i;
19 uint16_t upIndex = i;
20 uint16_t downIndex = i;
21
22 uint8_t d = fGenD.Update();
23
24 bool validLeft = pixelGroup->GetLeftIndex(leftIndex, &leftIndex);
25 bool validRight = pixelGroup->GetRightIndex(rightIndex, &rightIndex);
26 bool validUp = pixelGroup->GetUpIndex(upIndex, &upIndex);
27 bool validDown = pixelGroup->GetDownIndex(downIndex, &downIndex);
28
29 if (validLeft) {
30 colorBuffer[leftIndex].R = 100;
31 }
32 if (validRight) {
33 colorBuffer[rightIndex].G = 100;
34 }
35 if (validUp) {
36 colorBuffer[upIndex].B = 100;
37 }
38 if (validDown) {
39 colorBuffer[downIndex].R = colorBuffer[downIndex].R == 100 ? 100 : d;
40 colorBuffer[downIndex].G = colorBuffer[downIndex].G == 100 ? 100 : d;
41 colorBuffer[downIndex].B = colorBuffer[downIndex].B == 100 ? 100 : d;
42 }
43 }
44
45 for (uint16_t i = 0; i < pixelCount; i++) {
46 pixelColors[i].R = colorBuffer[i].R;
47 pixelColors[i].G = colorBuffer[i].G;
48 pixelColors[i].B = colorBuffer[i].B;
49 }
50}
Defines the Test effect class for debugging and memory issue detection.
float Update()
Updates and calculates the next value of the waveform.
Interface for managing and interacting with a collection of pixels.
Definition IPixelGroup.h:25
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 bool GetLeftIndex(uint16_t count, uint16_t *leftIndex)=0
Retrieves the index of the pixel to the left of a given pixel.
virtual bool GetRightIndex(uint16_t count, uint16_t *rightIndex)=0
Retrieves the index of the pixel to the right of a given pixel.
virtual uint16_t GetPixelCount()=0
Retrieves the total number of pixels in the group.
virtual bool GetUpIndex(uint16_t count, uint16_t *upIndex)=0
Retrieves the index of the pixel above a given pixel.
virtual bool GetDownIndex(uint16_t count, uint16_t *downIndex)=0
Retrieves the index of the pixel below a given pixel.
Represents an RGB color and provides methods for manipulation.
Definition RGBColor.h:23
uint8_t B
Blue component of the color (0-255).
Definition RGBColor.h:27
uint8_t G
Green component of the color (0-255).
Definition RGBColor.h:26
uint8_t R
Red component of the color (0-255).
Definition RGBColor.h:25
Test()
Constructs a Test effect instance.
Definition Test.cpp:3
FunctionGenerator fGenD
Function generator for the debug intensity values.
Definition Test.h:28
void ApplyEffect(IPixelGroup *pixelGroup) override
Applies the debugging effect to the given pixel group.
Definition Test.cpp:5