CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::Paint Class Reference

A class that encapsulates a 2D paint object. More...

#include <CeresEngine/Graphics/Shape.hpp>

Classes

struct  BoxGradient
 A structure that describes a box gradient. More...
 
struct  LinearGradient
 A structure that describes a linear gradient. More...
 
struct  RadialGradient
 A structure that describes a radial gradient. More...
 

Public Member Functions

 Paint ()
 Creates a new default color paint.
 
 Paint (const Color &solidColor)
 Create a new solid color paint.
 
 Paint (const Color &startingColor, const Color &endingColor, const Point2 &startingPosition={0, 0}, const Point2 &endingPosition={1, 1})
 Creates a new linear gradient paint.
 
 Paint (const Color &startingColor, const Color &endingColor, const Rect2 &box={0, 0, 1, 1}, double radius=0.0, double feather=1.0)
 Creates a new linear gradient paint.
 
 Paint (const Color &startingColor, const Color &endingColor, const Point2 &center={0, 0}, double innerRadius=0.0, double outerRadius=1.0)
 Creates a new linear gradient paint.
 
 Paint (const Paint &)=default
 Creates a new paint by copying another.
 
Paintoperator= (const Paint &)=default
 Assigns the paint object by copying from another.
 
bool isColor () const noexcept
 Checks if the paint holds a solid color.
 
const ColorasColor () const
 Gets the paint solid color value.
 
bool isLinearGradient () const noexcept
 Checks if the paint holds a linear gradient.
 
const LinearGradientasLinearGradient () const
 Gets the paint linear gradient value.
 
bool isBoxGradient () const noexcept
 Checks if the paint holds a box gradient.
 
const BoxGradientasBoxGradient () const
 Gets the paint box gradient value.
 
bool isRadialGradient () const noexcept
 Checks if the paint holds a radial gradient.
 
const RadialGradientasRadialGradient () const
 Gets the paint radial gradient value.
 
void transform (const AffineTransform &aTransform)
 Transforms all coordinates in the paint object with the specified transform.
 
Paint transformed (const AffineTransform &aTransform) const
 Transforms all coordinates in the paint object with the specified transform.
 
Painttint (const Color &color, double factor=0.5)
 Applies a tint color to the paint.
 
Paint tinted (const Color &color, const double factor=0.5) const
 Applies a tint color to the paint.
 
Paintoperator*= (const Color &color)
 Applies a tint color to the paint.
 
Paint operator* (const Color &color) const
 Applies a tint color to the paint.
 

Private Types

using Variant = Variant< Color, LinearGradient, BoxGradient, RadialGradient >
 A variant used to store the concrete paint implementation structure.
 

Private Attributes

Variant mData
 The storage for the concrete paint implementation structure.
 

Detailed Description

A class that encapsulates a 2D paint object.

Member Typedef Documentation

◆ Variant

A variant used to store the concrete paint implementation structure.

Constructor & Destructor Documentation

◆ Paint() [1/6]

CeresEngine::Paint::Paint ( )
inline

Creates a new default color paint.

◆ Paint() [2/6]

CeresEngine::Paint::Paint ( const Color solidColor)
inline

Create a new solid color paint.

◆ Paint() [3/6]

CeresEngine::Paint::Paint ( const Color startingColor,
const Color endingColor,
const Point2 &  startingPosition = {0, 0},
const Point2 &  endingPosition = {1, 1} 
)
inline

Creates a new linear gradient paint.

Parameters
startingColorThe gradient starting color at startingPosition.
endingColorThe gradient ending color at endingPosition.
startingPositionThe gradient starting position. By default, {0, 0}.
endingPositionThe gradient ending position. By default, {1, 1}.

◆ Paint() [4/6]

CeresEngine::Paint::Paint ( const Color startingColor,
const Color endingColor,
const Rect2 &  box = {0, 0, 1, 1},
double  radius = 0.0,
double  feather = 1.0 
)
inline

