-
Notifications
You must be signed in to change notification settings - Fork 0
/
Colors_test.hpp
43 lines (31 loc) · 949 Bytes
/
Colors_test.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#pragma once
template <class ConcretePainter>
class TestScreen: public Screen<ConcretePainter, TestScreen<ConcretePainter>> {
template <typename U>
friend class Widget;
public:
TestScreen() {
}
protected:
void onDraw(const Rect /*updateRect*/, const Rect /*excludeRect*/)
{
ConcretePainter painter;
constexpr int stripeHeight = 20;
const uint16_t numColors = this->height() / stripeHeight;
for (uint8_t i = 0; i < numColors; ++i)
{
painter.fillRect(Point{0, i * stripeHeight}, Size{this->width(), stripeHeight}, Color::fromHSV(i * 360 / numColors, 255, 255));
}
painter.fillRect(Point{0, numColors * stripeHeight}, Point{this->width(), this->height()}, Color::black());
}
private:
};
TestScreen<PainterImplementation> screen;
inline void setupExample()
{
tftInit();
screen.update();
}
inline void loopExample()
{
}