1.10 |
Manages a unique drawing surface and context. More...
#include <canvas.h>
Public Member Functions | |
Canvas (const shared_cairo_surface_t &surface) noexcept | |
Construct a canvas with an already existing surface. | |
Canvas (const shared_cairo_surface_t &surface, PixelFormat format) noexcept | |
Construct a canvas with an already existing surface, and specify the format of the surface the canvas create a copy to. | |
Canvas (const Size &size, PixelFormat format=PixelFormat::argb8888) noexcept | |
Construct a canvas with the specified format and size. | |
Canvas (const SizeF &size, PixelFormat format=PixelFormat::argb8888) noexcept | |
Construct a canvas with the specified format and size. | |
EGT_NODISCARD shared_cairo_t | context () const |
Get the context for the Canvas. | |
void | copy (const shared_cairo_surface_t &surface) |
Create a copy of a surface. | |
void | copy (const shared_cairo_surface_t &surface, const RectF &rect) |
EGT_NODISCARD PixelFormat | format () const |
Get the format of the surface. | |
void | reallocate (const Size &size, PixelFormat format=PixelFormat::argb8888) |
Reallocate the canvas to a different size. | |
void | reallocate (const SizeF &size, PixelFormat format=PixelFormat::argb8888) |
Reallocate the canvas to a different size. | |
EGT_NODISCARD Size | size () const |
Get the size of the surface. | |
EGT_NODISCARD shared_cairo_surface_t | surface () const |
Get the surface for the Canvas. | |
void | zero () |
Fill the surface with zero (including for transparency channel if applicable). | |
Protected Attributes | |
shared_cairo_t | m_cr |
The context of the canvas. | |
shared_cairo_surface_t | m_surface |
The surface of the canvas. | |
Manages a unique drawing surface and context.
This can be created and directly drawn to with Painter.
This is useful, for example, if you need a temporary or intermediate buffer for drawing to.
Example
|
explicitnoexcept |
Construct a canvas with the specified format and size.
[in] | size | The size of the canvas. |
[in] | format | The pixel format for the canvas. |
|
explicitnoexcept |
Construct a canvas with the specified format and size.
[in] | size | The size of the canvas. |
[in] | format | The pixel format for the canvas. |
|
explicitnoexcept |
Construct a canvas with an already existing surface.
The canvas will create a copy of the supplied surface.
[in] | surface | The surface to copy from. A copy will be made. |
|
noexcept |
Construct a canvas with an already existing surface, and specify the format of the surface the canvas create a copy to.
The canvas will create a copy of the supplied surface.
[in] | surface | The surface to copy from. A copy will be made. |
[in] | format | The pixel format for the canvas. |
|
inline |
Get the context for the Canvas.
void copy | ( | const shared_cairo_surface_t & | surface | ) |
Create a copy of a surface.
void copy | ( | const shared_cairo_surface_t & | surface, |
const RectF & | rect | ||
) |
EGT_NODISCARD PixelFormat format | ( | ) | const |
Get the format of the surface.
void reallocate | ( | const Size & | size, |
PixelFormat | format = PixelFormat::argb8888 |
||
) |
Reallocate the canvas to a different size.
[in] | size | The size of the canvas. |
[in] | format | The pixel format for the canvas. |
void reallocate | ( | const SizeF & | size, |
PixelFormat | format = PixelFormat::argb8888 |
||
) |
Reallocate the canvas to a different size.
[in] | size | The size of the canvas. |
[in] | format | The pixel format for the canvas. |
EGT_NODISCARD Size size | ( | ) | const |
Get the size of the surface.
|
inline |
Get the surface for the Canvas.
void zero | ( | ) |
Fill the surface with zero (including for transparency channel if applicable).
|
protected |
The context of the canvas.
|
protected |
The surface of the canvas.