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

Cairo-backed Canvas implementation. More...

#include <aeongui/CairoCanvas.hpp>

Inheritance diagram for AeonGUI::CairoCanvas:
[legend]
Collaboration diagram for AeonGUI::CairoCanvas:
[legend]

Public Member Functions

 CairoCanvas ()
 Default constructor. Creates an empty canvas.
 CairoCanvas (uint32_t aWidth, uint32_t aHeight)
 Construct a canvas with the given viewport size.
 ~CairoCanvas () final
 Destructor. Releases Cairo resources.
void ResizeViewport (uint32_t aWidth, uint32_t aHeight) final
 Resize the rendering viewport.
const uint8_t * GetPixels () const final
 Get a pointer to the raw pixel data.
size_t GetWidth () const final
 Get the width of the canvas in pixels.
size_t GetHeight () const final
 Get the height of the canvas in pixels.
size_t GetStride () const final
 Get the stride (bytes per row) of the pixel buffer.
void Clear () final
 Clear the canvas to transparent.
void Draw (const Path &aPath) final
 Draw a path using the current fill and stroke settings.
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) final
 Draw a raster image.
void DrawText (const std::string &aText, double aX, double aY, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle) final
double MeasureText (const std::string &aText, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle) const final
void SetFillColor (const ColorAttr &aColor) final
 Set the fill color.
const ColorAttr & GetFillColor () const final
 Get the current fill color.
void SetStrokeColor (const ColorAttr &aColor) final
 Set the stroke color.
const ColorAttr & GetStrokeColor () const final
 Get the current stroke color.
void SetStrokeWidth (double aWidth) final
 Set the stroke width.
double GetStrokeWidth () const final
 Get the current stroke width.
void SetStrokeOpacity (double aWidth) final
 Set the stroke opacity.
double GetStrokeOpacity () const final
 Get the current stroke opacity.
void SetFillOpacity (double aWidth) final
 Set the fill opacity.
double GetFillOpacity () const final
 Get the current fill opacity.
void SetOpacity (double aWidth) final
 Set the global opacity.
double GetOpacity () const final
 Get the current global opacity.
void SetViewBox (const ViewBox &aViewBox, const PreserveAspectRatio &aPreserveAspectRatio) final
 Set the SVG viewBox and preserveAspectRatio.
void SetTransform (const Matrix2x3 &aMatrix) final
 Replace the current transformation matrix.
void Transform (const Matrix2x3 &aMatrix) final
 Pre-multiply the current transformation matrix.
void * GetNativeSurface () const final
 Get the native rendering surface handle.
Public Member Functions inherited from AeonGUI::Canvas
virtual ~Canvas ()=0
 Virtual destructor.

Detailed Description

Cairo-backed Canvas implementation.

Provides software rasterization of paths, images, and text using the Cairo 2D graphics library.

Constructor & Destructor Documentation

◆ CairoCanvas()

AeonGUI::CairoCanvas::CairoCanvas ( uint32_t aWidth,
uint32_t aHeight )

Construct a canvas with the given viewport size.

Parameters
aWidthInitial width in pixels.
aHeightInitial height in pixels.

Member Function Documentation

◆ Clear()

void AeonGUI::CairoCanvas::Clear ( )
finalvirtual

Clear the canvas to transparent.

Implements AeonGUI::Canvas.

◆ Draw()

void AeonGUI::CairoCanvas::Draw ( const Path & aPath)
finalvirtual

Draw a path using the current fill and stroke settings.

Parameters
aPathThe path to draw.

Implements AeonGUI::Canvas.

◆ DrawImage()

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

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].

Implements AeonGUI::Canvas.

◆ DrawText()

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

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.

Implements AeonGUI::Canvas.

◆ GetFillColor()

const ColorAttr & AeonGUI::CairoCanvas::GetFillColor ( ) const
finalvirtual

Get the current fill color.

Returns
Reference to the current fill color.

Implements AeonGUI::Canvas.

◆ GetFillOpacity()

double AeonGUI::CairoCanvas::GetFillOpacity ( ) const
finalvirtual

Get the current fill opacity.

Returns
Opacity in [0.0, 1.0].

Implements AeonGUI::Canvas.

◆ GetHeight()

size_t AeonGUI::CairoCanvas::GetHeight ( ) const
finalvirtual

Get the height of the canvas in pixels.

Returns
Height in pixels.

Implements AeonGUI::Canvas.

◆ GetNativeSurface()

void * AeonGUI::CairoCanvas::GetNativeSurface ( ) const
finalvirtual

Get the native rendering surface handle.

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

