|
AeonGUI
A portable video game graphic user interface library.
|
Abstract 2D rendering surface. More...
#include </d/a/AeonGUI/AeonGUI/include/aeongui/Canvas.hpp>
Classes | |
| struct | PickBounds |
| Device-space bounding box for a pick-tracked element. More... | |
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 | 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)=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 | Save ()=0 |
| Save the current graphics state (transform, clipping, etc.). | |
| virtual void | Restore ()=0 |
| Restore the previously saved graphics state. | |
| virtual void * | GetNativeSurface () const =0 |
| Get the native rendering surface handle. | |
| virtual void | PushGroup ()=0 |
| Begin an offscreen group for filter/compositing. | |
| virtual void | PopGroup ()=0 |
| End an offscreen group and composite back. | |
| virtual void | ApplyDropShadow (double aDx, double aDy, double aStdDeviationX, double aStdDeviationY, const Color &aFloodColor, double aFloodOpacity)=0 |
| Apply a drop-shadow filter to the current group content. | |
| void | SetHitTesting (bool aHitTesting) |
| Enable or disable hit-testing mode. | |
| bool | IsHitTesting () const |
| Query whether the canvas is in hit-testing mode. | |
| void | SetPickId (uint8_t aPickId) |
| Set the current pick ID for subsequent Draw calls. | |
| virtual uint8_t | PickAtPoint (double aX, double aY) const =0 |
| Read the pick ID at the given viewport coordinates. | |
| virtual void | ResetPick ()=0 |
| Clear the pick buffer and reset for a new frame. | |
| virtual void | SetClipRect (double aX, double aY, double aWidth, double aHeight)=0 |
| Set a device-space clip rectangle on both render and pick surfaces. | |
| virtual std::unique_ptr< Path > | CreatePath () const =0 |
| Create a new Path object suitable for this canvas backend. | |
| virtual | ~Canvas ()=0 |
| Virtual destructor. | |
| const PickBounds & | GetPickBounds (uint8_t aId) const |
| Get the cached device-space bounds for a pick ID. | |
Protected Attributes | |
| bool | mHitTesting {false} |
| True when in hit-testing mode. | |
| uint8_t | mPickId {0} |
| Current pick ID for Draw calls. | |
| std::array< PickBounds, 256 > | mPickBounds {} |
| Cached device-space bounds per pick ID. | |
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.
|
pure virtual |
Apply a drop-shadow filter to the current group content.
Must be called between PushGroup() and PopGroup(). The implementation captures the group, creates a blurred shadow, offsets it, and composites it under the original content.
| aDx | Horizontal offset of the shadow. |
| aDy | Vertical offset of the shadow. |
| aStdDeviationX | Horizontal Gaussian blur standard deviation. |
| aStdDeviationY | Vertical Gaussian blur standard deviation. |
| aFloodColor | Shadow color. |
| aFloodOpacity | Shadow opacity [0.0, 1.0]. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Clear the canvas to transparent.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Create a new Path object suitable for this canvas backend.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Draw a path using the current fill and stroke settings.
| aPath | The path to draw. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Draw a raster image.
| aPixels | Pointer to source BGRA pixel data. |
| aImageWidth | Width of the source image in pixels. |
| aImageHeight | Height of the source image in pixels. |
| aImageStride | Stride of the source image in bytes. |
| aX | Destination X coordinate. |
| aY | Destination Y coordinate. |
| aWidth | Destination width in user units. |
| aHeight | Destination height in user units. |
| aOpacity | Opacity for the image [0.0, 1.0]. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Draw text at the given position using the specified font description and size.
| aText | The UTF-8 text string to render. |
| aX | The x coordinate for the text start position. |
| aY | The y coordinate for the text baseline. |
| aFontFamily | Font family name (e.g. "sans-serif"). |
| aFontSize | Font size in CSS pixels. |
| aFontWeight | CSS font weight (400 = normal, 700 = bold). |
| aFontStyle | 0 = normal, 1 = italic, 2 = oblique. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Draw text along a path. Each glyph is positioned and rotated to follow the path.
| aText | The UTF-8 text string to render. |
| aPath | The path to follow. |
| aStartOffset | Starting distance along the path in user units. |
| aFontFamily | Font family name. |
| aFontSize | Font size in CSS pixels. |
| aFontWeight | CSS font weight (400 = normal, 700 = bold). |
| aFontStyle | 0 = normal, 1 = italic, 2 = oblique. |
| aReverse | If true, render glyph order against the path direction. |
| aClosed | If true, treat the path as closed for offset wrapping. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Get the current fill color.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Get the current fill opacity.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Get the height of the canvas in pixels.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Get the native rendering surface handle.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Get the current global opacity.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
inline |
Get the cached device-space bounds for a pick ID.
| aId | Pick ID (1-255). |
|
pure virtual |
Get a pointer to the raw pixel data.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Get the stride (bytes per row) of the pixel buffer.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Get the current stroke color.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Get the current stroke opacity.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Get the current stroke width.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Get the width of the canvas in pixels.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
inline |
Query whether the canvas is in hit-testing mode.
|
pure virtual |
Measure the width of text with the given font parameters.
| aText | The UTF-8 text string to measure. |
| aFontFamily | Font family name. |
| aFontSize | Font size in CSS pixels. |
| aFontWeight | CSS font weight. |
| aFontStyle | Font style (0=normal, 1=italic, 2=oblique). |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Read the pick ID at the given viewport coordinates.
| aX | X coordinate in viewport pixels. |
| aY | Y coordinate in viewport pixels. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
End an offscreen group and composite back.
Pops the group pushed by PushGroup() and paints it back to the underlying surface.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Begin an offscreen group for filter/compositing.
All subsequent drawing is redirected to a temporary surface. Call PopGroup() to retrieve and composite the result.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Clear the pick buffer and reset for a new frame.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Resize the rendering viewport.
| aWidth | New width in pixels. |
| aHeight | New height in pixels. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Restore the previously saved graphics state.
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Save the current graphics state (transform, clipping, etc.).
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Set a device-space clip rectangle on both render and pick surfaces.
Must be called between Save() and Restore().
| aX | X of clip rect (device pixels). |
| aY | Y of clip rect (device pixels). |
| aWidth | Width (device pixels). |
| aHeight | Height (device pixels). |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Set the fill color.
| aColor | The fill color to set. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Set the fill opacity.
| aWidth | Opacity value in the range [0.0, 1.0]. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
inline |
Enable or disable hit-testing mode.
When true, filter effects (PushGroup/PopGroup/ApplyDropShadow) are skipped to avoid expensive pixel processing during elementFromPoint traversals.
| aHitTesting | True to enable hit-testing mode, false to disable. |
|
pure virtual |
Set the global opacity.
| aWidth | Opacity value in the range [0.0, 1.0]. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
inline |
Set the current pick ID for subsequent Draw calls.
When non-zero, Draw(path) also fills the path on the internal pick buffer using this value. Set to 0 to disable pick rendering for non-geometry nodes.
| aPickId | The pick ID to assign (0 disables pick rendering). |
|
pure virtual |
Set the stroke color.
| aColor | The stroke color to set. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Set the stroke opacity.
| aWidth | Opacity value in the range [0.0, 1.0]. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Set the stroke width.
| aWidth | The stroke width in user units. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Replace the current transformation matrix.
| aMatrix | The new 2x3 transformation matrix. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Set the SVG viewBox and preserveAspectRatio.
| aViewBox | The viewBox rectangle. |
| aPreserveAspectRatio | How to align and scale. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.
|
pure virtual |
Pre-multiply the current transformation matrix.
| aMatrix | The matrix to concatenate. |
Implemented in AeonGUI::CairoCanvas, and AeonGUI::SkiaCanvas.