TinyGPU
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CartesianView< RGB_T > Class Template Reference

Bottom-left Cartesian coordinate view over an existing Surface. More...

#include <CartesianView.h>

Inheritance diagram for CartesianView< RGB_T >:
Inheritance graph
[legend]
Collaboration diagram for CartesianView< RGB_T >:
Collaboration graph
[legend]

Public Member Functions

 CartesianView (ISurface< RGB_T > &surface)
 Creates a Cartesian view over the provided surface.
 
void resize (size_t newWidth, size_t newHeight) override
 Resizes the wrapped surface.
 
void setPixel (size_t x, size_t y, RGB_T color) override
 Sets a pixel using Cartesian bottom-left coordinates.
 
RGB_T getPixel (size_t x, size_t y) const override
 Returns a pixel using Cartesian bottom-left coordinates.
 
void clear (RGB_T color=RGB_T(0)) override
 Clears the wrapped surface.
 
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.
 
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.
 
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.
 
void drawCircle (size_t x, size_t y, size_t r, RGB_T color) override
 Draws a circle outline using Cartesian bottom-left coordinates.
 
void fillCircle (size_t x, size_t y, size_t r, RGB_T color) override
 Fills a circle using Cartesian bottom-left coordinates.
 
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.
 
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.
 
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.
 
size_t width () const override
 Returns the wrapped surface width.
 
size_t height () const override
 Returns the wrapped surface height.
 
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.
 
const uint8_t * data () const override
 Returns the wrapped byte buffer.
 
size_t size () const override
 Returns the wrapped buffer size in bytes.
 
ISurface< RGB_T > & surface ()
 Returns the wrapped surface as a reference.
 
const ISurface< RGB_T > & surface () const
 Returns the wrapped surface as a const reference.
 
IFont< RGB_T > & font () override
 Returns the font of the wrapped surface.
 
- Public Member Functions inherited from ISurface< RGB_T >
virtual ~ISurface ()=default
 Destroys the framebuffer interface.
 
virtual bool begin ()=0
 Initializes the framebuffer surface.
 
virtual void end ()=0
 Closes the framebuffer and releases resources.
 
virtual bool resize (size_t newWidth, size_t newHeight)=0
 Resizes the framebuffer surface.
 
virtual void setPixel (size_t x, size_t y, RGB_T color)=0
 Sets a pixel at the given position.
 
virtual RGB_T getPixel (size_t x, size_t y) const =0
 Returns the pixel at the given position.
 
virtual void scroll (int dx, int dy)=0
 Scrolls the framebuffer content by the specified offsets.
 
virtual void clear (RGB_T color=RGB_T(0))=0
 Clears the framebuffer with a single color.
 
virtual void drawLine (size_t x0, size_t y0, size_t x1, size_t y1, RGB_T color)=0
 Draws a line between two points.
 
virtual void drawRect (size_t x, size_t y, size_t w, size_t h, RGB_T color)=0
 Draws a rectangle outline.
 
virtual void fillRect (size_t x, size_t y, size_t w, size_t h, RGB_T color)=0
 Fills a rectangle.
 
virtual void drawCircle (size_t x, size_t y, size_t r, RGB_T color)=0
 Draws a circle outline.
 
virtual void fillCircle (size_t x, size_t y, size_t r, RGB_T color)=0
 Fills a circle.
 
virtual void drawSprite (size_t x, size_t y, const ISurface< RGB_T > &sprite, RGB_T invisibleColor=RGB_T(0))=0
 Draws a sprite using an optional transparent color.
 
virtual void clearSprite (size_t x, size_t y, ISurface< RGB_T > &sprite, RGB_T clearColor=RGB_T(0))=0
 Clears the area covered by a sprite.
 
virtual void copySprite (size_t x, size_t y, const ISurface< RGB_T > &sprite)=0
 Copies pixels from the framebuffer into a sprite.
 
virtual size_t width () const =0
 Returns the framebuffer width in pixels.
 
virtual size_t height () const =0
 Returns the framebuffer height in pixels.
 
virtual void drawText (int16_t x, int16_t y, const char *text, RGB_T foreground, RGB_T background=RGB_T(0), bool opaque=false, uint8_t scale=1, uint8_t spacing=1, uint8_t lineSpacing=1)=0
 Draws UTF-8 text using the configured font.
 
virtual IFont< RGB_T > & font ()=0
 Returns the currently set font for text rendering.
 
virtual const uint8_t * data () const =0
 Provides access to the framebuffer as a byte buffer.
 
virtual size_t size () const =0
 Provides the total data size in bytes.
 

Protected Member Functions

size_t mappedY (size_t y) const
 
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.
 

Protected Attributes

ISurface< RGB_T > & surface_
 

Detailed Description

template<typename RGB_T = RGB565>
class tinygpu::CartesianView< RGB_T >

Bottom-left Cartesian coordinate view over an existing Surface.

CartesianView wraps a Surface and remaps the logical y-axis so that (0, 0) refers to the lower-left corner while preserving the wrapped surface storage and export format.

Constructor & Destructor Documentation

◆ CartesianView()

CartesianView ( ISurface< RGB_T > &  surface)
inlineexplicit

