101 Paint(
const Color& startingColor,
const Color& endingColor,
const Point2& startingPosition = {0, 0},
const Point2& endingPosition = {1, 1})
102 :
mData(LinearGradient{startingColor, endingColor, startingPosition, endingPosition}) {}
110 Paint(
const Color& startingColor,
const Color& endingColor,
const Rect2&
box = {0, 0, 1, 1},
double radius = 0.0,
double feather = 1.0)
111 :
mData(BoxGradient{startingColor, endingColor,
box, radius, feather}) {}
119 Paint(
const Color& startingColor,
const Color& endingColor,
const Point2& center = {0, 0},
double innerRadius = 0.0,
double outerRadius = 1.0)
120 :
mData(RadialGradient{startingColor, endingColor, center, innerRadius, outerRadius}) {}
442 template<
typename Allocator>
explicit Shape(std::allocator_arg_t,
const Allocator& allocator) :
Shape(allocator.get_allocator()) {}
445 template<
typename Allocator>
446 explicit Shape(std::allocator_arg_t,
const Allocator& allocator,
const Shape& other) :
Shape(other, allocator.get_allocator()) {}
561 return std::move(*
this);
601 return std::move(*
this);
628 return std::move(*
this);
708template<
typename Alloc>
struct std::uses_allocator<
CeresEngine::Shape, Alloc> : std::true_type {};
#define CE_EXPLICIT(EXPR)
Definition Macros.hpp:413
A path that consists of straight and curved line segments that you can render.
Definition BezierPath.hpp:46
A class that encapsulates a 2D paint object.
Definition Shape.hpp:27
Paint & operator=(const Paint &)=default
Assigns the paint object by copying from another.
Paint()
Creates a new default color paint.
Definition Shape.hpp:91
const RadialGradient & asRadialGradient() const
Gets the paint radial gradient value.
Definition Shape.hpp:155
Paint(const Color &startingColor, const Color &endingColor, const Point2 ¢er={0, 0}, double innerRadius=0.0, double outerRadius=1.0)
Creates a new linear gradient paint.
Definition Shape.hpp:119
Paint transformed(const AffineTransform &aTransform) const
Transforms all coordinates in the paint object with the specified transform.
Definition Shape.hpp:166
Paint(const Paint &)=default
Creates a new paint by copying another.
Paint & tint(const Color &color, double factor=0.5)
Applies a tint color to the paint.
Variant mData
The storage for the concrete paint implementation structure.
Definition Shape.hpp:87
Paint(const Color &startingColor, const Color &endingColor, const Point2 &startingPosition={0, 0}, const Point2 &endingPosition={1, 1})
Creates a new linear gradient paint.
Definition Shape.hpp:101
bool isBoxGradient() const noexcept
Checks if the paint holds a box gradient.
Definition Shape.hpp:144
const LinearGradient & asLinearGradient() const
Gets the paint linear gradient value.
Definition Shape.hpp:141
const Color & asColor() const
Gets the paint solid color value.
Definition Shape.hpp:134
bool isColor() const noexcept
Checks if the paint holds a solid color.
Definition Shape.hpp:130
Paint & operator*=(const Color &color)
Applies a tint color to the paint.
Definition Shape.hpp:184
Paint tinted(const Color &color, const double factor=0.5) const
Applies a tint color to the paint.
Definition Shape.hpp:178
Variant< Color, LinearGradient, BoxGradient, RadialGradient > Variant
A variant used to store the concrete paint implementation structure.
Definition Shape.hpp:84
Paint operator*(const Color &color) const
Applies a tint color to the paint.
Definition Shape.hpp:187
void transform(const AffineTransform &aTransform)
Transforms all coordinates in the paint object with the specified transform.
bool isLinearGradient() const noexcept
Checks if the paint holds a linear gradient.
Definition Shape.hpp:137
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.
Definition Shape.hpp:110
const BoxGradient & asBoxGradient() const
Gets the paint box gradient value.
Definition Shape.hpp:148
bool isRadialGradient() const noexcept
Checks if the paint holds a radial gradient.
Definition Shape.hpp:151
A type that describes a conjunction of shapes that can be filled and stroked.
Definition Shape.hpp:198
Deque< BezierPath, AnyAllocator > mPaths
A vector that stores a unique copy of each path.
Definition Shape.hpp:416
Deque< Element, AnyAllocator > mElements
A vector of all elements in the shape.
Definition Shape.hpp:419
Shape & operator+=(const Shape &aShape)
Appends the contents of the specified shape object to the shape.
Definition Shape.hpp:520
ElementType
Definition Shape.hpp:358
Shape transformed(const AffineTransform &aTransform) const &
Transforms all points in the shape using the specified transform.
AnyAllocatorReference getAllocator() const noexcept
Definition Shape.hpp:703
void fill(const BezierPath &path, const Paint &paint, BlendMode blendMode=BlendMode::Normal)
Paints the region enclosed by the path.
Rect2 getBoundsAccurate() const
The bounding box of the shape.
BlendMode
Compositing operations for images.
Definition Shape.hpp:248
@ Exclusion
Produces an effect similar to that produced by difference, but with lower contrast.
@ Saturation
Uses the luminance and hue values of the background with the saturation of the source image.
@ Screen
Multiplies the inverse of the source image samples with the inverse of the background image samples,...
@ SourceOut
R = S*(1 - Da)
@ DestinationOut
R = D*(1 - Sa)
@ PlusLighter
R = MIN(1, S + D)
@ Luminosity
Uses the hue and saturation of the background with the luminance of the source image.
@ PlusDarker
R = MAX(0, 1 - ((1 - D) + (1 - S)))
@ DestinationOver
R = S*(1 - Da) + D.
@ SourceAtop
R = S*Da + D*(1 - Sa)
@ DestinationAtop
R = S*(1 - Da) + D*Sa.
@ Normal
Paints the source image samples over the background image samples.
@ ColorBurn
Darkens the background image samples to reflect the source image samples.
@ XorOp
R = S*(1 - Da) + D*(1 - Sa).
@ Color
Uses the luminance values of the background with the hue and saturation values of the source image.
@ Multiply
Multiplies the source image samples with the background image samples.
@ ColorDodge
Brightens the background image samples to reflect the source image samples.
@ Hue
Uses the luminance and saturation values of the background with the hue of the source image.
Shape(Shape &&other) noexcept
LineCapStyle
Constants that specify the shape of endpoints for an open path when it is stroked.
Definition Shape.hpp:202
@ Butt
Specifies a butt line cap style for endpoints for an open path when stroked.
@ Round
Specifies a round line cap style for endpoints for an open path when stroked.
@ Square
Specifies a square line cap style for endpoints for an open path when stroked.
typename Deque< Element >::const_iterator ElementIterator
An iterator type that allows iterating over the shape elements.
Definition Shape.hpp:412
Shape()
Creates a new empty shape using a default allocator.
Shape & operator+=(Shape &&aShape)
Appends the contents of the specified shape object to the shape.
Definition Shape.hpp:526
void append(const Shape &aShape)
Appends the contents of the specified shape object to the shape.
void reverse()
Computes a shape containing the reversed contents of the current shape path objects.
Shape(std::allocator_arg_t, const Allocator &allocator, const Shape &other)
Definition Shape.hpp:446
bool operator&(const Point2 &aPoint) const
Returns a Boolean value that indicates whether the shape contains the specified point.
Definition Shape.hpp:582
const Element & getElement(UInt32 index) const
Returns the type of shape element at the specified index.
ElementIterator cend() const
Returns an iterator that points to past-the-last path element.
Definition Shape.hpp:697
void append(Shape &&aShape)
Appends the contents of the specified shape object to the shape.
ElementIterator begin() const
Returns an iterator that points to the first path element.
Definition Shape.hpp:694
void stroke(const BezierPath &path, const Paint &paint, double lineWidth=1.0, BlendMode blendMode=BlendMode::Normal, LineCapStyle lineCapStyle=LineCapStyle::Butt, LineJoinStyle lineJoinStyle=LineJoinStyle::Miter, double miterLimit=10.0)
Draws a line along the path using the given stroke color and drawing attributes.
Shape(std::allocator_arg_t, const Allocator &allocator)
Creates a new empty shape using a custom allocator.
Definition Shape.hpp:442
Shape flattened() const &
Computes a flattened version of the shape object.
Element & appendElement(ElementType type, BezierPath &&path)
Appends a new element to the shape.
Shape(const Shape &other, AnyAllocatorReference allocator)
Shape && transformed(const AffineTransform &aTransform) &&
Transforms all points in the shape using the specified transform.
Definition Shape.hpp:559
void stroke(BezierPath &&path, const Paint &paint, double lineWidth=1.0, BlendMode blendMode=BlendMode::Normal, LineCapStyle lineCapStyle=LineCapStyle::Butt, LineJoinStyle lineJoinStyle=LineJoinStyle::Miter, double miterLimit=10.0)
Draws a line along the path using the given stroke color and drawing attributes.
ElementIterator cbegin() const
Returns an iterator that points to the first path element.
Definition Shape.hpp:691
bool isEmpty() const
A Boolean value that indicates whether the shape is empty.
void flatten()
Computes a flattened version of the shape object.
LineJoinStyle
Constants that specify the shape of the joins between connected segments of a stroked path.
Definition Shape.hpp:218
@ Bevel
Specifies a bevel line shape of the joints between connected segments of a stroked path.
@ Miter
Specifies a miter line shape of the joints between connected segments of a stroked path.
UInt32 getElementCount() const
The total number of shape elements in the shape.
const Element & operator[](const UInt32 index) const
Returns the type of shape element at the specified index.
Definition Shape.hpp:688
void fill(BezierPath &&path, const Paint &paint, BlendMode blendMode=BlendMode::Normal)
Paints the region enclosed by the path.
Shape operator+(Shape &&aShape) const
Appends the contents of the specified shape object to the shape.
Definition Shape.hpp:539
const BezierPath & appendPath(const BezierPath &path)
Appends a path to the internal list of paths.
Shape(AnyAllocatorReference allocator)
Creates a new empty shape using a custom allocator.
Shape & operator=(const Shape &other)
Shape reversed() const &
Computes a shape containing the reversed contents of the current shape path objects.
Rect2 getBounds() const
The bounding box of the shape.
Shape(const Shape &other)
Shape & operator=(Shape &&other) noexcept
AnyStdAllocator< Shape > allocator_type
Definition Shape.hpp:439
const BezierPath & appendPath(BezierPath &&path)
Appends a path to the internal list of paths.
ElementIterator end() const
Returns an iterator that points to past-the-last path element.
Definition Shape.hpp:700
void transform(const AffineTransform &aTransform)
Transforms all points in the shape using the specified transform.
Rect2 getControlPointBounds() const
The bounding box of the shape, including any control points.
Element & appendElement(ElementType type, const BezierPath &path)
Appends a new element to the shape.
Shape operator+(const Shape &aShape) const
Appends the contents of the specified shape object to the shape.
Definition Shape.hpp:532
bool contains(const Point2 &aPoint) const
Returns a Boolean value that indicates whether the shape contains the specified point.
constexpr T & as() &
Definition Variant.hpp:29
constexpr bool is() const noexcept
Definition Variant.hpp:27
Definition Application.hpp:19
std::deque< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Deque
Deque (double-ended queue) is an indexed sequence container that allows fast insertion and deletion a...
Definition Deque.hpp:20
Box box(T &value)
Creates a new Box object by wraping the value as a reference type.
Definition Box.hpp:672
foonathan::memory::any_allocator_reference AnyAllocatorReference
Definition Allocator.hpp:98
foonathan::memory::any_std_allocator< T > AnyStdAllocator
Definition Allocator.hpp:228
@ Color
Attachment is used for color output.
DefaultAllocator & gDefaultAllocator()
std::uint32_t UInt32
Definition DataTypes.hpp:23
void copy(const A &a, B &b, T &&t=T())
Copies values from one container to another.
Definition Iterator.hpp:564
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
A structure that describes a box gradient.
Definition Shape.hpp:47
double feather
Feather defines how blurry the border of the rectangle is.
Definition Shape.hpp:61
Color startingColor
The gradient starting color.
Definition Shape.hpp:49
double radius
Defines the corner radius.
Definition Shape.hpp:58
Rect2 box
Defines the box in which the gradient should be drawn.
Definition Shape.hpp:55
Color endingColor
The gradient ending color.
Definition Shape.hpp:52
A structure that describes a linear gradient.
Definition Shape.hpp:30
Point2 startingPosition
The gradient starting position.
Definition Shape.hpp:38
Color startingColor
The gradient starting color at startingPosition.
Definition Shape.hpp:32
Point2 endingPosition
The gradient ending position.
Definition Shape.hpp:41
Color endingColor
The gradient ending color at endingPosition.
Definition Shape.hpp:35
A structure that describes a radial gradient.
Definition Shape.hpp:65
Color startingColor
The gradient starting color at `center“.
Definition Shape.hpp:67
Point2 center
The center of the radial gradient.
Definition Shape.hpp:73
Color endingColor
The gradient ending color at center + outerRadius.
Definition Shape.hpp:70
double outerRadius
The gradient outer radius.
Definition Shape.hpp:79
double innerRadius
The gradient inner radius.
Definition Shape.hpp:76
An element is composed of a path and one or more commands to be done on that path.
Definition Shape.hpp:366
LineJoinStyle lineJoinStyle
The line join style for the path.
Definition Shape.hpp:383
LineCapStyle lineCapStyle
The line cap style for the path.
Definition Shape.hpp:380
double miterLimit
The limit at which miter joins are converted to bevel joins.
Definition Shape.hpp:403
Element(const ElementType type, const BezierPath &path)
Creates a new element instance.
Definition Shape.hpp:408
double lineWidth
The width of stroked path lines.
Definition Shape.hpp:395
BlendMode blendMode
A constant that describes the blending mode for the operation.
Definition Shape.hpp:377
Paint paint
The paint to be used to fill or stroke the path.
Definition Shape.hpp:374
const ElementType type
A constant that describes the type of the element.
Definition Shape.hpp:368
const BezierPath & path
A reference to an internally cached bezier path object.
Definition Shape.hpp:371