AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
Canvas.hpp
1/*
2Copyright (C) 2019,2020,2024,2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_CANVAS_H
17#define AEONGUI_CANVAS_H
18#include <cstdint>
19#include <cstddef>
20#include <vector>
21#include <memory>
22#include <string>
23#include "aeongui/Platform.hpp"
24#include "aeongui/DrawType.hpp"
25#include "aeongui/Color.hpp"
26#include "aeongui/Attribute.hpp"
27#include "aeongui/Matrix2x3.hpp"
28#include "aeongui/TextLayout.hpp"
29namespace AeonGUI
30{
31 class Path;
38 class Canvas
39 {
40 public:
45 virtual void ResizeViewport ( uint32_t aWidth, uint32_t aHeight ) = 0;
49 virtual const uint8_t* GetPixels() const = 0;
53 virtual size_t GetWidth() const = 0;
57 virtual size_t GetHeight() const = 0;
61 virtual size_t GetStride() const = 0;
63 virtual void Clear() = 0;
67 virtual void SetFillColor ( const ColorAttr& aColor ) = 0;
71 virtual const ColorAttr& GetFillColor() const = 0;
75 virtual void SetStrokeColor ( const ColorAttr& aColor ) = 0;
79 virtual const ColorAttr& GetStrokeColor() const = 0;
83 virtual void SetStrokeWidth ( double aWidth ) = 0;
87 virtual double GetStrokeWidth () const = 0;
91 virtual void SetStrokeOpacity ( double aWidth ) = 0;
95 virtual double GetStrokeOpacity () const = 0;
99 virtual void SetFillOpacity ( double aWidth ) = 0;
103 virtual double GetFillOpacity () const = 0;
107 virtual void SetOpacity ( double aWidth ) = 0;
111 virtual double GetOpacity () const = 0;
115 virtual void Draw ( const Path& aPath ) = 0;
127 virtual void DrawImage ( const uint8_t* aPixels,
128 size_t aImageWidth,
129 size_t aImageHeight,
130 size_t aImageStride,
131 double aX,
132 double aY,
133 double aWidth,
134 double aHeight,
135 double aOpacity ) = 0;
145 virtual void DrawText ( const std::string& aText, double aX, double aY,
146 const std::string& aFontFamily, double aFontSize,
147 int aFontWeight, int aFontStyle ) = 0;
156 virtual double MeasureText ( const std::string& aText,
157 const std::string& aFontFamily, double aFontSize,
158 int aFontWeight, int aFontStyle ) const = 0;
163 virtual void SetViewBox ( const ViewBox& aViewBox, const PreserveAspectRatio& aPreserveAspectRatio ) = 0;
167 virtual void SetTransform ( const Matrix2x3& aMatrix ) = 0;
171 virtual void Transform ( const Matrix2x3& aMatrix ) = 0;
175 virtual void* GetNativeSurface() const = 0;
177 virtual ~Canvas() = 0;
178 };
179}
180#endif
Platform-specific DLL import/export macros and compiler helpers.
Abstract 2D rendering surface.
Definition Canvas.hpp:39
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.
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 double GetFillOpacity() const =0
Get the current fill opacity.
virtual ~Canvas()=0
Virtual destructor.
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 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.
virtual size_t GetHeight() const =0
Get the height of the canvas in pixels.
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 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 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:32
SVG preserveAspectRatio attribute.
Definition Attribute.hpp:44
SVG viewBox attribute value.
Definition Attribute.hpp:31