AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
AeonGUI::Canvas Class Referenceabstract

Abstract 2D rendering surface. More...

#include <aeongui/Canvas.hpp>

Inheritance diagram for AeonGUI::Canvas:
[legend]

Public Member Functions

virtual void ResizeViewport (uint32_t aWidth, uint32_t aHeight)=0
 Resize the rendering viewport.
virtual const uint8_t * GetPixels () const =0
 Get a pointer to the raw pixel data.
virtual size_t GetWidth () const =0
 Get the width of the canvas in pixels.
virtual size_t GetHeight () const =0
 Get the height of the canvas in pixels.
virtual size_t GetStride () const =0
 Get the stride (bytes per row) of the pixel buffer.
virtual void Clear ()=0
 Clear the canvas to transparent.
virtual void SetFillColor (const ColorAttr &aColor)=0
 Set the fill color.
virtual const ColorAttr & GetFillColor () const =0
 Get the current fill color.
virtual void SetStrokeColor (const ColorAttr &aColor)=0
 Set the stroke color.
virtual const ColorAttr & GetStrokeColor () const =0
 Get the current stroke color.
virtual void SetStrokeWidth (double aWidth)=0
 Set the stroke width.
virtual double GetStrokeWidth () const =0
 Get the current stroke width.
virtual void SetStrokeOpacity (double aWidth)=0
 Set the stroke opacity.
virtual double GetStrokeOpacity () const =0
 Get the current stroke opacity.
virtual void SetFillOpacity (double aWidth)=0
 Set the fill opacity.
virtual double GetFillOpacity () const =0
 Get the current fill opacity.
virtual void SetOpacity (double aWidth)=0
 Set the global opacity.
virtual double GetOpacity () const =0
 Get the current global opacity.
virtual void Draw (const Path &aPath)=0
 Draw a path using the current fill and stroke settings.
virtual void DrawImage (const uint8_t *aPixels, size_t aImageWidth, size_t aImageHeight, size_t aImageStride, double aX, double aY, double aWidth, double aHeight, double aOpacity)=0
 Draw a raster image.
virtual void DrawText (const std::string &aText, double aX, double aY, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle)=0
virtual double MeasureText (const std::string &aText, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle) const =0
virtual void SetViewBox (const ViewBox &aViewBox, const PreserveAspectRatio &aPreserveAspectRatio)=0
 Set the SVG viewBox and preserveAspectRatio.
virtual void SetTransform (const Matrix2x3 &aMatrix)=0
 Replace the current transformation matrix.
virtual void Transform (const Matrix2x3 &aMatrix)=0
 Pre-multiply the current transformation matrix.
virtual void * GetNativeSurface () const =0
 Get the native rendering surface handle.
virtual ~Canvas ()=0
 Virtual destructor.

Detailed Description

Abstract 2D rendering surface.

Provides a pure virtual interface for drawing paths, images, and text onto a pixel buffer. Concrete implementations (e.g. CairoCanvas) supply the actual rendering back-end.

Member Function Documentation

◆ Clear()

virtual void AeonGUI::Canvas::Clear ( )
pure virtual

Clear the canvas to transparent.

Implemented in AeonGUI::CairoCanvas.

◆ Draw()

virtual void AeonGUI::Canvas::Draw ( const Path & aPath)
pure virtual

Draw a path using the current fill and stroke settings.

Parameters
aPathThe path to draw.

Implemented in AeonGUI::CairoCanvas.

◆ DrawImage()

virtual void AeonGUI::Canvas::DrawImage ( const uint8_t * aPixels,
size_t aImageWidth,
size_t aImageHeight,
size_t aImageStride,
double aX,
double aY,
double aWidth,
double aHeight,
double aOpacity )
pure virtual

Draw a raster image.

Parameters
aPixelsPointer to source BGRA pixel data.
aImageWidthWidth of the source image in pixels.
aImageHeightHeight of the source image in pixels.
aImageStrideStride of the source image in bytes.
aXDestination X coordinate.
aYDestination Y coordinate.
aWidthDestination width in user units.
aHeightDestination height in user units.
aOpacityOpacity for the image [0.0, 1.0].

Implemented in AeonGUI::CairoCanvas.

◆ DrawText()

virtual void AeonGUI::Canvas::DrawText ( const std::string & aText,
double aX,
double aY,
const std::string & aFontFamily,
double aFontSize,
int aFontWeight,
int aFontStyle )
pure virtual

Draw text at the given position using the specified font description and size.

Parameters
aTextThe UTF-8 text string to render.
aXThe x coordinate for the text start position.
aYThe y coordinate for the text baseline.
aFontFamilyFont family name (e.g. "sans-serif").
aFontSizeFont size in CSS pixels.
aFontWeightCSS font weight (400 = normal, 700 = bold).
aFontStyle0 = normal, 1 = italic, 2 = oblique.

Implemented in AeonGUI::CairoCanvas.

◆ GetFillColor()

virtual const ColorAttr & AeonGUI::Canvas::GetFillColor ( ) const
pure virtual

Get the current fill color.

Returns
Reference to the current fill color.

Implemented in AeonGUI::CairoCanvas.

◆ GetFillOpacity()

virtual double AeonGUI::Canvas::GetFillOpacity ( ) const
pure virtual

Get the current fill opacity.

Returns
Opacity in [0.0, 1.0].

Implemented in AeonGUI::CairoCanvas.

◆ GetHeight()

virtual size_t AeonGUI::Canvas::GetHeight ( ) const
pure virtual

Get the height of the canvas in pixels.

Returns
Height in pixels.

Implemented in AeonGUI::CairoCanvas.

