151 template<
typename Allocator>
200 void curve(
double x,
double y,
double c1x,
double c1y,
double c2x,
double c2y) {
curve({x, y}, {
c1x,
c1y}, {
c2x,
c2y}); }
724 static_assert(
I <= 3);
725 if constexpr(
I == 0) {
727 }
else if constexpr(
I == 1) {
728 return element.points[
I - 1];
734 static_assert(
I <= 3);
735 if constexpr(
I == 0) {
738 return element.points[
I - 1];
743template<
typename Alloc>
struct std::uses_allocator<
CeresEngine::BezierPath, Alloc> : std::true_type {};
745template<>
struct std::tuple_size<
CeresEngine::BezierPath::Element> : std::integral_constant<std::size_t, 4> {};
747template<std::
size_t N>
struct std::tuple_element<
N,
CeresEngine::BezierPath::Element> {
748 using type =
decltype(get<N>(std::declval<CeresEngine::BezierPath::Element>()));
751template<>
struct std::tuple_size<const
CeresEngine::BezierPath::Element> : std::integral_constant<std::size_t, 4> {};
753template<std::
size_t N>
struct std::tuple_element<
N, const
CeresEngine::BezierPath::Element> {
754 using type =
decltype(get<N>(std::declval<const CeresEngine::BezierPath::Element>()));
A path that consists of straight and curved line segments that you can render.
Definition BezierPath.hpp:46
static BezierPath roundedRect(const Rect2 &aRect, const double xRadius, const double yRadius)
Creates a rounded rectangular path.
Definition BezierPath.hpp:643
ElementReverseIterator rend() const
Returns an iterator that points to past-the-last path element in the reversed order.
Definition BezierPath.hpp:582
static BezierPath rect(AnyAllocatorReference allocator, const Rect2 &aRect)
\coypdoc rect(const Rect2&)
void relativeLine(const Point2 &aPoint)
Appends a straight line segment to the path starting at the current point and moving towards the spec...
void move(const Point2 &aPoint)
Moves the path's current point to the specified location.
bool isFlat() const
A Boolean value that indicates whether the path is flat.
ElementIterator cbegin() const
Returns an iterator that points to the first path element.
Definition BezierPath.hpp:559
static BezierPath oval(const Rect2 &aRect)
Creates an oval path, inscribing the oval in the specified rectangle.
Definition BezierPath.hpp:611
ElementReverseIterator rbegin() const
Returns an iterator that points to the first path element in the reversed order.
Definition BezierPath.hpp:575
BezierPath expandedStroke(const double width) const
Creates a new bezier path containing the expanded stroke.
Definition BezierPath.hpp:457
void append(const BezierPath &aPath)
Appends the contents of the specified path object to the path.
friend bool operator!=(const BezierPath &lhs, const BezierPath &rhs) noexcept
void line(double x, double y)
Appends a straight line to the path.
Definition BezierPath.hpp:187
void relativeMove(const Point2 &aPoint)
Moves the path's current point to a new point whose location is the specified distance from the curre...
BezierPath & operator=(const BezierPath &)=default
void appendRect(const Rect2 &aRect)
Appends a rectangular path to the path.
void relativeCurve(const Point2 &aPoint, const Point2 &controlPoint1, const Point2 &controlPoint2)
Adds a Bezier cubic curve to the path from the current point to a new location, which is specified as...
static BezierPath arc(const Point2 ¢er, const double radius, const Degree &startAngle, const Degree &endAngle, const bool clockwise=false)
Creates an arc of a circle.
Definition BezierPath.hpp:701
ElementReverseIterator crend() const
Returns an iterator that points to past-the-last path element in the reversed order.
Definition BezierPath.hpp:579
BezierPath flattened() const
Computes a flattened version of the path object.
BezierPath reversed() const
Computes a path containing the reversed contents of the current path object.
double getFlatness() const
The accuracy with which curves are rendered.
Definition BezierPath.hpp:595
double mFlatness
The accuracy with which curves are rendered.
Definition BezierPath.hpp:123
ElementType
Constants that specify basic path element commands.
Definition BezierPath.hpp:63
@ CurveTo
Creates a curved line segment from the current point to the specified endpoint using two control poin...
@ LineTo
Creates a straight line from the current drawing point to the specified point.
@ ClosePath
Marks the end of the current subpath at the specified point.
@ MoveTo
Moves the path object's current drawing point to the specified point.
BezierPath(std::allocator_arg_t, const Allocator &allocator, const BezierPath &other)
Definition BezierPath.hpp:152
static BezierPath roundedRect(AnyAllocatorReference allocator, const Rect2 &aRect, double xRadius, double yRadius)
Creates a rounded rectangular path.
BezierPath expandedStrokeAsFan(const double innerWidth, const double outerWidth) const
Creates a new bezier path containing the expanded stroke.
Definition BezierPath.hpp:446
bool operator&(const Point2 &aPoint) const
Returns a Boolean value that indicates whether the path contains the specified point.
Definition BezierPath.hpp:412
bool isOpen() const
A Boolean value that indicates whether the path is currently open.
BezierPath & operator+=(const BezierPath &aPath)
Appends the contents of the specified path object to the path.
Definition BezierPath.hpp:279
void move(double x, double y)
Moves the path's current point to the specified location.
Definition BezierPath.hpp:169
void setFlatness(double flatness)
The accuracy with which curves are rendered.
void appendOval(const Rect2 &aRect)
Appends an oval path to the path, inscribing the oval in the specified rectangle.
BezierPath(const BezierPath &, AnyAllocatorReference allocator)
AnyStdAllocator< BezierPath > allocator_type
Definition BezierPath.hpp:145
typename Deque< Element, AnyAllocator >::const_reverse_iterator ElementReverseIterator
An iterator type that allows iterating over the bezier path elements in reverse order.
Definition BezierPath.hpp:95
ElementIterator end() const
Returns an iterator that points to past-the-last path element.
Definition BezierPath.hpp:568
void setWindingRule(WindingRule windingRule)
The winding rule used to fill the path.
BezierPath()
Creates a new empty bezier path using a default allocator.
Rect2 getBounds() const
The bounding box of the path.
WindingRule
Constants that specify the winding rule a Bézier path uses.
Definition BezierPath.hpp:49
@ NonZero
Specifies the non-zero winding rule.
@ EvenOdd
Specifies the even-odd winding rule.
BezierPath(const BezierPath &)=default
void clear()
Removes all path elements from the path, effectively clearing the path.
Definition BezierPath.hpp:556
void close()
Closes the most recently added subpath.
Point2 getCurrentPoint() const
The current point (the trailing point or ending point in the most recently added segment).
WindingRule getWindingRule() const
The winding rule used to fill the path.
Definition BezierPath.hpp:589
typename Deque< Element, AnyAllocator >::const_iterator ElementIterator
An iterator type that allows iterating over the bezier path elements.
Definition BezierPath.hpp:91
BezierPath transformed(const AffineTransform &aTransform) const
Transforms all points in the path using the specified transform.
void flatten()
Computes a flattened version of the path object.
Rect2 getControlPointBounds() const
The bounding box of the path, including any control points.
bool contains(const Point2 &aPoint) const
Returns a Boolean value that indicates whether the path contains the specified point.
ElementType getElement(UInt32 index, Point2 &aPoint0, Point2 &aPoint1, Point2 &aPoint2) const
Gets the element type and the associated points for the path element at the specified index.
static BezierPath arc(const Point2 &fromPoint, const Point2 &toPoint, const double radius)
Creates an arc path.
Definition BezierPath.hpp:672
void removeAllPoints()
Removes all path elements from the path, effectively clearing the path.
Deque< Element, AnyAllocator > mElements
An array of BezierPath elements.
Definition BezierPath.hpp:126
bool isEmpty() const
A Boolean value that indicates whether the path is empty.
void appendArc(const Point2 ¢er, double radius, const Degree &startAngle, const Degree &endAngle, bool clockwise=false)
Appends an arc of a circle to the path.
static BezierPath oval(AnyAllocatorReference allocator, const Rect2 &aRect)
Creates an oval path, inscribing the oval in the specified rectangle.
BezierPath expandedStrokeAsStrip(const double width) const
Creates a new bezier path containing the expanded stroke.
Definition BezierPath.hpp:451
void transform(const AffineTransform &aTransform)
Transforms all points in the path using the specified transform.
ElementIterator cend() const
Returns an iterator that points to past-the-last path element.
Definition BezierPath.hpp:565
BezierPath expandedStrokeInternal(double innerWidth, double outerWidth, bool asTriangleFan) const
Creates a new bezier path containing the expanded stroke.
BezierPath expandedStroke(const double innerWidth, const double outerWidth) const
Creates a new bezier path containing the expanded stroke.
Definition BezierPath.hpp:454
static BezierPath rect(const Rect2 &aRect)
Creates a rectangular path.
Definition BezierPath.hpp:623
ElementReverseIterator crbegin() const
Returns an iterator that points to the first path element in the reversed order.
Definition BezierPath.hpp:572
Rect2 getBoundsAccurate() const
The bounding box of the path.
void appendRoundedRect(const Rect2 &aRect, double xRadius, double yRadius)
Appends a rounded rectangular path to the path.
UInt32 getElementCount() const
The total number of path elements in the path.
WindingRule mWindingRule
The winding rule used to fill the path.
Definition BezierPath.hpp:114
friend bool operator==(const BezierPath &lhs, const BezierPath &rhs) noexcept
static BezierPath arc(AnyAllocatorReference allocator, const Point2 ¢er, double radius, const Degree &startAngle, const Degree &endAngle, bool clockwise=false)
Creates an arc of a circle.
const Element & operator[](const UInt32 index) const
Definition BezierPath.hpp:549
static BezierPath arc(AnyAllocatorReference allocator, const Point2 &fromPoint, const Point2 &toPoint, double radius)
Creates an arc path.
ElementIterator begin() const
Returns an iterator that points to the first path element.
Definition BezierPath.hpp:562
BezierPath operator+(const BezierPath &aPath) const
Appends the contents of the specified path object to the path.
Definition BezierPath.hpp:285
AnyAllocatorReference getAllocator() const noexcept
Definition BezierPath.hpp:714
void curve(const Point2 &aPoint, const Point2 &controlPoint1, const Point2 &controlPoint2)
Adds a Bezier cubic curve to the path.
BezierPath(BezierPath &&) noexcept=default
void reverse()
Computes a path containing the reversed contents of the current path object.
void line(const Point2 &aPoint)
Appends a straight line to the path.
void appendArc(const Point2 &fromPoint, const Point2 &toPoint, double radius)
Appends an arc to the path.
Vector< SubPath > getSubPaths() const
Gets a vector that contains all sub-paths currently on the bezier path.
void curve(double x, double y, double c1x, double c1y, double c2x, double c2y)
Adds a Bezier cubic curve to the path.
Definition BezierPath.hpp:200
const Element & getElement(UInt32 index) const
Returns the type of path element at the specified index.
BezierPath(AnyAllocatorReference allocator)
Creates a new empty bezier path using a custom allocator.
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
foonathan::memory::any_allocator_reference AnyAllocatorReference
Definition Allocator.hpp:98
decltype(auto) get(BezierPath::Element &element) noexcept
Decomposes a bezier path element.
Definition BezierPath.hpp:723
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
foonathan::memory::any_std_allocator< T > AnyStdAllocator
Definition Allocator.hpp:228
std::uint8_t UInt8
Definition DataTypes.hpp:17
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 BezierPath element.
Definition BezierPath.hpp:81
Point2 points[3]
An array of points.
Definition BezierPath.hpp:87
ElementType type
The type of element represented by the struct.
Definition BezierPath.hpp:83
A structure that describes a BezierPath sub-path.
Definition BezierPath.hpp:101
UInt32 firstIndex
The index of the first element of the sub-path.
Definition BezierPath.hpp:106
UInt32 lastIndex
The index past the last element of the sub-path.
Definition BezierPath.hpp:109
bool closed
A boolean flag that determines if the sub-path is closed.
Definition BezierPath.hpp:103