renderbug-cpp/lib/Figments/Surface.h

39 lines
1.0 KiB
C
Raw Normal View History

#pragma once
2021-03-29 08:10:55 +00:00
#include <FastLED.h>
2019-05-10 05:17:29 +00:00
#include "./Geometry.h"
2021-03-29 08:10:55 +00:00
#include <functional>
2019-05-10 05:17:29 +00:00
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);
2019-05-10 05:17:29 +00:00
2021-03-29 08:10:55 +00:00
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&)>;
2019-05-10 05:17:29 +00:00
void paintWith(BrushFunc func);
void paintShader(Shader shader);
2019-05-10 05:17:29 +00:00
const PhysicalCoordinates start;
const PhysicalCoordinates end;
const VirtualCoordinates virtStart;
const VirtualCoordinates virtEnd;
2019-05-10 05:17:29 +00:00
private:
Display* m_display;
uint8_t m_rotation = 0;
2019-05-10 05:17:29 +00:00
};