16#include <egt/detail/meta.h>
19#include <egt/geometry.h>
20#include <egt/pattern.h>
103 m_painter.push_group();
113 m_painter.pop_group();
184 cairo_move_to(m_cr.get(), point.
x(), point.
y());
192 cairo_line_to(m_cr.get(), point.
x(), point.
y());
206 cairo_move_to(m_cr.get(),
start.x(),
start.y());
207 cairo_line_to(m_cr.get(), end.x(), end.y());
220 cairo_move_to(m_cr.get(), line.
start().x(), line.
start().y());
221 cairo_line_to(m_cr.get(), line.
end().x(), line.
end().y());
237 cairo_rectangle(m_cr.get(),
257 cairo_arc(m_cr.get(), arc.
center().x(), arc.
center().y(),
274 cairo_arc(m_cr.get(), arc.
center().x(), arc.
center().y(),
299 shadow = detail::bit(0),
334 static void flood(cairo_surface_t* image,
350 return {cairo_image_surface_get_width(surface.get()),
351 cairo_image_surface_get_height(surface.get())};
359 return {cairo_image_surface_get_width(surface),
360 cairo_image_surface_get_height(surface)};
An Arc consists of a radius and two angles.
Definition geometry.h:1123
constexpr void radius(Dim radius) noexcept
Set the radius.
Definition geometry.h:1154
constexpr void angle1(float angle) noexcept
Set the angle1.
Definition geometry.h:1156
EGT_NODISCARD EGT_API bool empty() const noexcept
Returns true if the arc has no radius.
constexpr void center(const PointType< Dim > ¢er) noexcept
Set the center point.
Definition geometry.h:1160
constexpr void angle2(float angle) noexcept
Set the angle2.
Definition geometry.h:1158
A basic circle with a center point and radius.
Definition geometry.h:1204
32 bit RGBA color.
Definition color.h:41
Utility class for managing a set of flags with the ability to observe changes to the flags.
Definition flags.h:40
Manages a font and properties of a font.
Definition font.h:35
Raster image resource used for drawing or displaying.
Definition image.h:39
A line, with a starting and ending point.
Definition geometry.h:1043
EGT_NODISCARD constexpr PointType< Dim > start() const noexcept
Get the start point of the line.
Definition geometry.h:1061
EGT_NODISCARD constexpr PointType< Dim > end() const noexcept
Get the end point of the line.
Definition geometry.h:1063
Drawing interface for 2D graphics.
Definition painter.h:45
Painter & draw(const Image &image)
Draw an image surface at the specified point.
Painter & paint(float alpha)
Painter & draw(const Rect &rect, const Image &image)
Painter & flood(const Point &point, const Color &color)
void push_group()
Push a group onto the stack.
Painter & draw(const std::string &str, const TextDrawFlags &flags={})
Draw text inside the specified rectangle.
Color color_at(const Point &point) noexcept
Painter & draw(const CircleType< T > &arc)
Create a circle.
Definition painter.h:269
Painter & set(const Pattern &pattern)
Set the current color.
static Color color_at(cairo_surface_t *image, const Point &point) noexcept
Painter & set(const Font &font)
Set the active font.
Painter(shared_cairo_t cr) noexcept
Construct a Painter with an existing context.
Painter & draw(const ArcType< T > &arc)
Create an arc.
Definition painter.h:252
static void color_at(cairo_surface_t *image, const Point &point, const Color &color) noexcept
Painter & line_width(float width)
Set the current line width.
TextDrawFlag
Definition painter.h:298
shared_cairo_t m_cr
Cairo context.
Definition painter.h:368
Painter & draw(const RectType< T > &rect)
Create a rectangle.
Definition painter.h:232
Painter & draw(const PointType< T, detail::Compatible::normal > &point)
Move to a point.
Definition painter.h:182
Painter & translate(const PointF &point)
void save()
Save the state of the current context.
Size text_size(const std::string &text)
static Size surface_to_size(cairo_surface_t *surface)
Get a Size from a surface.
Definition painter.h:357
Painter & mask(const Image &image, const Point &point={})
Draw an image as a mask.
Painter & translate(const Point &point)
void color_at(const Point &point, const Color &color) noexcept
void pop_group()
Pop a group off the stack and automatically make it the source.
Painter & draw(const T &start, const T &end)
Create a line from the start point to the end point.
Definition painter.h:204
Painter & line(const PointType< T, detail::Compatible::normal > &point)
Definition painter.h:190
EGT_NODISCARD shared_cairo_t context() const
Get the current underlying context the painter is using.
Definition painter.h:340
Painter & draw(const LineType< T > &line)
Create a line.
Definition painter.h:218
Painter & rotate(float angle)
static void flood(cairo_surface_t *image, const Point &point, const Color &color)
void restore()
Restore the previous saved state of the current context.
static Size surface_to_size(const shared_cairo_surface_t &surface)
Get a Size from a surface.
Definition painter.h:348
A Pattern which can store one or more colors at different offsets (steps) which can be used to create...
Definition pattern.h:55
Simple x,y coordinate.
Definition geometry.h:63
EGT_NODISCARD constexpr Dim x() const noexcept
Get the x value.
Definition geometry.h:192
EGT_NODISCARD constexpr Dim y() const noexcept
Get the y value.
Definition geometry.h:194
A rectangle with a point and a size.
Definition geometry.h:595
EGT_NODISCARD constexpr Dim width() const noexcept
Get the width value.
Definition geometry.h:913
EGT_NODISCARD constexpr Dim x() const noexcept
Get the x value.
Definition geometry.h:903
EGT_NODISCARD constexpr bool empty() const noexcept
Returns true if the rectangle has no width or height.
Definition geometry.h:829
EGT_NODISCARD constexpr Dim height() const noexcept
Get the height value.
Definition geometry.h:915
EGT_NODISCARD constexpr Dim y() const noexcept
Get the y value.
Definition geometry.h:905
std::shared_ptr< cairo_surface_t > shared_cairo_surface_t
Shared pointer for a cairo surface.
Definition types.h:29
std::shared_ptr< cairo_t > shared_cairo_t
Shared pointer for a cairo context.
Definition types.h:35
EGT framework namespace.
Definition animation.h:24
You are encouraged to use this instead of manually calling Painter::push_group() and Painter::pop_gro...
Definition painter.h:99
Painter & m_painter
Definition painter.h:116
AutoGroup(Painter &painter)
Definition painter.h:100
AutoGroup & operator=(const AutoGroup &)=delete
AutoGroup & operator=(AutoGroup &&)=delete
AutoGroup(AutoGroup &&)=delete
AutoGroup(const AutoGroup &)=delete
~AutoGroup()
Definition painter.h:111
Scoped save() and restore() for a Painter.
Definition painter.h:65
AutoSaveRestore & operator=(const AutoSaveRestore &)=delete
Painter & m_painter
Definition painter.h:82
AutoSaveRestore(const AutoSaveRestore &)=delete
AutoSaveRestore & operator=(AutoSaveRestore &&)=delete
AutoSaveRestore(Painter &painter)
Definition painter.h:66
AutoSaveRestore(AutoSaveRestore &&)=delete
~AutoSaveRestore()
Definition painter.h:77