Implements AeonGUI::Canvas.

◆ GetOpacity()

double AeonGUI::CairoCanvas::GetOpacity ( ) const
finalvirtual

Get the current global opacity.

Returns
Opacity in [0.0, 1.0].

Implements AeonGUI::Canvas.

◆ GetPixels()

const uint8_t * AeonGUI::CairoCanvas::GetPixels ( ) const
finalvirtual

Get a pointer to the raw pixel data.

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

Implements AeonGUI::Canvas.

◆ GetStride()

size_t AeonGUI::CairoCanvas::GetStride ( ) const
finalvirtual

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

Returns
Stride in bytes.

Implements AeonGUI::Canvas.

◆ GetStrokeColor()

const ColorAttr & AeonGUI::CairoCanvas::GetStrokeColor ( ) const
finalvirtual

Get the current stroke color.

Returns
Reference to the current stroke color.

Implements AeonGUI::Canvas.

◆ GetStrokeOpacity()

double AeonGUI::CairoCanvas::GetStrokeOpacity ( ) const
finalvirtual

Get the current stroke opacity.

Returns
Opacity in [0.0, 1.0].

Implements AeonGUI::Canvas.

◆ GetStrokeWidth()

double AeonGUI::CairoCanvas::GetStrokeWidth ( ) const
finalvirtual

Get the current stroke width.

Returns
Stroke width in user units.

Implements AeonGUI::Canvas.

◆ GetWidth()

size_t AeonGUI::CairoCanvas::GetWidth ( ) const
finalvirtual

Get the width of the canvas in pixels.

Returns
Width in pixels.

Implements AeonGUI::Canvas.

◆ MeasureText()

double AeonGUI::CairoCanvas::MeasureText ( const std::string & aText,
const std::string & aFontFamily,
double aFontSize,
int aFontWeight,
int aFontStyle ) const
finalvirtual

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.

Implements AeonGUI::Canvas.

◆ ResizeViewport()

void AeonGUI::CairoCanvas::ResizeViewport ( uint32_t aWidth,
uint32_t aHeight )
finalvirtual

Resize the rendering viewport.

Parameters
aWidthNew width in pixels.
aHeightNew height in pixels.

Implements AeonGUI::Canvas.

◆ SetFillColor()

void AeonGUI::CairoCanvas::SetFillColor ( const ColorAttr & aColor)
finalvirtual

Set the fill color.

Parameters
aColorThe fill color to set.

Implements AeonGUI::Canvas.

◆ SetFillOpacity()

void AeonGUI::CairoCanvas::SetFillOpacity ( double aWidth)
finalvirtual

Set the fill opacity.

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

Implements AeonGUI::Canvas.

◆ SetOpacity()

void AeonGUI::CairoCanvas::SetOpacity ( double aWidth)
finalvirtual

Set the global opacity.

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

Implements AeonGUI::Canvas.

◆ SetStrokeColor()

void AeonGUI::CairoCanvas::SetStrokeColor ( const ColorAttr & aColor)
finalvirtual

Set the stroke color.

Parameters
aColorThe stroke color to set.

Implements AeonGUI::Canvas.

◆ SetStrokeOpacity()

void AeonGUI::CairoCanvas::SetStrokeOpacity ( double aWidth)
finalvirtual

Set the stroke opacity.

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

Implements AeonGUI::Canvas.

◆ SetStrokeWidth()

void AeonGUI::CairoCanvas::SetStrokeWidth ( double aWidth)
finalvirtual

Set the stroke width.

Parameters
aWidthThe stroke width in user units.

Implements AeonGUI::Canvas.

◆ SetTransform()

void AeonGUI::CairoCanvas::SetTransform ( const Matrix2x3 & aMatrix)
finalvirtual

Replace the current transformation matrix.

Parameters
aMatrixThe new 2x3 transformation matrix.

Implements AeonGUI::Canvas.

◆ SetViewBox()

void AeonGUI::CairoCanvas::SetViewBox ( const ViewBox & aViewBox,
const PreserveAspectRatio & aPreserveAspectRatio )
finalvirtual

Set the SVG viewBox and preserveAspectRatio.

Parameters
aViewBoxThe viewBox rectangle.
aPreserveAspectRatioHow to align and scale.

Implements AeonGUI::Canvas.

◆ Transform()

void AeonGUI::CairoCanvas::Transform ( const Matrix2x3 & aMatrix)
finalvirtual

Pre-multiply the current transformation matrix.

Parameters
aMatrixThe matrix to concatenate.

Implements AeonGUI::Canvas.


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