1.8
Public Types | Public Member Functions | Protected Attributes | List of all members
Pattern Class Reference

A Pattern which can store one or more colors at different offsets (steps) which can be used to create complex gradients. More...

Public Types

using StepArray = std::vector< std::pair< float, Color > >
 Step array type. More...
 
using StepScaler = float
 Scalar type for pattern steps. More...
 
enum class  Type { solid , linear , linear_vertical , radial }
 Type of pattern. More...
 

Public Member Functions

 Pattern () noexcept=default
 
constexpr Pattern (const Color &color) noexcept
 
 Pattern (const Pattern &rhs)
 
 Pattern (const StepArray &steps, const Point &start, const Point &end)
 Construct a linear pattern with the specified steps. More...
 
 Pattern (const StepArray &steps, const Point &start, float start_radius, const Point &end, float end_radius)
 Construct a radial pattern with the specified steps. More...
 
 Pattern (Pattern &&rhs) noexcept
 
 Pattern (Type type, const StepArray &steps={})
 Construct a pattern with the specified type and steps. More...
 
 ~Pattern () noexcept
 
EGT_DEPRECATED EGT_NODISCARD Color color () const
 Get the first color of the pattern. More...
 
EGT_NODISCARD Point ending () const
 Get the ending point of the pattern. More...
 
EGT_NODISCARD float ending_radius () const
 Get the ending radius of the pattern. More...
 
EGT_NODISCARD Color first () const
 Get the first color of the pattern. More...
 
void linear (const Point &start, const Point &end)
 Create a linear gradient from start to end. More...
 
EGT_PATTERN_CONSTEXPR operator Color () const
 Get the first color of the pattern. More...
 
bool operator!= (const Pattern &rhs) const
 
Patternoperator= (const Pattern &rhs)
 
Patternoperator= (Pattern &&rhs) noexcept
 
bool operator== (const Pattern &rhs) const
 Compare two patterns. More...
 
EGT_NODISCARD cairo_pattern_t * pattern () const
 Get internal pattern representation. More...
 
void radial (const Point &start, float start_radius, const Point &end, float end_radius)
 Create a radial gradient from start to end. More...
 
EGT_PATTERN_CONSTEXPR Color solid () const
 Get the solid color. More...
 
EGT_NODISCARD Point starting () const
 Get the starting point of the pattern. More...
 
EGT_NODISCARD float starting_radius () const
 Get the starting radius of the pattern. More...
 
Patternstep (StepScaler offset, const Color &color)
 Add a step to the gradient. More...
 
EGT_NODISCARD const StepArraysteps () const
 Get all of the steps of the pattern. More...
 
EGT_NODISCARD Type type () const
 Get the type of pattern. More...
 

Protected Attributes

Color m_color
 Solid color of the pattern. More...
 
PatternImpl * m_impl {nullptr}
 Implementation details for non-solid color patterns. More...
 
shared_cairo_pattern_t m_pattern
 Internal pattern representation. More...
 
Type m_type {Type::solid}
 Type of the pattern. More...
 

Detailed Description

A Pattern which can store one or more colors at different offsets (steps) which can be used to create complex gradients.

Member Typedef Documentation

◆ StepArray

using StepArray = std::vector<std::pair<float, Color> >

Step array type.

◆ StepScaler

using StepScaler = float

Scalar type for pattern steps.

Member Enumeration Documentation

◆ Type

enum Type
strong

Type of pattern.

Enumerator
solid 
linear 
linear_vertical 
radial 

Constructor & Destructor Documentation

◆ Pattern() [1/7]

Pattern ( )
defaultnoexcept

◆ Pattern() [2/7]

Pattern ( const Pattern rhs)

◆ Pattern() [3/7]

Pattern ( Pattern &&  rhs)
noexcept

◆ ~Pattern()

~Pattern ( )
noexcept

◆ Pattern() [4/7]

constexpr Pattern ( const Color color)
inlineconstexprnoexcept

◆ Pattern() [5/7]

Pattern ( Type  type,
const StepArray steps = {} 
)
explicit

Construct a pattern with the specified type and steps.

◆ Pattern() [6/7]

Pattern ( const StepArray steps,
const Point start,
const Point end 
)

Construct a linear pattern with the specified steps.

A linear pattern is made between a starting point and an ending point.

Parameters
stepsThe steps of the gradient.
startThe starting point of the pattern.
endThe ending point of the pattern.

◆ Pattern() [7/7]

Pattern ( const StepArray steps,
const Point start,
float  start_radius,
const Point end,
float  end_radius 
)

Construct a radial pattern with the specified steps.

A radial pattern is made between a starting circle and an ending circle.

Parameters
stepsThe steps of the gradient.
startThe center of the starting circle.
start_radiusThe starting radius of the pattern.
endThe center of the ending circle.
end_radiusThe ending radius of the pattern.

Member Function Documentation

◆ color()

EGT_DEPRECATED EGT_NODISCARD Color color ( ) const
inline

Get the first color of the pattern.

Deprecated:

◆ ending()

EGT_NODISCARD Point ending ( ) const

Get the ending point of the pattern.

◆ ending_radius()

EGT_NODISCARD float ending_radius ( ) const

Get the ending radius of the pattern.

◆ first()

EGT_NODISCARD Color first ( ) const

Get the first color of the pattern.

◆ linear()

void linear ( const Point start,
const Point end 
)

Create a linear gradient from start to end.

◆ operator Color()

EGT_PATTERN_CONSTEXPR operator Color ( ) const
inline

Get the first color of the pattern.

◆ operator!=()

bool operator!= ( const Pattern rhs) const
inline

◆ operator=() [1/2]

Pattern& operator= ( const Pattern rhs)

◆ operator=() [2/2]

Pattern& operator= ( Pattern &&  rhs)
noexcept

◆ operator==()

bool operator== ( const Pattern rhs) const

Compare two patterns.

◆ pattern()

EGT_NODISCARD cairo_pattern_t* pattern ( ) const
inline

Get internal pattern representation.

◆ radial()

void radial ( const Point start,
float  start_radius,
const Point end,
float  end_radius 
)

Create a radial gradient from start to end.

◆ solid()

EGT_PATTERN_CONSTEXPR Color solid ( ) const
inline

Get the solid color.

Calling this when type() != Type::Solid will throw.

◆ starting()

EGT_NODISCARD Point starting ( ) const

Get the starting point of the pattern.

◆ starting_radius()

EGT_NODISCARD float starting_radius ( ) const

Get the starting radius of the pattern.

◆ step()

Pattern& step ( StepScaler  offset,
const Color color 
)

Add a step to the gradient.

◆ steps()

EGT_NODISCARD const StepArray& steps ( ) const

Get all of the steps of the pattern.

◆ type()

EGT_NODISCARD Type type ( ) const
inline

Get the type of pattern.

Member Data Documentation

◆ m_color

Color m_color
protected

Solid color of the pattern.

◆ m_impl

PatternImpl* m_impl {nullptr}
protected

Implementation details for non-solid color patterns.

◆ m_pattern

shared_cairo_pattern_t m_pattern
mutableprotected

Internal pattern representation.

◆ m_type

Type m_type {Type::solid}
protected

Type of the pattern.