16#ifndef AEONGUI_CANVAS_H
17#define AEONGUI_CANVAS_H
25#include "aeongui/DrawType.hpp"
26#include "aeongui/Color.hpp"
27#include "aeongui/Attribute.hpp"
28#include "aeongui/Matrix2x3.hpp"
29#include "aeongui/TextLayout.hpp"
136 double aOpacity ) = 0;
146 virtual void DrawText (
const std::string& aText,
double aX,
double aY,
147 const std::string& aFontFamily,
double aFontSize,
148 int aFontWeight,
int aFontStyle ) = 0;
158 const std::string& aFontFamily,
double aFontSize,
159 int aFontWeight,
int aFontStyle )
const = 0;
175 const std::string& aFontFamily,
double aFontSize,
176 int aFontWeight,
int aFontStyle,
177 bool aReverse =
false,
bool aClosed =
false ) = 0;
227 double aStdDeviationX,
double aStdDeviationY,
228 const Color& aFloodColor,
double aFloodOpacity ) = 0;
274 virtual void SetClipRect (
double aX,
double aY,
double aWidth,
double aHeight ) = 0;
Abstract 2D rendering surface.
Definition Canvas.hpp:40
virtual double GetOpacity() const =0
Get the current global opacity.
virtual size_t GetStride() const =0
Get the stride (bytes per row) of the pixel buffer.
virtual const uint8_t * GetPixels() const =0
Get a pointer to the raw pixel data.
virtual const ColorAttr & GetFillColor() const =0
Get the current fill color.
virtual void SetStrokeColor(const ColorAttr &aColor)=0
Set the stroke color.
void SetPickId(uint8_t aPickId)
Set the current pick ID for subsequent Draw calls.
Definition Canvas.hpp:254
virtual std::unique_ptr< Path > CreatePath() const =0
Create a new Path object suitable for this canvas backend.
virtual void PopGroup()=0
End an offscreen group and composite back.
virtual void SetOpacity(double aWidth)=0
Set the global opacity.
virtual void Draw(const Path &aPath)=0
Draw a path using the current fill and stroke settings.
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.
virtual void PushGroup()=0
Begin an offscreen group for filter/compositing.
virtual double GetFillOpacity() const =0
Get the current fill opacity.
virtual ~Canvas()=0
Virtual destructor.
virtual void Save()=0
Save the current graphics state (transform, clipping, etc.).
const PickBounds & GetPickBounds(uint8_t aId) const
Get the cached device-space bounds for a pick ID.
Definition Canvas.hpp:294
void SetHitTesting(bool aHitTesting)
Enable or disable hit-testing mode.
Definition Canvas.hpp:236
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 size_t GetWidth() const =0
Get the width of the canvas in pixels.
virtual double GetStrokeOpacity() const =0
Get the current stroke opacity.
virtual void Restore()=0
Restore the previously saved graphics state.
virtual void ResetPick()=0
Clear the pick buffer and reset for a new frame.
virtual double GetStrokeWidth() const =0
Get the current stroke width.
virtual void SetStrokeWidth(double aWidth)=0
Set the stroke width.
virtual void ResizeViewport(uint32_t aWidth, uint32_t aHeight)=0
Resize the rendering viewport.
bool IsHitTesting() const
Query whether the canvas is in hit-testing mode.
Definition Canvas.hpp:243
virtual size_t GetHeight() const =0
Get the height of the canvas in pixels.
bool mHitTesting
True when in hit-testing mode.
Definition Canvas.hpp:299
virtual void SetViewBox(const ViewBox &aViewBox, const PreserveAspectRatio &aPreserveAspectRatio)=0
Set the SVG viewBox and preserveAspectRatio.
virtual void SetFillOpacity(double aWidth)=0
Set the fill opacity.
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
uint8_t mPickId
Current pick ID for Draw calls.
Definition Canvas.hpp:300
virtual void SetClipRect(double aX, double aY, double aWidth, double aHeight)=0
Set a device-space clip rectangle on both render and pick surfaces.
std::array< PickBounds, 256 > mPickBounds
Cached device-space bounds per pick ID.
Definition Canvas.hpp:301
virtual void Clear()=0
Clear the canvas to transparent.
virtual void SetFillColor(const ColorAttr &aColor)=0
Set the fill color.
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 const ColorAttr & GetStrokeColor() const =0
Get the current stroke color.
virtual void DrawText(const std::string &aText, double aX, double aY, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle)=0
virtual void SetStrokeOpacity(double aWidth)=0
Set the stroke opacity.
virtual void SetTransform(const Matrix2x3 &aMatrix)=0
Replace the current transformation matrix.
virtual uint8_t PickAtPoint(double aX, double aY) const =0
Read the pick ID at the given viewport coordinates.
virtual double MeasureText(const std::string &aText, const std::string &aFontFamily, double aFontSize, int aFontWeight, int aFontStyle) const =0
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
Device-space bounding box for a pick-tracked element.
Definition Canvas.hpp:284
double x1
Left edge (device pixels).
Definition Canvas.hpp:285
double y1
Top edge (device pixels).
Definition Canvas.hpp:286
double y2
Bottom edge (device pixels).
Definition Canvas.hpp:288
double x2
Right edge (device pixels).
Definition Canvas.hpp:287
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