2022-06-11 09:02:27 +00:00
|
|
|
#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);
|
2022-06-11 09:02:27 +00:00
|
|
|
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);
|
2022-06-11 09:02:27 +00:00
|
|
|
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
|
|
|
|
2022-06-11 09:02:27 +00:00
|
|
|
void paintWith(BrushFunc func);
|
|
|
|
void paintShader(Shader shader);
|
2019-05-10 05:17:29 +00:00
|
|
|
|
|
|
|
const PhysicalCoordinates start;
|
|
|
|
const PhysicalCoordinates end;
|
2022-06-11 09:02:27 +00:00
|
|
|
const VirtualCoordinates virtStart;
|
|
|
|
const VirtualCoordinates virtEnd;
|
2019-05-10 05:17:29 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Display* m_display;
|
2022-06-11 09:02:27 +00:00
|
|
|
uint8_t m_rotation = 0;
|
2019-05-10 05:17:29 +00:00
|
|
|
};
|