-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathPainter.h
executable file
·79 lines (62 loc) · 3.2 KB
/
Painter.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef PAINTER_H
#define PAINTER_H
#include <stdint.h>
#include "IPainter.h"
#include "IDebugPainter.h"
#include "../GFXFont.h"
#include "../FontDefinitions.h"
#include "../Color565.h"
#include "../Widgets/Icon.h"
class Painter : public IPainter
{
GFXfont _fontList[4];
GFXfont _currentFont;
uint8_t _currentFontHeight;
uint16_t _cursorX;
uint16_t _cursorY;
IDebugPainter* _debugPainter;
protected:
volatile uint16_t* _framebuffer;
uint16_t _framebufferWidth;
uint16_t _framebufferHeight;
public:
Painter(volatile uint16_t* framebuffer, uint16_t framebufferWidth, uint8_t framebufferHeight);
// Debugging
void SetDebugOverlay(IDebugPainter* debugPainter);
// Primitives
void DrawLine(int16_t x0, int16_t y0, int16_t x1, int16_t y1, uint16_t color) override;
void DrawFastVLine(int16_t x, int16_t y, int16_t h, uint16_t color) override;
void DrawFastHLine(int16_t x, int16_t y, int16_t l, uint16_t color) override;
// Rectangle
void DrawRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) override;
void DrawFillRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) override;
void DrawFillRoundRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t radius,
uint16_t color) override;
void DrawStripedRectangle(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t firstColor,
uint16_t secondColor, uint8_t tilt, uint8_t offset) override;
// Circle
void DrawCircle(int16_t x, int16_t y, int16_t r, uint16_t color) override;
void DrawFillCircle(int16_t x, int16_t y, int16_t r, uint16_t color) override;
void DrawCircleQuarter(int16_t x, int16_t y, int16_t r, uint8_t cornername, uint16_t color) override;
void DrawFillCircleQuarter(int16_t x0, int16_t y0, int16_t r, uint8_t cornername, int16_t delta,
uint16_t color) override;
// Misc
void DrawImage(const uint8_t* data, uint16_t x, uint16_t y, uint16_t width, uint16_t height) override;
void DrawPixel(uint16_t x, uint16_t y, uint16_t color) override;
virtual void DrawIcon(const Icon* image, uint16_t x, uint16_t y, uint16_t color) override;
uint16_t ProcessByte(uint8_t data, uint16_t x, uint16_t xIndex, uint16_t yPos, uint16_t height, uint16_t color);
virtual void Draw2BitIcon(const Icon* image, uint16_t x, uint16_t y, uint16_t foregroundColor,
uint16_t backgroundColor, bool transparency) override;
uint16_t GetColor(uint16_t foregroundColor, uint16_t backgroundColor, uint8_t color_bits);
uint16_t GetPixel(uint16_t x, uint16_t y);
void Fill(uint16_t fillColor) override;
void Dim() override;
// Text Related
void SetFont(Font font) override;
void DrawCharacter(unsigned char c, int16_t x, int16_t y, uint16_t color) override;
virtual void DrawText(uint16_t x, uint16_t y, const char* text, uint16_t color, TextAlign align,
uint16_t textblockwidth) override;
uint16_t GetStringFramebufferWidth(const char* str) override;
uint8_t GetCurrentFontHeight() override;
};
#endif /* PAINTER_H */