pitrix/include/SimpleEffect.h
Fabian Schlenz a6af2829ee Better and more SimpleEffects.
* Calculations are done using doubles for much easier code.
* Binary flags instead of boolean variables for configuration.
* New effects sineline, barbershop and zigzag.
2020-11-06 22:33:37 +00:00

32 lines
1.3 KiB
C++

#pragma once
#include "Effect.h"
#include "prototypes.h"
#include <cmath>
#define SE_CYCLE_COLORS 1 // Slowly cycle through the rainbow.
#define SE_RANDOM_PIXEL_COLORS 2 // Every pixel gets a random color every frame.
#define SE_ONLY_POSITIVE 4 // Only use colors, not white. This is equivalent to running your output through abs()
#define SE_FADEOUT 8 // Fades the old image out. Returning 0 doesn't change the pixel's value.
#define SE_RANDOM_STATIC_COLOR 16 // Sets a random static color at start of the effect.
#define SE_DEBUG 32 // Prints debug messages.
class SimpleEffect : public Effect {
protected:
Window* window = &Window::window_full; // Use a full screen window per default.
uint8_t _color = 0;
uint16_t _flags;
String _name;
simple_effect_t _method;
public:
SimpleEffect(String name, uint16_t flags, simple_effect_t method): _name { name }, _method { method } {
_flags = flags;
if (_flags & SE_RANDOM_STATIC_COLOR) {
_color = random8();
_flags &= ~SE_CYCLE_COLORS & ~SE_RANDOM_PIXEL_COLORS;
}
};
void loop(uint16_t ms) override;
String get_name() { return _name; };
boolean can_be_shown_with_clock() { return true; }
};