TinyGPU
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ISurface< RGB_T > Class Template Referenceabstract

Abstract framebuffer and drawing interface for TinyGPU surfaces. More...

#include <ISurface.h>

Inheritance diagram for ISurface< RGB_T >:
Inheritance graph
[legend]

Public Member Functions

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 drawRoundRect (size_t x, size_t y, size_t w, size_t h, size_t radius, RGB_T color)
 
virtual void fillRoundRect (size_t x, size_t y, size_t w, size_t h, size_t radius, RGB_T color)
 
virtual void drawArc (size_t cx, size_t cy, size_t r, float startDeg, float endDeg, RGB_T color, uint8_t thickness=1)
 
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.
 
virtual bool contains (size_t x, size_t y)=0
 Checks if the given coordinates are within the surface bounds.
 
virtual void pushClipRect (size_t x, size_t y, size_t w, size_t h)
 
virtual void popClipRect ()
 
virtual bool isClipVisible (size_t x, size_t y) const
 

Detailed Description

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

Abstract framebuffer and drawing interface for TinyGPU surfaces.

Implementations expose pixel access, primitive drawing, sprite operations, and text rendering through a common API.

Note
The coordinate x=0 and y=0 corresponds to the top-left corner of the surface. The x coordinate increases to the right and the y coordinate increases downwards.

Constructor & Destructor Documentation

◆ ~ISurface()

virtual ~ISurface ( )
virtualdefault

Destroys the framebuffer interface.

Member Function Documentation

◆ begin()

virtual bool begin ( )
pure virtual

Initializes the framebuffer surface.

Implemented in SurfaceBase< PixelT >, SurfaceBase< RGB565 >, SurfaceBase< bool >, and FrameBuffer< RGB_T, SurfaceT >.

◆ clear()

virtual void clear ( RGB_T  color = RGB_T(0))
pure virtual

Clears the framebuffer with a single color.

Implemented in SurfaceBase< PixelT >, FrameBuffer< RGB_T, SurfaceT >, and CartesianView< RGB_T >.

◆ clearSprite()

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

Clears the area covered by a sprite.

Implemented in SurfaceBase< PixelT >, FrameBuffer< RGB_T, SurfaceT >, and CartesianView< RGB_T >.

◆ contains()

virtual bool contains ( size_t  x,
size_t  y 
)
pure virtual

Checks if the given coordinates are within the surface bounds.

Implemented in CartesianView< RGB_T >, FrameBuffer< RGB_T, SurfaceT >, SurfaceBase< PixelT >, SurfaceBase< RGB565 >, SurfaceBase< bool >, and WindowedSurface< RGB_T >.

◆ copySprite()

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

Copies pixels from the framebuffer into a sprite.

Implemented in SurfaceBase< PixelT >, FrameBuffer< RGB_T, SurfaceT >, and CartesianView< RGB_T >.

◆ data()

virtual const uint8_t * data ( ) const
pure virtual

◆ drawArc()

virtual void drawArc ( size_t  cx,
size_t  cy,
size_t  r,
float  startDeg,
float  endDeg,
RGB_T  color,
uint8_t  thickness = 1 
)
inlinevirtual

Draws a stroked arc around center (cx, cy) with radius r, sweeping from startDeg to endDeg (degrees, clockwise on screen since y increases downward; 0 deg = +X/3 o'clock direction; pass endDeg < startDeg to wrap through 0, e.g. 350 -> 370). thickness draws that many concentric 1px radii ending at r. Used for circular progress/spinner widgets.

◆ drawCircle()

virtual void drawCircle ( size_t  x,
size_t  y,
size_t  r,
RGB_T  color 
)
pure virtual

Draws a circle outline.

Implemented in SurfaceBase< PixelT >, FrameBuffer< RGB_T, SurfaceT >, and CartesianView< RGB_T >.

◆ drawLine()

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

Draws a line between two points.

Implemented in SurfaceBase< PixelT >, FrameBuffer< RGB_T, SurfaceT >, and CartesianView< RGB_T >.

◆ drawRect()

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

Draws a rectangle outline.

Implemented in SurfaceBase< PixelT >, FrameBuffer< RGB_T, SurfaceT >, and CartesianView< RGB_T >.

◆ drawRoundRect()

virtual void drawRoundRect ( size_t  x,
size_t  y,
size_t  w,
size_t  h,
size_t  radius,
RGB_T  color 
)
inlinevirtual

Draws a rectangle outline with rounded corners.

Parameters
radiusCorner radius in pixels; clamped to min(w,h)/2.

Implemented here (not left pure virtual) purely in terms of drawLine(), setPixel() and contains(), so every existing ISurface implementation gets a correct default for free. Override only to provide a faster, hardware-specific version.

◆ drawSprite()

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

Draws a sprite using an optional transparent color.

Implemented in SurfaceBase< PixelT >, FrameBuffer< RGB_T, SurfaceT >, and CartesianView< RGB_T >.

◆ drawText()

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 
)
pure virtual

