16#include <egt/detail/meta.h>
17#include <egt/geometry.h>
43# define EGT_PATTERN_CONSTEXPR constexpr
44#elif defined(__GNUC__)
45# if (__GNUC__ < 7 || (__GNUC__ == 7 && __GNUC_MINOR__ < 2))
46# define EGT_PATTERN_CONSTEXPR
48# define EGT_PATTERN_CONSTEXPR constexpr
51# define EGT_PATTERN_CONSTEXPR constexpr
75 using StepArray = std::vector<std::pair<float, Color>>;
140 EGT_PATTERN_CONSTEXPR
operator Color()
const
152 if (m_type != Type::solid)
153 throw std::runtime_error(
"requested solid color in pattern that is not a solid color");
190 const Point& end,
float end_radius);
205 EGT_NODISCARD
const detail::InternalPattern&
pattern()
const
209 assert(m_pattern.get());
216 void create_pattern()
const;
219 static bool sort_by_first(
const std::pair<float, Color>& a,
220 const std::pair<float, Color>& b)
222 return (a.first < b.first);
233 PatternImpl* m_impl{
nullptr};
236 mutable std::shared_ptr<detail::InternalPattern>
m_pattern;
239static_assert(detail::rule_of_5<Pattern>(),
"must fulfill rule of 5");
32 bit RGBA color.
Definition color.h:41
A Pattern which can store one or more colors at different offsets (steps) which can be used to create...
Definition pattern.h:59
EGT_NODISCARD Color first() const
Get the first color of the pattern.
float StepScaler
Scalar type for pattern steps.
Definition pattern.h:72
Type
Type of pattern.
Definition pattern.h:64
EGT_NODISCARD const detail::InternalPattern & pattern() const
Get internal pattern representation.
Definition pattern.h:205
Pattern() noexcept=default
void radial(const Point &start, float start_radius, const Point &end, float end_radius)
Create a radial gradient from start to end.
std::vector< std::pair< float, Color > > StepArray
Step array type.
Definition pattern.h:75
std::shared_ptr< detail::InternalPattern > m_pattern
Internal pattern representation.
Definition pattern.h:236
void linear(const Point &start, const Point &end)
Create a linear gradient from start to end.
bool operator!=(const Pattern &rhs) const
Definition pattern.h:131
Pattern(const StepArray &steps, const Point &start, const Point &end)
Construct a linear pattern with the specified steps.
Color m_color
Solid color of the pattern.
Definition pattern.h:229
Pattern(Type type, const StepArray &steps={})
Construct a pattern with the specified type and steps.
EGT_DEPRECATED EGT_NODISCARD Color color() const
Get the first color of the pattern.
Definition pattern.h:161
EGT_NODISCARD Point ending() const
Get the ending point of the pattern.
EGT_PATTERN_CONSTEXPR Color solid() const
Get the solid color.
Definition pattern.h:150
Pattern & step(StepScaler offset, const Color &color)
Add a step to the gradient.
EGT_NODISCARD const StepArray & steps() const
Get all of the steps of the pattern.
EGT_NODISCARD Type type() const
Get the type of pattern.
Definition pattern.h:179
EGT_NODISCARD float ending_radius() const
Get the ending radius of the pattern.
bool operator==(const Pattern &rhs) const
Compare two patterns.
Pattern(const StepArray &steps, const Point &start, float start_radius, const Point &end, float end_radius)
Construct a radial pattern with the specified steps.
EGT_NODISCARD Point starting() const
Get the starting point of the pattern.
EGT_NODISCARD float starting_radius() const
Get the starting radius of the pattern.
constexpr bool operator==(const Color &lhs, const Color &rhs)
Color operator.
Definition color.h:500
EGT framework namespace.
Definition animation.h:24