Creates a Cartesian view over the provided surface.

Member Function Documentation

◆ clear()

void clear ( RGB_T  color = RGB_T(0))
inlineoverridevirtual

Clears the wrapped surface.

Implements ISurface< RGB_T >.

◆ clearSprite()

void clearSprite ( size_t  x,
size_t  y,
ISurface< RGB_T > &  sprite,
RGB_T  clearColor = RGB_T(0) 
)
inlineoverridevirtual

Clears the area occupied by a sprite anchored at its lower-left corner.

Implements ISurface< RGB_T >.

◆ copySprite()

void copySprite ( size_t  x,
size_t  y,
const ISurface< RGB_T > &  sprite 
)
inlineoverridevirtual

Copies pixels from the view into a sprite using Cartesian coordinates.

Implements ISurface< RGB_T >.

◆ data()

const uint8_t * data ( ) const
inlineoverridevirtual

Returns the wrapped byte buffer.

Implements ISurface< RGB_T >.

◆ drawCircle()

void drawCircle ( size_t  x,
size_t  y,
size_t  r,
RGB_T  color 
)
inlineoverridevirtual

Draws a circle outline using Cartesian bottom-left coordinates.

Implements ISurface< RGB_T >.

◆ drawLine()

void drawLine ( size_t  x0,
size_t  y0,
size_t  x1,
size_t  y1,
RGB_T  color 
)
inlineoverridevirtual

Draws a line using Cartesian bottom-left coordinates.

Implements ISurface< RGB_T >.

◆ drawRect()

void drawRect ( size_t  x,
size_t  y,
size_t  w,
size_t  h,
RGB_T  color 
)
inlineoverridevirtual

Draws a rectangle outline using Cartesian bottom-left coordinates.

Implements ISurface< RGB_T >.

◆ drawSprite()

void drawSprite ( size_t  x,
size_t  y,
const ISurface< RGB_T > &  sprite,
RGB_T  invisibleColor = RGB_T(0) 
)
inlineoverridevirtual

Draws a sprite with its lower-left corner anchored at the given position.

Implements ISurface< RGB_T >.

◆ drawText()

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 
)
inlineoverride

Draws text with the given lower-left text box origin.

◆ fillCircle()

void fillCircle ( size_t  x,
size_t  y,
size_t  r,
RGB_T  color 
)
inlineoverridevirtual

Fills a circle using Cartesian bottom-left coordinates.

Implements ISurface< RGB_T >.

◆ fillRect()

void fillRect ( size_t  x,
size_t  y,
size_t  w,
size_t  h,
RGB_T  color 
)
inlineoverridevirtual

Fills a rectangle using Cartesian bottom-left coordinates.

Implements ISurface< RGB_T >.

◆ font()

IFont< RGB_T > & font ( )
inlineoverridevirtual

Returns the font of the wrapped surface.

Implements ISurface< RGB_T >.

◆ getPixel()

RGB_T getPixel ( size_t  x,
size_t  y 
) const
inlineoverridevirtual

Returns a pixel using Cartesian bottom-left coordinates.

Implements ISurface< RGB_T >.

◆ height()

size_t height ( ) const
inlineoverridevirtual

Returns the wrapped surface height.

Implements ISurface< RGB_T >.

◆ mappedTopOfBox()

size_t mappedTopOfBox ( size_t  y,
size_t  objectHeight 
) const
inlineprotected

Maps the logical bottom-left Y and object height to the top Y coordinate for box-based operations.

For rectangles, sprites, and text, this computes the top Y (in Cartesian coordinates), then maps it to the wrapped surface's Y. Returns 0 if the computed top Y is out of bounds.

Parameters
yLogical bottom Y (Cartesian, bottom-left origin)
objectHeightHeight of the object (rectangle, sprite, or text)
Returns
size_t Mapped Y coordinate for the top of the box in the wrapped surface

◆ mappedY()

size_t mappedY ( size_t  y) const
inlineprotected

Maps a logical Cartesian Y coordinate (bottom-left origin) to the wrapped surface's Y (top-left origin).

◆ resize()

void resize ( size_t  newWidth,
size_t  newHeight 
)
inlineoverridevirtual

Resizes the wrapped surface.

Implements ISurface< RGB_T >.

◆ setPixel()

void setPixel ( size_t  x,
size_t  y,
RGB_T  color 
)
inlineoverridevirtual

Sets a pixel using Cartesian bottom-left coordinates.

Implements ISurface< RGB_T >.

◆ size()

size_t size ( ) const
inlineoverridevirtual

Returns the wrapped buffer size in bytes.

Implements ISurface< RGB_T >.

◆ surface() [1/2]

ISurface< RGB_T > & surface ( )
inline

Returns the wrapped surface as a reference.

◆ surface() [2/2]

const ISurface< RGB_T > & surface ( ) const
inline

Returns the wrapped surface as a const reference.

◆ width()

size_t width ( ) const
inlineoverridevirtual

Returns the wrapped surface width.

Implements ISurface< RGB_T >.

Member Data Documentation

◆ surface_

ISurface<RGB_T>& surface_
protected

The documentation for this class was generated from the following file: