15#include <egt/detail/meta.h>
18#include <egt/geometry.h>
19#include <egt/pattern.h>
142 m_painter.push_group();
152 m_painter.pop_group();
306 return move_to(point);
312 return line_to(point);
346 return rectangle(rect);
357 return this->arc(arc);
422 shadow = detail::bit(0),
488 EGT_NODISCARD
const detail::InternalContext&
context()
const {
return *m_cr; }
521 std::unique_ptr<detail::InternalContext>
m_cr;
An Arc consists of a radius and two angles.
Definition geometry.h:1136
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:41
Font extent.
Definition font.h:50
Text extent.
Definition font.h:62
Raster image resource used for drawing or displaying.
Definition image.h:38
A line, with a starting and ending point.
Definition geometry.h:1056
EGT_NODISCARD constexpr PointType< Dim > start() const noexcept
Get the start point of the line.
Definition geometry.h:1074
EGT_NODISCARD constexpr PointType< Dim > end() const noexcept
Get the end point of the line.
Definition geometry.h:1076
Drawing interface for 2D graphics.
Definition painter.h:54
Painter & draw(const Image &image)
Draw an image surface at the specified point.
Painter & paint(float alpha)
Painter & source(const Color &color)
Set the source pattern from a Color.
std::unique_ptr< detail::InternalContext > m_cr
Internal context.
Definition painter.h:521
void low_fidelity()
Configure low fidelity options.
Painter & flood(const Point &point, const Color &color)
Painter & antialias(Painter::AntiAlias value)
Set the type of anti-aliasing.
void push_group()
Push a group onto the stack.
Painter & draw(const Color &color, const RectF &rect={}, bool preserve=false)
EGT_NODISCARD Font::FontExtents extents() const
Get the font extents based on the current context, hence taking into account transformations such as ...
Painter & draw(const std::string &str, const TextDrawFlags &flags={})
Draw text inside the specified rectangle.
EGT_NODISCARD Surface & target()
Definition painter.h:495
Color color_at(const Point &point) noexcept
EGT_NODISCARD bool filter_subordinate(const Widget &subordinate) const
Apply the current subordinate filter.
Painter & set(const Pattern &pattern)
Set the current color.
Painter & fill_preserve()
AntiAlias
Supported types of anti-aliasing.
Definition painter.h:61
Painter & source(const Pattern &pattern)
Set the source pattern from a Pattern.
Painter & set(const Font &font)
Set the active font.
Painter & arc(const ArcF &arc)
Painter & draw(const ArcType< T > &arc)
Create an arc.
Definition painter.h:355
SubordinateFilter set_subordinate_filter(const SubordinateFilter &subordinate_filter)
Set the subordinate filter (nullptr to remove the current filter).
Painter & source(const Surface &surface, const PointF &point={})
Set the source pattern from a Surface.
Painter & show_text(const std::string &str)
Definition painter.h:462
LineCap
Supported line caps.
Definition painter.h:75
Painter & line_width(float width)
Set the current line width.
TextDrawFlag
Definition painter.h:421
EGT_NODISCARD Painter::AntiAlias antialias() const
Get the current type of anti-aliasing.
Painter & draw(const RectType< T > &rect)
Create a rectangle.
Definition painter.h:344
Painter & draw(const PointType< T, detail::Compatible::normal > &point)
Move to a point.
Definition painter.h:304
Painter & source(const Image &image, const PointF &point={})
Set the source pattern from an Image.
void sync_for_cpu(bool skip_source=false) const
Claim the painter for being used by the CPU.
EGT_NODISCARD bool alpha_blending() const
Get the alpha blending state, either enabled or disabled.
Painter & move_to(const PointF &point)
Painter(Surface &surface) noexcept
Painter & draw(const Image &image, const PointF &point, const RectF &rect={})
Painter & alpha_blending(bool enabled)
Set the alpha blending state either enabled or disabled.
Surface & m_surface
Definition painter.h:523
Painter & rectangle(const RectF &rect)
std::function< bool(const Widget &)> SubordinateFilter
Return true if the subordinate widget is filtered out, hence should not be drawn by the painter.
Definition painter.h:85
SubordinateFilter m_subordinate_filter
Internal state.
Definition painter.h:516
Painter & translate(const PointF &point)
void save()
Save the state of the current context.
EGT_NODISCARD const detail::InternalContext & context() const
Get the current underlying context the painter is using.
Definition painter.h:488
Painter & line_to(const PointF &point)
Painter & mask(const Surface &surface, const PointF &point={})
Draw an image as a mask.
Painter & draw(const Surface &surface, const PointF &point, const RectF &rect={})
Size text_size(const std::string &text)
Painter & line_cap(Painter::LineCap value)
Set the current line cap.
EGT_NODISCARD const Surface & target() const
Get the target surface the painter is using.
Definition painter.h:493
Painter & scale(float sx, float sy)
Painter & mask(const Image &image, const Point &point={})
Painter & translate(const Point &point)
void color_at(const Point &point, const Color &color) noexcept
EGT_NODISCARD Painter::LineCap line_cap() const
Get the current line cap.
Painter & draw(const Pattern &pattern, const RectF &rect={}, bool preserve=false)
EGT_NODISCARD Font::TextExtents extents(const std::string &text) const
Get the text extents based on the current context, hence taking into account transformations such as ...
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:322
Painter & line(const PointType< T, detail::Compatible::normal > &point)
Definition painter.h:310
Painter & set_dash(const double *dashes, size_t num_dashes, double offset)
Set the dash pattern to be used by stroke().
void high_fidelity()
Configure high fidelity options.
Painter & draw(const LineType< T > &line)
Create a line.
Definition painter.h:333
void restore_subordinate_filter(SubordinateFilter &&subordinate_filter)
Restore the subordinate filter from a previous value.
Painter & rotate(float angle)
Painter & show_text(const char *utf8)
void restore()
Restore the previous saved state of the current context.
A Pattern which can store one or more colors at different offsets (steps) which can be used to create...
Definition pattern.h:59
Simple x,y coordinate.
Definition geometry.h:63
A rectangle with a point and a size.
Definition geometry.h:595
EGT_API std::ostream & operator<<(std::ostream &os, const Color &color)
Overloaded std::ostream insertion operator.
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:138
Painter & m_painter
Definition painter.h:155
AutoGroup(Painter &painter)
Definition painter.h:139
AutoGroup & operator=(const AutoGroup &)=delete
AutoGroup & operator=(AutoGroup &&)=delete
AutoGroup(AutoGroup &&)=delete
AutoGroup(const AutoGroup &)=delete
~AutoGroup()
Definition painter.h:150
Scoped save() and restore() for a Painter.
Definition painter.h:104
AutoSaveRestore & operator=(const AutoSaveRestore &)=delete
Painter & m_painter
Definition painter.h:121
AutoSaveRestore(const AutoSaveRestore &)=delete
AutoSaveRestore & operator=(AutoSaveRestore &&)=delete
AutoSaveRestore(Painter &painter)
Definition painter.h:105
AutoSaveRestore(AutoSaveRestore &&)=delete
~AutoSaveRestore()
Definition painter.h:116