12
13
14
15
16
17
19template <
typename RGB_T =
RGB565>
26 void resize(size_t newWidth, size_t newHeight)
override {
27 surface_.resize(newWidth, newHeight);
31 void setPixel(size_t x, size_t y, RGB_T color)
override {
32 surface_.setPixel(x, mappedY(y), color);
36 RGB_T
getPixel(size_t x, size_t y)
const override {
37 return surface_.getPixel(x, mappedY(y));
44 void drawLine(size_t x0, size_t y0, size_t x1, size_t y1,
45 RGB_T color)
override {
46 surface_.drawLine(x0, mappedY(y0), x1, mappedY(y1), color);
50 void drawRect(size_t x, size_t y, size_t w, size_t h, RGB_T color)
override {
51 surface_.drawRect(x, mappedTopOfBox(y, h), w, h, color);
55 void fillRect(size_t x, size_t y, size_t w, size_t h, RGB_T color)
override {
56 surface_.fillRect(x, mappedTopOfBox(y, h), w, h, color);
60 void drawCircle(size_t x, size_t y, size_t r, RGB_T color)
override {
61 surface_.drawCircle(x, mappedY(y), r, color);
65 void fillCircle(size_t x, size_t y, size_t r, RGB_T color)
override {
66 surface_.fillCircle(x, mappedY(y), r, color);
70 void drawSprite(size_t x, size_t y,
const ISurface<RGB_T>& sprite,
71 RGB_T invisibleColor = RGB_T(0))
override {
72 surface_.drawSprite(x, mappedTopOfBox(y, sprite.height()), sprite,
78 RGB_T clearColor = RGB_T(0))
override {
79 surface_.clearSprite(x, mappedTopOfBox(y, sprite.height()), sprite,
84 void copySprite(size_t x, size_t y,
const ISurface<RGB_T>& sprite)
override {
85 surface_.copySprite(x, mappedTopOfBox(y, sprite.height()), sprite);
97 uint8_t scale = 1, uint8_t spacing = 1,
98 uint8_t lineSpacing = 1)
override {
99 const size_t textHeight =
100 surface_.font().measureTextHeight(text, scale, lineSpacing);
102 static_cast<int16_t>(
103 mappedTopOfBox(
static_cast<size_t>(y), textHeight)),
104 text, foreground, background, opaque, scale, spacing,
131
132
133
134
135
136
137
138
139
140
141
142
144 if (height() == 0 || objectHeight == 0) {
148 const uint64_t topY =
static_cast<uint64_t>(y) + objectHeight - 1U;
149 if (topY >= height()) {
152 return mappedY(
static_cast<size_t>(topY));
Bottom-left Cartesian coordinate view over an existing Surface.
Definition: CartesianView.h:20
void drawLine(size_t x0, size_t y0, size_t x1, size_t y1, RGB_T color) override
Draws a line using Cartesian bottom-left coordinates.
Definition: CartesianView.h:44
void fillCircle(size_t x, size_t y, size_t r, RGB_T color) override
Fills a circle using Cartesian bottom-left coordinates.
Definition: CartesianView.h:65
void copySprite(size_t x, size_t y, const ISurface< RGB_T > &sprite) override
Copies pixels from the view into a sprite using Cartesian coordinates.
Definition: CartesianView.h:84
const ISurface< RGB_T > & surface() const
Returns the wrapped surface as a const reference.
Definition: CartesianView.h:118
ISurface< RGB_T > & surface_
Definition: CartesianView.h:124
CartesianView(ISurface< RGB_T > &surface)
Creates a Cartesian view over the provided surface.
Definition: CartesianView.h:23
void resize(size_t newWidth, size_t newHeight) override
Resizes the wrapped surface.
Definition: CartesianView.h:26
size_t height() const override
Returns the wrapped surface height.
Definition: CartesianView.h:92
void drawText(int16_t x, int16_t y, const char *text, RGB565 foreground, RGB565 background=RGB565(0), bool opaque=false, uint8_t scale=1, uint8_t spacing=1, uint8_t lineSpacing=1) override
Draws text with the given lower-left text box origin.
Definition: CartesianView.h:95
ISurface< RGB_T > & surface()
Returns the wrapped surface as a reference.
Definition: CartesianView.h:115
const uint8_t * data() const override
Returns the wrapped byte buffer.
Definition: CartesianView.h:109
size_t mappedTopOfBox(size_t y, size_t objectHeight) const
Maps the logical bottom-left Y and object height to the top Y coordinate for box-based operations.
Definition: CartesianView.h:143
size_t mappedY(size_t y) const
Definition: CartesianView.h:128
IFont< RGB_T > & font() override
Returns the font of the wrapped surface.
Definition: CartesianView.h:121
void fillRect(size_t x, size_t y, size_t w, size_t h, RGB_T color) override
Fills a rectangle using Cartesian bottom-left coordinates.
Definition: CartesianView.h:55
void drawRect(size_t x, size_t y, size_t w, size_t h, RGB_T color) override
Draws a rectangle outline using Cartesian bottom-left coordinates.
Definition: CartesianView.h:50
void drawSprite(size_t x, size_t y, const ISurface< RGB_T > &sprite, RGB_T invisibleColor=RGB_T(0)) override
Draws a sprite with its lower-left corner anchored at the given position.
Definition: CartesianView.h:70
size_t width() const override
Returns the wrapped surface width.
Definition: CartesianView.h:89
void setPixel(size_t x, size_t y, RGB_T color) override
Sets a pixel using Cartesian bottom-left coordinates.
Definition: CartesianView.h:31
size_t size() const override
Returns the wrapped buffer size in bytes.
Definition: CartesianView.h:112
void clearSprite(size_t x, size_t y, ISurface< RGB_T > &sprite, RGB_T clearColor=RGB_T(0)) override
Clears the area occupied by a sprite anchored at its lower-left corner.
Definition: CartesianView.h:77
RGB_T getPixel(size_t x, size_t y) const override
Returns a pixel using Cartesian bottom-left coordinates.
Definition: CartesianView.h:36
void clear(RGB_T color=RGB_T(0)) override
Clears the wrapped surface.
Definition: CartesianView.h:41
void drawCircle(size_t x, size_t y, size_t r, RGB_T color) override
Draws a circle outline using Cartesian bottom-left coordinates.
Definition: CartesianView.h:60
Font rendering interface for TinyGPU-compatible framebuffers.
Definition: IFont.h:19
RGB color stored in 16-bit RGB565 format.
Definition: RGB565.h:13
RGB565(uint16_t packed)
Creates a color from a packed RGB565 value.
Definition: RGB565.h:23
Definition: AVIWriter.h:9