Draws UTF-8 text using the configured font.

Implemented in SurfaceBase< PixelT >, and FrameBuffer< RGB_T, SurfaceT >.

◆ end()

virtual void end ( )
pure virtual

Closes the framebuffer and releases resources.

Implemented in SurfaceBase< PixelT >, SurfaceBase< RGB565 >, SurfaceBase< bool >, and FrameBuffer< RGB_T, SurfaceT >.

◆ fillCircle()

virtual void fillCircle ( size_t  x,
size_t  y,
size_t  r,
RGB_T  color 
)
pure virtual

◆ fillRect()

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

◆ fillRoundRect()

virtual void fillRoundRect ( size_t  x,
size_t  y,
size_t  w,
size_t  h,
size_t  radius,
RGB_T  color 
)
inlinevirtual

Fills a rectangle with rounded corners.

Parameters
radiusCorner radius in pixels; clamped to min(w,h)/2.

Row-scan fill: each row's horizontal inset comes from the corner circle's equation (0 for the straight middle rows), then the existing fillRect() draws that single row. Produces the same shape as the classic "middle band + two rounded end caps" decomposition, just expressed as one loop. Implemented here (not pure virtual) so every existing ISurface implementation gets it for free.

◆ font()

virtual IFont< RGB_T > & font ( )
pure virtual

Returns the currently set font for text rendering.

Implemented in FrameBuffer< RGB_T, SurfaceT >, CartesianView< RGB_T >, SurfaceBase< PixelT >, SurfaceBase< RGB565 >, and SurfaceBase< bool >.

◆ getPixel()

virtual RGB_T getPixel ( size_t  x,
size_t  y 
) const
pure virtual

◆ height()

virtual size_t height ( ) const
pure virtual

◆ isClipVisible()

virtual bool isClipVisible ( size_t  x,
size_t  y 
) const
inlinevirtual

True if (x, y) lies within the currently active clip rect - always true if pushClipRect() was never called (see the default there). Exposed so code doing its own pixel math (drawArc(), the plotRoundRectCorner() helper below) can respect the same clip primitive drawing calls do.

Reimplemented in SurfaceBase< PixelT >, SurfaceBase< RGB565 >, and SurfaceBase< bool >.

◆ popClipRect()

virtual void popClipRect ( )
inlinevirtual

Restores whatever clip rect was active before the matching pushClipRect() call. Popping with no active push is a no-op.

Reimplemented in SurfaceBase< PixelT >, SurfaceBase< RGB565 >, and SurfaceBase< bool >.

◆ pushClipRect()

virtual void pushClipRect ( size_t  x,
size_t  y,
size_t  w,
size_t  h 
)
inlinevirtual

Restricts all subsequent drawing to the intersection of (x, y, w, h) and whatever clip rect is already active - a nested pushClipRect() call narrows further, never widens. Every drawing primitive on this surface (fillRect(), drawLine(), drawCircle(), drawSprite(), drawText(), ...) respects the currently active clip; reads (getPixel(), copySprite()) do not. Pair with a matching popClipRect() - typically wrapping one widget/container's own children so nothing they draw can spill past that widget's bounds.

Default: a no-op, so an ISurface implementation that doesn't override this (anything not deriving from SurfaceBase, which implements the actual clip stack) simply never clips - existing implementations keep drawing exactly as before.

Reimplemented in SurfaceBase< PixelT >, SurfaceBase< RGB565 >, and SurfaceBase< bool >.

◆ resize()

virtual bool resize ( size_t  newWidth,
size_t  newHeight 
)
pure virtual

◆ scroll()

virtual void scroll ( int  dx,
int  dy 
)
pure virtual

Scrolls the framebuffer content by the specified offsets.

Implemented in SurfaceBase< PixelT >, SurfaceBase< RGB565 >, SurfaceBase< bool >, and FrameBuffer< RGB_T, SurfaceT >.

◆ setPixel()

virtual void setPixel ( size_t  x,
size_t  y,
RGB_T  color 
)
pure virtual

Sets a pixel at the given position.

Implemented in SurfaceBase< PixelT >, CartesianView< RGB_T >, and FrameBuffer< RGB_T, SurfaceT >.

◆ size()

virtual size_t size ( ) const
pure virtual

◆ width()

virtual size_t width ( ) const
pure virtual

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