16#ifndef AEONGUI_CAIROCANVAS_H
17#define AEONGUI_CAIROCANVAS_H
20#include "aeongui/Canvas.hpp"
23typedef struct _cairo_surface cairo_surface_t;
25typedef struct _cairo cairo_t;
43 DLL
CairoCanvas ( uint32_t aWidth, uint32_t aHeight );
46 DLL
void ResizeViewport ( uint32_t aWidth, uint32_t aHeight ) final;
47 DLL const uint8_t*
GetPixels() const final;
51 DLL
void Clear() final;
52 DLL
void Draw ( const
Path& aPath ) final;
53 DLL
void DrawImage ( const uint8_t* aPixels,
61 double aOpacity ) final;
62 DLL
void DrawText ( const std::
string& aText,
double aX,
double aY,
63 const std::
string& aFontFamily,
double aFontSize,
64 int aFontWeight,
int aFontStyle ) final;
66 const std::
string& aFontFamily,
double aFontSize,
67 int aFontWeight,
int aFontStyle ) const final;
71 const std::
string& aFontFamily,
double aFontSize,
72 int aFontWeight,
int aFontStyle,
73 bool aReverse = false,
bool aClosed = false ) final;
89 DLL
void Save() final;
95 double aStdDeviationX,
double aStdDeviationY,
96 const
Color& aFloodColor,
double aFloodOpacity ) final;
97 DLL uint8_t
PickAtPoint (
double aX,
double aY ) const final;
99 DLL
void SetClipRect (
double aX,
double aY,
double aWidth,
double aHeight ) final;
102 void InitPickSurface ( uint32_t aWidth, uint32_t aHeight );
103 void DestroyPickSurface();
104 cairo_surface_t* mCairoSurface{};
105 cairo_t* mCairoContext{};
106 cairo_surface_t* mPickSurface{};
107 cairo_t* mPickContext{};
108 ColorAttr mFillColor{};
109 ColorAttr mStrokeColor{};
110 double mStrokeWidth{1};
111 double mStrokeOpacity{1};
112 double mFillOpacity{1};
void DrawText(const std::string &aText, double aX, double aY, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle) final
Definition CairoCanvas.cpp:393
void SetStrokeColor(const ColorAttr &aColor) final
Set the stroke color.
Definition CairoCanvas.cpp:112
void SetViewBox(const ViewBox &aViewBox, const PreserveAspectRatio &aPreserveAspectRatio) final
Set the SVG viewBox and preserveAspectRatio.
Definition CairoCanvas.cpp:630
void DrawTextOnPath(const std::string &aText, const Path &aPath, double aStartOffset, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle, bool aReverse=false, bool aClosed=false) final
Definition CairoCanvas.cpp:489
void Save() final
Save the current graphics state (transform, clipping, etc.).
Definition CairoCanvas.cpp:713
const ColorAttr & GetStrokeColor() const final
Get the current stroke color.
Definition CairoCanvas.cpp:117
double GetStrokeOpacity() const final
Get the current stroke opacity.
Definition CairoCanvas.cpp:137
void SetOpacity(double aWidth) final
Set the global opacity.
Definition CairoCanvas.cpp:152
void SetStrokeOpacity(double aWidth) final
Set the stroke opacity.
Definition CairoCanvas.cpp:132
void Clear() final
Clear the canvas to transparent.
Definition CairoCanvas.cpp:82
CairoCanvas()
Default constructor. Creates an empty canvas.
void Draw(const Path &aPath) final
Draw a path using the current fill and stroke settings.
Definition CairoCanvas.cpp:162
void * GetNativeSurface() const final
Get the native rendering surface handle.
Definition CairoCanvas.cpp:729
void ResizeViewport(uint32_t aWidth, uint32_t aHeight) final
Resize the rendering viewport.
Definition CairoCanvas.cpp:41
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.
Definition CairoCanvas.cpp:262
void SetTransform(const Matrix2x3 &aMatrix) final
Replace the current transformation matrix.
Definition CairoCanvas.cpp:685
double GetOpacity() const final
Get the current global opacity.
Definition CairoCanvas.cpp:157
double GetFillOpacity() const final
Get the current fill opacity.
Definition CairoCanvas.cpp:147
uint8_t PickAtPoint(double aX, double aY) const final
Read the pick ID at the given viewport coordinates.
Definition CairoCanvas.cpp:947
size_t GetWidth() const final
Get the width of the canvas in pixels.
Definition CairoCanvas.cpp:70
size_t GetStride() const final
Get the stride (bytes per row) of the pixel buffer.
Definition CairoCanvas.cpp:78
std::unique_ptr< Path > CreatePath() const final
Create a new Path object suitable for this canvas backend.
Definition CairoCanvas.cpp:988
void SetFillColor(const ColorAttr &aColor) final
Set the fill color.
Definition CairoCanvas.cpp:102
const uint8_t * GetPixels() const final
Get a pointer to the raw pixel data.
Definition CairoCanvas.cpp:61
void Transform(const Matrix2x3 &aMatrix) final
Pre-multiply the current transformation matrix.
Definition CairoCanvas.cpp:699
double MeasureText(const std::string &aText, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle) const final
Definition CairoCanvas.cpp:460
size_t GetHeight() const final
Get the height of the canvas in pixels.
Definition CairoCanvas.cpp:74
void SetStrokeWidth(double aWidth) final
Set the stroke width.
Definition CairoCanvas.cpp:122
double GetStrokeWidth() const final
Get the current stroke width.
Definition CairoCanvas.cpp:127
void SetFillOpacity(double aWidth) final
Set the fill opacity.
Definition CairoCanvas.cpp:142
void PushGroup() final
Begin an offscreen group for filter/compositing.
Definition CairoCanvas.cpp:734
~CairoCanvas() final
Destructor. Releases Cairo resources.
Definition CairoCanvas.cpp:89
void ApplyDropShadow(double aDx, double aDy, double aStdDeviationX, double aStdDeviationY, const Color &aFloodColor, double aFloodOpacity) final
Apply a drop-shadow filter to the current group content.
Definition CairoCanvas.cpp:844
const ColorAttr & GetFillColor() const final
Get the current fill color.
Definition CairoCanvas.cpp:107
void ResetPick() final
Clear the pick buffer and reset for a new frame.
Definition CairoCanvas.cpp:934
void PopGroup() final
End an offscreen group and composite back.
Definition CairoCanvas.cpp:739
void SetClipRect(double aX, double aY, double aWidth, double aHeight) final
Set a device-space clip rectangle on both render and pick surfaces.
Definition CairoCanvas.cpp:967
void Restore() final
Restore the previously saved graphics state.
Definition CairoCanvas.cpp:721
Abstract 2D rendering surface.
Definition Canvas.hpp:40
2x3 affine transformation matrix.
Definition Matrix2x3.hpp:37
Abstract base class for renderable path data.
Definition Path.hpp:40
SVG preserveAspectRatio attribute.
Definition Attribute.hpp:44
SVG viewBox attribute value.
Definition Attribute.hpp:31
Pixel Color Union. The Color union allows access to each unsigned 8 bit RGBA color component individu...
Definition Color.hpp:185