Creates a new linear gradient paint.

Parameters
startingColorThe gradient starting color at startingPosition.
endingColorThe gradient ending color at endingPosition.
boxDefines the box in which the gradient should be drawn.
radiusDefines the corner radius.
featherDefines how blurry the border of the rectangle is.

◆ Paint() [5/6]

CeresEngine::Paint::Paint ( const Color startingColor,
const Color endingColor,
const Point2 &  center = {0, 0},
double  innerRadius = 0.0,
double  outerRadius = 1.0 
)
inline

Creates a new linear gradient paint.

Parameters
startingColorThe gradient starting color at startingPosition.
endingColorThe gradient ending color at endingPosition.
centerThe center of the radial gradient.
innerRadiusThe gradient inner radius.
outerRadiusThe gradient outer radius.

◆ Paint() [6/6]

CeresEngine::Paint::Paint ( const Paint )
default

Creates a new paint by copying another.

Member Function Documentation

◆ asBoxGradient()

const BoxGradient & CeresEngine::Paint::asBoxGradient ( ) const
inline

Gets the paint box gradient value.

If this paint does not hold a box gradient value, an exception is thrown.

◆ asColor()

const Color & CeresEngine::Paint::asColor ( ) const
inline

Gets the paint solid color value.

If this paint does not hold a solid color value, an exception is thrown.

◆ asLinearGradient()

const LinearGradient & CeresEngine::Paint::asLinearGradient ( ) const
inline

Gets the paint linear gradient value.

If this paint does not hold a linear gradient value, an exception is thrown.

◆ asRadialGradient()

const RadialGradient & CeresEngine::Paint::asRadialGradient ( ) const
inline

Gets the paint radial gradient value.

If this paint does not hold a radial gradient value, an exception is thrown.

◆ isBoxGradient()

bool CeresEngine::Paint::isBoxGradient ( ) const
inlinenoexcept

Checks if the paint holds a box gradient.

◆ isColor()

bool CeresEngine::Paint::isColor ( ) const
inlinenoexcept

Checks if the paint holds a solid color.

◆ isLinearGradient()

bool CeresEngine::Paint::isLinearGradient ( ) const
inlinenoexcept

Checks if the paint holds a linear gradient.

◆ isRadialGradient()

bool CeresEngine::Paint::isRadialGradient ( ) const
inlinenoexcept

Checks if the paint holds a radial gradient.

◆ operator*()

Paint CeresEngine::Paint::operator* ( const Color color) const
inline

Applies a tint color to the paint.

The tint color is applied with a mixing factor of factor.

◆ operator*=()

Paint & CeresEngine::Paint::operator*= ( const Color color)
inline

Applies a tint color to the paint.

The tint color is applied with a mixing factor of factor.

◆ operator=()

Paint & CeresEngine::Paint::operator= ( const Paint )
default

Assigns the paint object by copying from another.

◆ tint()

Paint & CeresEngine::Paint::tint ( const Color color,
double  factor = 0.5 
)

Applies a tint color to the paint.

The tint color is applied with a mixing factor of factor.

◆ tinted()

Paint CeresEngine::Paint::tinted ( const Color color,
const double  factor = 0.5 
) const
inline

Applies a tint color to the paint.

The tint color is applied with a mixing factor of factor.

◆ transform()

void CeresEngine::Paint::transform ( const AffineTransform &  aTransform)

Transforms all coordinates in the paint object with the specified transform.

This method returns the transformed paint object.

Parameters
aTransformThe transform to apply to the paint.

◆ transformed()

Paint CeresEngine::Paint::transformed ( const AffineTransform &  aTransform) const
inline

Transforms all coordinates in the paint object with the specified transform.

This method returns the transformed paint object.

Parameters
aTransformThe transform to apply to the paint.

Member Data Documentation

◆ mData

Variant CeresEngine::Paint::mData
private

The storage for the concrete paint implementation structure.


The documentation for this class was generated from the following file: