1.10 |
Drawing interface for 2D graphics. More...
#include <painter.h>
Classes | |
struct | AutoGroup |
You are encouraged to use this instead of manually calling Painter::push_group() and Painter::pop_group(). More... | |
struct | AutoSaveRestore |
Scoped save() and restore() for a Painter. More... | |
Public Types | |
enum class | TextDrawFlag : uint32_t { shadow = detail::bit(0) } |
using | TextDrawFlags = Flags< TextDrawFlag > |
Public Member Functions | |
Painter ()=delete | |
Painter (shared_cairo_t cr) noexcept | |
Construct a Painter with an existing context. | |
Painter & | clip () |
Color | color_at (const Point &point) noexcept |
void | color_at (const Point &point, const Color &color) noexcept |
EGT_NODISCARD shared_cairo_t | context () const |
Get the current underlying context the painter is using. | |
template<class T > | |
Painter & | draw (const ArcType< T > &arc) |
Create an arc. | |
template<class T > | |
Painter & | draw (const CircleType< T > &arc) |
Create a circle. | |
Painter & | draw (const Image &image) |
Draw an image surface at the specified point. | |
template<class T > | |
Painter & | draw (const LineType< T > &line) |
Create a line. | |
template<class T > | |
Painter & | draw (const PointType< T, detail::Compatible::normal > &point) |
Move to a point. | |
Painter & | draw (const Rect &rect, const Image &image) |
template<class T > | |
Painter & | draw (const RectType< T > &rect) |
Create a rectangle. | |
Painter & | draw (const std::string &str, const TextDrawFlags &flags={}) |
Draw text inside the specified rectangle. | |
template<class T > | |
Painter & | draw (const T &start, const T &end) |
Create a line from the start point to the end point. | |
Painter & | fill () |
Painter & | flood (const Point &point, const Color &color) |
template<class T > | |
Painter & | line (const PointType< T, detail::Compatible::normal > &point) |
Painter & | line_width (float width) |
Set the current line width. | |
Painter & | mask (const Image &image, const Point &point={}) |
Draw an image as a mask. | |
Painter & | paint () |
Painter & | paint (float alpha) |
void | pop_group () |
Pop a group off the stack and automatically make it the source. | |
void | push_group () |
Push a group onto the stack. | |
void | restore () |
Restore the previous saved state of the current context. | |
Painter & | rotate (float angle) |
void | save () |
Save the state of the current context. | |
Painter & | set (const Font &font) |
Set the active font. | |
Painter & | set (const Pattern &pattern) |
Set the current color. | |
Painter & | stroke () |
Size | text_size (const std::string &text) |
Painter & | translate (const Point &point) |
Painter & | translate (const PointF &point) |
Static Public Member Functions | |
static Color | color_at (cairo_surface_t *image, const Point &point) noexcept |
static void | color_at (cairo_surface_t *image, const Point &point, const Color &color) noexcept |
static void | flood (cairo_surface_t *image, const Point &point, const Color &color) |
static Size | surface_to_size (cairo_surface_t *surface) |
Get a Size from a surface. | |
static Size | surface_to_size (const shared_cairo_surface_t &surface) |
Get a Size from a surface. | |
Protected Attributes | |
shared_cairo_t | m_cr |
Cairo context. | |
Drawing interface for 2D graphics.
This is the interface for 2D drawing primitives that makes working with and drawing EGT primitives easier.
using TextDrawFlags = Flags<TextDrawFlag> |
|
strong |
|
delete |
|
explicitnoexcept |
Construct a Painter with an existing context.
Painter & clip | ( | ) |
|
staticnoexcept |
|
inline |
Get the current underlying context the painter is using.
Create an arc.
[in] | arc | The arc. |
|
inline |
Create a circle.
[in] | arc | The circle. |
Create a line.
[in] | line | The line. |
|
inline |
Move to a point.
[in] | point | The point. |
[in] | rect | The source rect to copy. |
[in] | image | The image surface to draw. |
Create a rectangle.
[in] | rect | The rectangle. |
Painter & draw | ( | const std::string & | str, |
const TextDrawFlags & | flags = {} |
||
) |
Draw text inside the specified rectangle.
|
inline |
Create a line from the start point to the end point.
[in] | start | The point. |
[in] | end | The point. |
Painter & fill | ( | ) |
|
inline |
Painter & line_width | ( | float | width | ) |
Set the current line width.
[in] | width | Line width. |
Painter & paint | ( | ) |
Painter & paint | ( | float | alpha | ) |
void pop_group | ( | ) |
Pop a group off the stack and automatically make it the source.
void push_group | ( | ) |
Push a group onto the stack.
void restore | ( | ) |
Restore the previous saved state of the current context.
Painter & rotate | ( | float | angle | ) |
void save | ( | ) |
Save the state of the current context.
Painter & stroke | ( | ) |
|
inlinestatic |
Get a Size from a surface.
|
inlinestatic |
Get a Size from a surface.
Size text_size | ( | const std::string & | text | ) |
|
protected |
Cairo context.