renderbug-cpp/lib/Figments/Surface.h

39 lines
1.0 KiB
C++

#pragma once
#include <FastLED.h>
#include "./Geometry.h"
#include <functional>
class Display;
class Surface {
public:
Surface(Display* dpy, const VirtualCoordinates& start, const VirtualCoordinates& end);
Surface(Display* dpy, const VirtualCoordinates& start, const VirtualCoordinates& end, uint8_t rotation);
Surface& operator=(const CRGB& color);
Surface& operator+=(const CRGB& color);
template<typename T>
Surface& operator|=(const T& val) {
paintWith([&](CRGB& pixel) {
pixel |= val;
});
return *this;
}
using Shader = std::function<void(CRGB&, const VirtualCoordinates& virtPos, const PhysicalCoordinates& realPos, const VirtualCoordinates& surfacePos)>;
using BrushFunc = std::function<void(CRGB&)>;
void paintWith(BrushFunc func);
void paintShader(Shader shader);
const PhysicalCoordinates start;
const PhysicalCoordinates end;
const VirtualCoordinates virtStart;
const VirtualCoordinates virtEnd;
private:
Display* m_display;
uint8_t m_rotation = 0;
};