ESP32-HUB75-MatrixPanel-DMA/examples/AuroraDemo/PatternTunnel.hpp
mrcodetastic f77a5cac9c Make AuroraDemo great again.
And test out ChatGPT's attempt to create some effects as well.
2024-07-29 17:23:53 +01:00

66 lines
1.4 KiB
C++

// Codetastic 2024
// ChatGPT was used to create this.
#ifndef PatternTunnel_H
#define PatternTunnel_H
class PatternTunnel : public Drawable {
private:
uint8_t circlePositions[5] = {0, 6, 12, 18, 24}; // Initial positions of circles
public:
PatternTunnel() {
name = (char *)"Tunnel";
}
// Function to draw a circle on the matrix
void drawCircle(int centerX, int centerY, int radius, CRGB color) {
for (int y = -radius; y <= radius; y++) {
for (int x = -radius; x <= radius; x++) {
if (x*x + y*y <= radius*radius) {
int drawX = centerX + x;
int drawY = centerY + y;
if (drawX >= 0 && drawX < VPANEL_W && drawY >= 0 && drawY < VPANEL_H) {
effects.leds[XY(drawX, drawY)] = color;
}
}
}
}
}
void start()
{
};
unsigned int drawFrame() {
effects.DimAll(250);
// Draw circles
for (int i = 0; i < 5; i++) {
int radius = circlePositions[i] % 32;
CRGB color = CHSV(map(radius, 0, 31, 0, 255), 255, 255);
drawCircle(VPANEL_W / 2, VPANEL_H / 2, radius, color);
// Move circles forward
circlePositions[i]++;
// Reset the position if the circle is out of bounds
if (circlePositions[i] >= 32) {
circlePositions[i] = 0;
}
}
effects.ShowFrame();
return 0;
}
};
#endif