◆ GetNativeSurface()

virtual void * AeonGUI::Canvas::GetNativeSurface ( ) const
pure virtual

Get the native rendering surface handle.

Returns
Pointer to the underlying surface (e.g. cairo_surface_t).

Implemented in AeonGUI::CairoCanvas.

◆ GetOpacity()

virtual double AeonGUI::Canvas::GetOpacity ( ) const
pure virtual

Get the current global opacity.

Returns
Opacity in [0.0, 1.0].

Implemented in AeonGUI::CairoCanvas.

◆ GetPixels()

virtual const uint8_t * AeonGUI::Canvas::GetPixels ( ) const
pure virtual

Get a pointer to the raw pixel data.

Returns
Pointer to BGRA pixel data, or nullptr if empty.

Implemented in AeonGUI::CairoCanvas.

◆ GetStride()

virtual size_t AeonGUI::Canvas::GetStride ( ) const
pure virtual

Get the stride (bytes per row) of the pixel buffer.

Returns
Stride in bytes.

Implemented in AeonGUI::CairoCanvas.

◆ GetStrokeColor()

virtual const ColorAttr & AeonGUI::Canvas::GetStrokeColor ( ) const
pure virtual

Get the current stroke color.

Returns
Reference to the current stroke color.

Implemented in AeonGUI::CairoCanvas.

◆ GetStrokeOpacity()

virtual double AeonGUI::Canvas::GetStrokeOpacity ( ) const
pure virtual

Get the current stroke opacity.

Returns
Opacity in [0.0, 1.0].

Implemented in AeonGUI::CairoCanvas.

◆ GetStrokeWidth()

virtual double AeonGUI::Canvas::GetStrokeWidth ( ) const
pure virtual

Get the current stroke width.

Returns
Stroke width in user units.

Implemented in AeonGUI::CairoCanvas.

◆ GetWidth()

virtual size_t AeonGUI::Canvas::GetWidth ( ) const
pure virtual

Get the width of the canvas in pixels.

Returns
Width in pixels.

Implemented in AeonGUI::CairoCanvas.

◆ MeasureText()

virtual double AeonGUI::Canvas::MeasureText ( const std::string & aText,
const std::string & aFontFamily,
double aFontSize,
int aFontWeight,
int aFontStyle ) const
pure virtual

Measure the width of text with the given font parameters.

Parameters
aTextThe UTF-8 text string to measure.
aFontFamilyFont family name.
aFontSizeFont size in CSS pixels.
aFontWeightCSS font weight.
aFontStyleFont style (0=normal, 1=italic, 2=oblique).
Returns
The logical width in CSS pixels.

Implemented in AeonGUI::CairoCanvas.

◆ ResizeViewport()

virtual void AeonGUI::Canvas::ResizeViewport ( uint32_t aWidth,
uint32_t aHeight )
pure virtual

Resize the rendering viewport.

Parameters
aWidthNew width in pixels.
aHeightNew height in pixels.

Implemented in AeonGUI::CairoCanvas.

◆ SetFillColor()

virtual void AeonGUI::Canvas::SetFillColor ( const ColorAttr & aColor)
pure virtual

Set the fill color.

Parameters
aColorThe fill color to set.

Implemented in AeonGUI::CairoCanvas.

◆ SetFillOpacity()

virtual void AeonGUI::Canvas::SetFillOpacity ( double aWidth)
pure virtual

Set the fill opacity.

Parameters
aWidthOpacity value in the range [0.0, 1.0].

Implemented in AeonGUI::CairoCanvas.

◆ SetOpacity()

virtual void AeonGUI::Canvas::SetOpacity ( double aWidth)
pure virtual

Set the global opacity.

Parameters
aWidthOpacity value in the range [0.0, 1.0].

Implemented in AeonGUI::CairoCanvas.

◆ SetStrokeColor()

virtual void AeonGUI::Canvas::SetStrokeColor ( const ColorAttr & aColor)
pure virtual

Set the stroke color.

Parameters
aColorThe stroke color to set.

Implemented in AeonGUI::CairoCanvas.

◆ SetStrokeOpacity()

virtual void AeonGUI::Canvas::SetStrokeOpacity ( double aWidth)
pure virtual

Set the stroke opacity.

Parameters
aWidthOpacity value in the range [0.0, 1.0].

Implemented in AeonGUI::CairoCanvas.

◆ SetStrokeWidth()

virtual void AeonGUI::Canvas::SetStrokeWidth ( double aWidth)
pure virtual

Set the stroke width.

Parameters
aWidthThe stroke width in user units.

Implemented in AeonGUI::CairoCanvas.

◆ SetTransform()

virtual void AeonGUI::Canvas::SetTransform ( const Matrix2x3 & aMatrix)
pure virtual

Replace the current transformation matrix.

Parameters
aMatrixThe new 2x3 transformation matrix.

Implemented in AeonGUI::CairoCanvas.

◆ SetViewBox()

virtual void AeonGUI::Canvas::SetViewBox ( const ViewBox & aViewBox,
const PreserveAspectRatio & aPreserveAspectRatio )
pure virtual

Set the SVG viewBox and preserveAspectRatio.

Parameters
aViewBoxThe viewBox rectangle.
aPreserveAspectRatioHow to align and scale.

Implemented in AeonGUI::CairoCanvas.

◆ Transform()

virtual void AeonGUI::Canvas::Transform ( const Matrix2x3 & aMatrix)
pure virtual

Pre-multiply the current transformation matrix.

Parameters
aMatrixThe matrix to concatenate.

Implemented in AeonGUI::CairoCanvas.


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