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

A path that consists of straight and curved line segments that you can render. More...

#include <CeresEngine/Graphics/BezierPath.hpp>

Classes

struct  Element
 A structure that describes a BezierPath element. More...
 
struct  SubPath
 A structure that describes a BezierPath sub-path. More...
 

Public Types

enum class  WindingRule : UInt8 { NonZero , EvenOdd }
 Constants that specify the winding rule a Bézier path uses. More...
 
enum class  ElementType : UInt8 { MoveTo , LineTo , CurveTo , ClosePath }
 Constants that specify basic path element commands. More...
 
using ElementIterator = typename Deque< Element, AnyAllocator >::const_iterator
 An iterator type that allows iterating over the bezier path elements.
 
using ElementReverseIterator = typename Deque< Element, AnyAllocator >::const_reverse_iterator
 An iterator type that allows iterating over the bezier path elements in reverse order.
 
using allocator_type = AnyStdAllocator< BezierPath >
 

Public Member Functions

 BezierPath ()
 Creates a new empty bezier path using a default allocator.
 
 BezierPath (AnyAllocatorReference allocator)
 Creates a new empty bezier path using a custom allocator.
 
 BezierPath (const BezierPath &)=default
 
BezierPathoperator= (const BezierPath &)=default
 
 BezierPath (const BezierPath &, AnyAllocatorReference allocator)
 
 BezierPath (BezierPath &&) noexcept=default
 
BezierPathoperator= (BezierPath &&) noexcept=default
 
 ~BezierPath ()=default
 
template<typename Allocator >
 BezierPath (std::allocator_arg_t, const Allocator &allocator)
 Creates a new empty bezier path using a custom allocator.
 
template<typename Allocator >
 BezierPath (std::allocator_arg_t, const Allocator &allocator, const BezierPath &other)
 
void move (const Point2 &aPoint)
 Moves the path's current point to the specified location.
 
void move (double x, double y)
 Moves the path's current point to the specified location.
 
void line (const Point2 &aPoint)
 Appends a straight line to the path.
 
void line (double x, double y)
 Appends a straight line to the path.
 
void curve (const Point2 &aPoint, const Point2 &controlPoint1, const Point2 &controlPoint2)
 Adds a Bezier cubic curve to the path.
 
void curve (double x, double y, double c1x, double c1y, double c2x, double c2y)
 Adds a Bezier cubic curve to the path.
 
void close ()
 Closes the most recently added subpath.
 
void relativeMove (const Point2 &aPoint)
 Moves the path's current point to a new point whose location is the specified distance from the current point.
 
void relativeLine (const Point2 &aPoint)
 Appends a straight line segment to the path starting at the current point and moving towards the specified point, relative to the current location.
 
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 a relative distance from the current point.
 
void append (const BezierPath &aPath)
 Appends the contents of the specified path object to the path.
 
BezierPathoperator+= (const BezierPath &aPath)
 Appends the contents of the specified path object to the path.
 
BezierPath operator+ (const BezierPath &aPath) const
 Appends the contents of the specified path object to the path.
 
void appendOval (const Rect2 &aRect)
 Appends an oval path to the path, inscribing the oval in the specified rectangle.
 
void appendRect (const Rect2 &aRect)
 Appends a rectangular path to the path.
 
void appendRoundedRect (const Rect2 &aRect, double xRadius, double yRadius)
 Appends a rounded rectangular path to the path.
 
void appendArc (const Point2 &fromPoint, const Point2 &toPoint, double radius)
 Appends an arc to the path.
 
void appendArc (const Point2 &center, double radius, const Degree &startAngle, const Degree &endAngle, bool clockwise=false)
 Appends an arc of a circle to the path.
 
void transform (const AffineTransform &aTransform)
 Transforms all points in the path using the specified transform.
 
BezierPath transformed (const AffineTransform &aTransform) const
 Transforms all points in the path using the specified transform.
 
bool contains (const Point2 &aPoint) const
 Returns a Boolean value that indicates whether the path contains the specified point.
 
bool operator& (const Point2 &aPoint) const
 Returns a Boolean value that indicates whether the path contains the specified point.
 
void flatten ()
 Computes a flattened version of the path object.
 
BezierPath flattened () const
 Computes a flattened version of the path object.
 
void reverse ()
 Computes a path containing the reversed contents of the current path object.
 
BezierPath reversed () const
 Computes a path containing the reversed contents of the current path object.
 
BezierPath expandedStrokeAsFan (const double innerWidth, const double outerWidth) const
 Creates a new bezier path containing the expanded stroke.
 
BezierPath expandedStrokeAsStrip (const double width) 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.
 
BezierPath expandedStroke (const double width) const
 Creates a new bezier path containing the expanded stroke.
 
Rect2 getBounds () const
 The bounding box of the path.
 
Rect2 getControlPointBounds () const
 The bounding box of the path, including any control points.
 
Rect2 getBoundsAccurate () const
 The bounding box of the path.
 
Point2 getCurrentPoint () const
 The current point (the trailing point or ending point in the most recently added segment).
 
bool isEmpty () const
 A Boolean value that indicates whether the path is empty.
 
bool isOpen () const
 A Boolean value that indicates whether the path is currently open.
 
bool isFlat () const
 A Boolean value that indicates whether the path is flat.
 
UInt32 getElementCount () const
 The total number of path elements in the path.
 
const ElementgetElement (UInt32 index) const
 Returns the type of path element at the specified index.
 
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.
 
const Elementoperator[] (const UInt32 index) const
 
void removeAllPoints ()
 Removes all path elements from the path, effectively clearing the path.
 
void clear ()
 Removes all path elements from the path, effectively clearing the path.
 
ElementIterator cbegin () const
 Returns an iterator that points to the first path element.
 
ElementIterator begin () const
 Returns an iterator that points to the first path element.
 
ElementIterator cend () const
 Returns an iterator that points to past-the-last path element.
 
ElementIterator end () const
 Returns an iterator that points to past-the-last path element.
 
ElementReverseIterator crbegin () const
 Returns an iterator that points to the first path element in the reversed order.
 
ElementReverseIterator rbegin () const
 Returns an iterator that points to the first path element in the reversed order.
 
ElementReverseIterator crend () const
 Returns an iterator that points to past-the-last path element in the reversed order.
 
ElementReverseIterator rend () const
 Returns an iterator that points to past-the-last path element in the reversed order.
 
Vector< SubPathgetSubPaths () const
 Gets a vector that contains all sub-paths currently on the bezier path.
 
WindingRule getWindingRule () const
 The winding rule used to fill the path.
 
void setWindingRule (WindingRule windingRule)
 The winding rule used to fill the path.
 
double getFlatness () const
 The accuracy with which curves are rendered.
 
void setFlatness (double flatness)
 The accuracy with which curves are rendered.
 
String toSVG () const
 
AnyAllocatorReference getAllocator () const noexcept
 

Static Public Member Functions

static BezierPath oval (const Rect2 &aRect)
 Creates an oval path, inscribing the oval in the specified rectangle.
 
static BezierPath oval (AnyAllocatorReference allocator, const Rect2 &aRect)
 Creates an oval path, inscribing the oval in the specified rectangle.
 
static BezierPath rect (const Rect2 &aRect)
 Creates a rectangular path.
 
static BezierPath rect (AnyAllocatorReference allocator, const Rect2 &aRect)
 \coypdoc rect(const Rect2&)
 
static BezierPath roundedRect (const Rect2 &aRect, const double xRadius, const double yRadius)
 Creates a rounded rectangular path.
 
static BezierPath roundedRect (AnyAllocatorReference allocator, const Rect2 &aRect, double xRadius, double yRadius)
 Creates a rounded rectangular path.
 
static BezierPath arc (const Point2 &fromPoint, const Point2 &toPoint, const double radius)
 Creates an arc path.
 
static BezierPath arc (AnyAllocatorReference allocator, const Point2 &fromPoint, const Point2 &toPoint, double radius)
 Creates an arc path.
 
static BezierPath arc (const Point2 &center, const double radius, const Degree &startAngle, const Degree &endAngle, const bool clockwise=false)
 Creates an arc of a circle.
 
static BezierPath arc (AnyAllocatorReference allocator, const Point2 &center, double radius, const Degree &startAngle, const Degree &endAngle, bool clockwise=false)
 Creates an arc of a circle.
 

Private Member Functions

BezierPath expandedStrokeInternal (double innerWidth, double outerWidth, bool asTriangleFan) const
 Creates a new bezier path containing the expanded stroke.
 

Private Attributes

WindingRule mWindingRule = WindingRule::NonZero
 The winding rule used to fill the path.
 
double mFlatness = 0.6
 The accuracy with which curves are rendered.
 
Deque< Element, AnyAllocatormElements {gDefaultAllocator()}
 An array of BezierPath elements.
 

Friends

bool operator== (const BezierPath &lhs, const BezierPath &rhs) noexcept
 
bool operator!= (const BezierPath &lhs, const BezierPath &rhs) noexcept
 

Detailed Description

A path that consists of straight and curved line segments that you can render.

Paths consist of straight and curved line segments joined together. Paths can form recognizable shapes such as rectangles, ovals and arcs; they can also form complex polygons using either straight or line segments. A single path can be closed by connecting its two endpoints, or it can be left open.

An BezierPath object can contain multiple disconnected paths, whether they are closed or open. Each of these paths is referred to as a subpath. The subpaths of a Bézier path object must be manipulated as a group. The only way to manipulate subpaths individually is to create separate BezierPath objects for each.

Using methods of BezierPath, you can also perform hit detection on the filled or stroked path. Hit detection is needed to implement interactive graphics, as in rubber banding and dragging operations.

Member Typedef Documentation

◆ allocator_type

◆ ElementIterator

An iterator type that allows iterating over the bezier path elements.

◆ ElementReverseIterator

An iterator type that allows iterating over the bezier path elements in reverse order.

Member Enumeration Documentation

◆ ElementType

Constants that specify basic path element commands.

These commands are enough to define all of the possible path shapes. Each command has one or more points that contain information needed to position the path element. Most path elements use the current drawing point as the starting point for drawing.

Enumerator
MoveTo 

Moves the path object's current drawing point to the specified point.

LineTo 

Creates a straight line from the current drawing point to the specified point.

CurveTo 

Creates a curved line segment from the current point to the specified endpoint using two control points to define the curve.

ClosePath 

Marks the end of the current subpath at the specified point.

◆ WindingRule

Constants that specify the winding rule a Bézier path uses.

Enumerator
NonZero 

Specifies the non-zero winding rule.

EvenOdd 

Specifies the even-odd winding rule.

Constructor & Destructor Documentation

◆ BezierPath() [1/7]

CeresEngine::BezierPath::BezierPath ( )
explicit

Creates a new empty bezier path using a default allocator.

◆ BezierPath() [2/7]

CeresEngine::BezierPath::BezierPath ( AnyAllocatorReference  allocator)
explicit

Creates a new empty bezier path using a custom allocator.

Parameters
allocatorThe allocator to be used for memory allocations.

◆ BezierPath() [3/7]

CeresEngine::BezierPath::BezierPath ( const BezierPath )
default

◆ BezierPath() [4/7]

CeresEngine::BezierPath::BezierPath ( const BezierPath ,
AnyAllocatorReference  allocator 
)

◆ BezierPath() [5/7]

CeresEngine::BezierPath::BezierPath ( BezierPath &&  )
defaultnoexcept

◆ ~BezierPath()

CeresEngine::BezierPath::~BezierPath ( )
default

◆ BezierPath() [6/7]

template<typename Allocator >
CeresEngine::BezierPath::BezierPath ( std::allocator_arg_t  ,
const Allocator &  allocator 
)
inlineexplicit

Creates a new empty bezier path using a custom allocator.

Parameters
allocatorThe allocator to be used for memory allocations.

◆ BezierPath() [7/7]

template<typename Allocator >
CeresEngine::BezierPath::BezierPath ( std::allocator_arg_t  ,
const Allocator &  allocator,
const BezierPath other 
)
inlineexplicit

Member Function Documentation

◆ append()

void CeresEngine::BezierPath::append ( const BezierPath aPath)

Appends the contents of the specified path object to the path.

This method adds the commands used to create aPath to the end of the receiver's path. This method does not explicitly try to connect the subpaths in the two objects, although the operations in aPath may still cause that effect.

Parameters
aPathThe path to add to the receiver.

◆ appendArc() [1/2]

void CeresEngine::BezierPath::appendArc ( const Point2 &  center,
double  radius,
const Degree &  startAngle,
const Degree &  endAngle,
bool  clockwise = false 
)

Appends an arc of a circle to the path.

The created arc lies on the perimeter of the circle, between the angles specified by the startAngle and endAngle parameters. The arc is drawn in the direction indicated by the clockwise parameter. If the receiver's path is empty, this method sets the current point to the beginning of the arc before adding the arc segment. If the receiver's path is not empty, a line is drawn from the current point to the starting point of the arc.

Depending on the length of the arc, this method may add multiple connected curve segments to the path.

Parameters
centerSpecifies the center point of the circle used to define the arc.
radiusSpecifies the radius of the circle used to define the arc.
startAngleSpecifies the starting angle of the arc, measured in degrees counterclockwise from the x-axis.
endAngleSpecifies the end angle of the arc, measured in degrees counterclockwise from the x-axis.
clockwisetrue if you want the arc to be drawn in a clockwise direction; otherwise false to draw the arc in a counterclockwise direction.

◆ appendArc() [2/2]

void CeresEngine::BezierPath::appendArc ( const Point2 &  fromPoint,
const Point2 &  toPoint,
double  radius 
)

Appends an arc to the path.

The created arc is defined by a circle inscribed inside the angle specified by three points: the current point, the fromPoint parameter, and the toPoint parameter (in that order). The arc itself lies on the perimeter of the circle, whose radius is specified by the radius parameter. The arc is drawn between the two points of the circle that are tangent to the two legs of the angle.

The arc usually does not contain the points in the fromPoint and toPoint parameters. If the starting point of the arc does not coincide with the current point, a line is drawn between the two points. The starting point of the arc lies on the line defined by the current point and the fromPoint parameter.

You must set the path's current point (using the move method or through the creation of a preceding line or curve segment) before you invoke this method. If the path is empty, this method throws.

Depending on the length of the arc, this method may add multiple connected curve segments to the path.

Parameters
fromPointThe middle point of the angle.
toPointThe end point of the angle.
radiusThe radius of the circle inscribed in the angle.

◆ appendOval()

void CeresEngine::BezierPath::appendOval ( const Rect2 &  aRect)

Appends an oval path to the path, inscribing the oval in the specified rectangle.

Before adding the oval, this method moves the current point, which implicitly closes the current subpath. If the aRect parameter specifies a square, the inscribed path is a circle. The path is constructed by starting in the lower-right quadrant of the rectangle and adding arc segments counterclockwise to complete the oval.

Parameters
aRectThe rectangle in which to inscribe the oval.

◆ appendRect()

void CeresEngine::BezierPath::appendRect ( const Rect2 &  aRect)

Appends a rectangular path to the path.

Before adding the rectangle, this method moves the current point to the origin of the rectangle, which implicitly closes the current subpath (if any). The path is constructed by starting at the origin of aRect and adding line segments in a counterclockwise direction. The final segment is added using close.

Parameters
aRectThe rectangle describing the path to create.

◆ appendRoundedRect()

void CeresEngine::BezierPath::appendRoundedRect ( const Rect2 &  aRect,
double  xRadius,
double  yRadius 
)

Appends a rounded rectangular path to the path.

The path is constructed in a counter-clockwise direction, starting at the top-left corner of the rectangle. If either one of the radius parameters contains the value 0.0, the returned path is a plain rectangle without rounded corners.

Parameters
aRectThe rectangle that defines the basic shape of the path.
xRadiusThe radius of each corner oval along the x-axis. Values larger than half the rectangle's width are clamped to half the width.
yRadiusThe radius of each corner oval along the y-axis. Values larger than half the rectangle's height are clamped to half the height.

◆ arc() [1/4]

static BezierPath CeresEngine::BezierPath::arc ( AnyAllocatorReference  allocator,
const Point2 &  center,
double  radius,
const Degree &  startAngle,
const Degree &  endAngle,
bool  clockwise = false 
)
static

Creates an arc of a circle.

The created arc lies on the perimeter of the circle, between the angles specified by the startAngle and endAngle parameters. The arc is drawn in the direction indicated by the clockwise parameter.

Depending on the length of the arc, this method may add multiple connected curve segments to the path.

Parameters
centerSpecifies the center point of the circle used to define the arc.
radiusSpecifies the radius of the circle used to define the arc.
startAngleSpecifies the starting angle of the arc, measured in degrees counterclockwise from the x-axis.
endAngleSpecifies the end angle of the arc, measured in degrees counterclockwise from the x-axis.
clockwisetrue if you want the arc to be drawn in a clockwise direction; otherwise false to draw the arc in a counterclockwise direction.

◆ arc() [2/4]

static BezierPath CeresEngine::BezierPath::arc ( AnyAllocatorReference  allocator,
const Point2 &  fromPoint,
const Point2 &  toPoint,
double  radius 
)
static

Creates an arc path.

The created arc is defined by a circle inscribed inside the angle specified by three points: the current point, the fromPoint parameter, and the toPoint parameter (in that order). The arc itself lies on the perimeter of the circle, whose radius is specified by the radius parameter. The arc is drawn between the two points of the circle that are tangent to the two legs of the angle.

The arc usually does not contain the points in the fromPoint and toPoint parameters. If the starting point of the arc does not coincide with the current point, a line is drawn between the two points. The starting point of the arc lies on the line defined by the current point and the fromPoint parameter.

Depending on the length of the arc, this method may add multiple connected curve segments to the path.

Parameters
fromPointThe middle point of the angle.
toPointThe end point of the angle.
radiusThe radius of the circle inscribed in the angle.

◆ arc() [3/4]

static BezierPath CeresEngine::BezierPath::arc ( const Point2 &  center,
const double  radius,
const Degree &  startAngle,
const Degree &  endAngle,
const bool  clockwise = false 
)
inlinestatic

Creates an arc of a circle.

The created arc lies on the perimeter of the circle, between the angles specified by the startAngle and endAngle parameters. The arc is drawn in the direction indicated by the clockwise parameter.

Depending on the length of the arc, this method may add multiple connected curve segments to the path.

Parameters
centerSpecifies the center point of the circle used to define the arc.
radiusSpecifies the radius of the circle used to define the arc.
startAngleSpecifies the starting angle of the arc, measured in degrees counterclockwise from the x-axis.
endAngleSpecifies the end angle of the arc, measured in degrees counterclockwise from the x-axis.
clockwisetrue if you want the arc to be drawn in a clockwise direction; otherwise false to draw the arc in a counterclockwise direction.

◆ arc() [4/4]

static BezierPath CeresEngine::BezierPath::arc ( const Point2 &  fromPoint,
const Point2 &  toPoint,
const double  radius 
)
inlinestatic

Creates an arc path.

The created arc is defined by a circle inscribed inside the angle specified by three points: the current point, the fromPoint parameter, and the toPoint parameter (in that order). The arc itself lies on the perimeter of the circle, whose radius is specified by the radius parameter. The arc is drawn between the two points of the circle that are tangent to the two legs of the angle.

The arc usually does not contain the points in the fromPoint and toPoint parameters. If the starting point of the arc does not coincide with the current point, a line is drawn between the two points. The starting point of the arc lies on the line defined by the current point and the fromPoint parameter.

Depending on the length of the arc, this method may add multiple connected curve segments to the path.

Parameters
fromPointThe middle point of the angle.
toPointThe end point of the angle.
radiusThe radius of the circle inscribed in the angle.

◆ begin()

ElementIterator CeresEngine::BezierPath::begin ( ) const
inline

Returns an iterator that points to the first path element.

◆ cbegin()

ElementIterator CeresEngine::BezierPath::cbegin ( ) const
inline

Returns an iterator that points to the first path element.

◆ cend()

ElementIterator CeresEngine::BezierPath::cend ( ) const
inline

Returns an iterator that points to past-the-last path element.

◆ clear()

void CeresEngine::BezierPath::clear ( )
inline

Removes all path elements from the path, effectively clearing the path.

◆ close()

void CeresEngine::BezierPath::close ( )

Closes the most recently added subpath.

This method closes the current subpath by creating a line segment between the first and last points in the subpath. This method subsequently updates the current point to the end of the newly created line segment, which is also the first point in the now closed subpath.

◆ contains()

bool CeresEngine::BezierPath::contains ( const Point2 &  aPoint) const

Returns a Boolean value that indicates whether the path contains the specified point.

This method checks the point against the path itself and the area it encloses. When determining hits in the enclosed area, this method uses the non-zero winding rule (nonZero). It does not take into account the line width used to stroke the path.

Parameters
aPointThe point to test against the path, specified in the path object's coordinate system.
Returns
true if the path's enclosed area contains the specified point; otherwise, false.

◆ crbegin()

ElementReverseIterator CeresEngine::BezierPath::crbegin ( ) const
inline

Returns an iterator that points to the first path element in the reversed order.

◆ crend()

ElementReverseIterator CeresEngine::BezierPath::crend ( ) const
inline

Returns an iterator that points to past-the-last path element in the reversed order.

◆ curve() [1/2]

void CeresEngine::BezierPath::curve ( const Point2 &  aPoint,
const Point2 &  controlPoint1,
const Point2 &  controlPoint2 
)

Adds a Bezier cubic curve to the path.

Parameters
aPointThe destination point of the curve segment, specified in the current coordinate system.
controlPoint1The point that determines the shape of the curve near the current point.
controlPoint2The point that determines the shape of the curve near the destination point.

◆ curve() [2/2]

void CeresEngine::BezierPath::curve ( double  x,
double  y,
double  c1x,
double  c1y,
double  c2x,
double  c2y 
)
inline

Adds a Bezier cubic curve to the path.

Parameters
aPointThe destination point of the curve segment, specified in the current coordinate system.
controlPoint1The point that determines the shape of the curve near the current point.
controlPoint2The point that determines the shape of the curve near the destination point.

◆ end()

ElementIterator CeresEngine::BezierPath::end ( ) const
inline

Returns an iterator that points to past-the-last path element.

◆ expandedStroke() [1/2]

BezierPath CeresEngine::BezierPath::expandedStroke ( const double  innerWidth,
const double  outerWidth 
) const
inline

Creates a new bezier path containing the expanded stroke.

◆ expandedStroke() [2/2]

BezierPath CeresEngine::BezierPath::expandedStroke ( const double  width) const
inline

Creates a new bezier path containing the expanded stroke.

◆ expandedStrokeAsFan()

BezierPath CeresEngine::BezierPath::expandedStrokeAsFan ( const double  innerWidth,
const double  outerWidth 
) const
inline

Creates a new bezier path containing the expanded stroke.

◆ expandedStrokeAsStrip()

BezierPath CeresEngine::BezierPath::expandedStrokeAsStrip ( const double  width) const
inline

Creates a new bezier path containing the expanded stroke.

◆ expandedStrokeInternal()

BezierPath CeresEngine::BezierPath::expandedStrokeInternal ( double  innerWidth,
double  outerWidth,
bool  asTriangleFan 
) const
private

Creates a new bezier path containing the expanded stroke.

◆ flatten()

void CeresEngine::BezierPath::flatten ( )

Computes a flattened version of the path object.

Flattening a path converts all curved line segments into straight line approximations. The granularity of the approximations is controlled by the path's current flatness value, which is set using the setFlatness method.

◆ flattened()

BezierPath CeresEngine::BezierPath::flattened ( ) const

Computes a flattened version of the path object.

Flattening a path converts all curved line segments into straight line approximations. The granularity of the approximations is controlled by the path's current flatness value, which is set using the setFlatness method.

◆ getAllocator()

AnyAllocatorReference CeresEngine::BezierPath::getAllocator ( ) const
inlinenoexcept

◆ getBounds()

Rect2 CeresEngine::BezierPath::getBounds ( ) const

The bounding box of the path.

This property contains the rectangle that encloses the path of the receiver. If the path contains curve segments, the bounding box encloses the curve but may not enclose the control points used to calculate the curve.

If the path is empty, this method returns an empty rect.

◆ getBoundsAccurate()

Rect2 CeresEngine::BezierPath::getBoundsAccurate ( ) const

The bounding box of the path.

This property contains the rectangle that encloses the path of the receiver. This method performs a more accurate bounding box calculation by flattening the path. This is a slow operation, so only use it when you actually need a precise bounding box.

If the path is empty, this method returns an empty rect.

◆ getControlPointBounds()

Rect2 CeresEngine::BezierPath::getControlPointBounds ( ) const

The bounding box of the path, including any control points.

This property contains the rectangle that encloses the receiver's path. If the path contains curve segments, the bounding box encloses the control points of the curves as well as the curves themselves.

◆ getCurrentPoint()

Point2 CeresEngine::BezierPath::getCurrentPoint ( ) const

The current point (the trailing point or ending point in the most recently added segment).

If the path is empty, accessing this property returns a zero point.

◆ getElement() [1/2]

const Element & CeresEngine::BezierPath::getElement ( UInt32  index) const

Returns the type of path element at the specified index.

Path elements describe the commands used to define a path and include basic commands such as moving to a specific point, creating a line segment, creating a curve, or closing the path. The elements are stored in the order of their execution.

Parameters
indexThe index of the desired path element.
Returns
A reference to the internal Element structure.

◆ getElement() [2/2]

ElementType CeresEngine::BezierPath::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.

Move, close path, and line segment commands return one point. Curve operations return three points. For curve operations, the order of the points is controlPoint1 (aPoint0), controlPoint2 (aPoint1), endPoint (aPoint2).

Parameters
indexThe index of the desired path element.
aPoint0The first associated point for the element.
aPoint1The second associated point for the element.
aPoint2The third associated point for the element.
Returns
The type of the path element. For a list of constants, see ElementType.

◆ getElementCount()

UInt32 CeresEngine::BezierPath::getElementCount ( ) const

The total number of path elements in the path.

Each element type corresponds to one of the operations described in ElementType.

◆ getFlatness()

double CeresEngine::BezierPath::getFlatness ( ) const
inline

The accuracy with which curves are rendered.

The flatness value specifies the accuracy (or smoothness) with which curves are rendered. It is also the maximum error tolerance (measured in pixels) for rendering curves, where smaller numbers give smoother curves at the expense of more computation. The exact interpretation may vary slightly on different rendering devices.

◆ getSubPaths()

Vector< SubPath > CeresEngine::BezierPath::getSubPaths ( ) const

Gets a vector that contains all sub-paths currently on the bezier path.

◆ getWindingRule()

WindingRule CeresEngine::BezierPath::getWindingRule ( ) const
inline

The winding rule used to fill the path.

◆ isEmpty()

bool CeresEngine::BezierPath::isEmpty ( ) const

A Boolean value that indicates whether the path is empty.

The value of this property is true if the path contains no elements, or false if it contains at least one element.

◆ isFlat()

bool CeresEngine::BezierPath::isFlat ( ) const

A Boolean value that indicates whether the path is flat.

The value of this property is true if the path contains only move, lineTo and close elements, or false if it contains at least one of any other type of element.

◆ isOpen()

bool CeresEngine::BezierPath::isOpen ( ) const

A Boolean value that indicates whether the path is currently open.

The value of this property is true if the path is currently open, or false if it's last element is a close path element.

◆ line() [1/2]

void CeresEngine::BezierPath::line ( const Point2 &  aPoint)

Appends a straight line to the path.

This method creates a straight line segment starting at the current point and ending at the point specified by the aPoint parameter. The current point is the last point in the receiver's most recently added segment.

You must set the path's current point (using the move() method or through the creation of a preceding line or curve segment) before you invoke this method. If the path is empty, this method throws.

Parameters
aPointThe destination point of the line segment, specified in the current coordinate system.

◆ line() [2/2]

void CeresEngine::BezierPath::line ( double  x,
double  y 
)
inline

Appends a straight line to the path.

This method creates a straight line segment starting at the current point and ending at the point specified by the aPoint parameter. The current point is the last point in the receiver's most recently added segment.

You must set the path's current point (using the move() method or through the creation of a preceding line or curve segment) before you invoke this method. If the path is empty, this method throws.

Parameters
aPointThe destination point of the line segment, specified in the current coordinate system.

◆ move() [1/2]

void CeresEngine::BezierPath::move ( const Point2 &  aPoint)

Moves the path's current point to the specified location.

This method implicitly closes the current subpath (if any) and sets the current point to the value in aPoint. When closing the previous subpath, this method does not cause a line to be created from the first and last points in the subpath.

For many path operations, you must invoke this method before issuing any commands that cause a line or curve segment to be drawn.

Parameters
aPointA point in the current coordinate system.

◆ move() [2/2]

void CeresEngine::BezierPath::move ( double  x,
double  y 
)
inline

Moves the path's current point to the specified location.

This method implicitly closes the current subpath (if any) and sets the current point to the value in aPoint. When closing the previous subpath, this method does not cause a line to be created from the first and last points in the subpath.

For many path operations, you must invoke this method before issuing any commands that cause a line or curve segment to be drawn.

Parameters
aPointA point in the current coordinate system.

◆ operator&()

bool CeresEngine::BezierPath::operator& ( const Point2 &  aPoint) const
inline

Returns a Boolean value that indicates whether the path contains the specified point.

This method checks the point against the path itself and the area it encloses. When determining hits in the enclosed area, this method uses the non-zero winding rule (nonZero). It does not take into account the line width used to stroke the path.

Parameters
aPointThe point to test against the path, specified in the path object's coordinate system.
Returns
true if the path's enclosed area contains the specified point; otherwise, false.

◆ operator+()

BezierPath CeresEngine::BezierPath::operator+ ( const BezierPath aPath) const
inline

Appends the contents of the specified path object to the path.

This method adds the commands used to create aPath to the end of the receiver's path. This method does not explicitly try to connect the subpaths in the two objects, although the operations in aPath may still cause that effect.

Parameters
aPathThe path to add to the receiver.

◆ operator+=()

BezierPath & CeresEngine::BezierPath::operator+= ( const BezierPath aPath)
inline

Appends the contents of the specified path object to the path.

This method adds the commands used to create aPath to the end of the receiver's path. This method does not explicitly try to connect the subpaths in the two objects, although the operations in aPath may still cause that effect.

Parameters
aPathThe path to add to the receiver.

◆ operator=() [1/2]

BezierPath & CeresEngine::BezierPath::operator= ( BezierPath &&  )
defaultnoexcept

◆ operator=() [2/2]

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

◆ operator[]()

const Element & CeresEngine::BezierPath::operator[] ( const UInt32  index) const
inline

◆ oval() [1/2]

static BezierPath CeresEngine::BezierPath::oval ( AnyAllocatorReference  allocator,
const Rect2 &  aRect 
)
static

Creates an oval path, inscribing the oval in the specified rectangle.

The path is constructed by starting in the lower-right quadrant of the rectangle and adding arc segments counterclockwise to complete the oval.

Parameters
aRectThe rectangle in which to inscribe the oval.

◆ oval() [2/2]

static BezierPath CeresEngine::BezierPath::oval ( const Rect2 &  aRect)
inlinestatic

Creates an oval path, inscribing the oval in the specified rectangle.

The path is constructed by starting in the lower-right quadrant of the rectangle and adding arc segments counterclockwise to complete the oval.

Parameters
aRectThe rectangle in which to inscribe the oval.

◆ rbegin()

ElementReverseIterator CeresEngine::BezierPath::rbegin ( ) const
inline

Returns an iterator that points to the first path element in the reversed order.

◆ rect() [1/2]

static BezierPath CeresEngine::BezierPath::rect ( AnyAllocatorReference  allocator,
const Rect2 &  aRect 
)
static

◆ rect() [2/2]

static BezierPath CeresEngine::BezierPath::rect ( const Rect2 &  aRect)
inlinestatic

Creates a rectangular path.

The path is constructed by starting at the origin of aRect and adding line segments in a counterclockwise direction. The final segment is added using close.

Parameters
aRectThe rectangle describing the path to create.

◆ relativeCurve()

void CeresEngine::BezierPath::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 a relative distance from the current point.

You must set the path's current point (using the move() method or through the creation of a preceding line or curve segment) before you invoke this method. If the path is empty, this method throws.

Parameters
aPointThe destination point of the curve segment, interpreted as a relative offset from the current point.
controlPoint1The point that determines the shape of the curve near the current point, interpreted as a relative offset from the current point.
controlPoint2The point that determines the shape of the curve near the destination point, interpreted as a relative offset from the current point.

◆ relativeLine()

void CeresEngine::BezierPath::relativeLine ( const Point2 &  aPoint)

Appends a straight line segment to the path starting at the current point and moving towards the specified point, relative to the current location.

The destination point is relative to the current point. For example, if the current point is (1, 1) and aPoint contains the value (1, 2), a line segment is created between the points (1, 1) and (2, 3).

You must set the path's current point (using the move() method or through the creation of a preceding line or curve segment) before you invoke this method. If the path is empty, this method throws.

Parameters
aPointA point whose coordinates are interpreted as a relative offset from the current point.

◆ relativeMove()

void CeresEngine::BezierPath::relativeMove ( const Point2 &  aPoint)

Moves the path's current point to a new point whose location is the specified distance from the current point.

This method implicitly closes the current subpath (if any) and updates the location of the current point. For example, if the current point is (1, 1) and aPoint contains the value (1, 2), the previous subpath would be closed and the current point would become (2, 3). When closing the previous subpath, this method does not cause a line to be created from the first and last points in the subpath.

You must set the path's current point (using the move() method or through the creation of a preceding line or curve segment) before you invoke this method. If the path is empty, this method throws.

Parameters
aPointA point whose coordinates are interpreted as a relative offset from the current point.

◆ removeAllPoints()

void CeresEngine::BezierPath::removeAllPoints ( )

Removes all path elements from the path, effectively clearing the path.

◆ rend()

ElementReverseIterator CeresEngine::BezierPath::rend ( ) const
inline

Returns an iterator that points to past-the-last path element in the reversed order.

◆ reverse()

void CeresEngine::BezierPath::reverse ( )

Computes a path containing the reversed contents of the current path object.

The reversed path does not necessarily have a different appearance when rendered. Instead, it changes the direction in which path segments are drawn. For example, reversing the path of a rectangle (whose line segments are normally drawn starting at the origin and proceeding in a counterclockwise direction) causes its line segments to be drawn in a clockwise direction instead. Drawing a reversed path could affect the appearance of a filled pattern, depending on the pattern and the fill rule in use.

The path is created by reversing each whole or partial subpath in the path object individually.

◆ reversed()

BezierPath CeresEngine::BezierPath::reversed ( ) const

Computes a path containing the reversed contents of the current path object.

The reversed path does not necessarily have a different appearance when rendered. Instead, it changes the direction in which path segments are drawn. For example, reversing the path of a rectangle (whose line segments are normally drawn starting at the origin and proceeding in a counterclockwise direction) causes its line segments to be drawn in a clockwise direction instead. Drawing a reversed path could affect the appearance of a filled pattern, depending on the pattern and the fill rule in use.

The path is created by reversing each whole or partial subpath in the path object individually.

◆ roundedRect() [1/2]

static BezierPath CeresEngine::BezierPath::roundedRect ( AnyAllocatorReference  allocator,
const Rect2 &  aRect,
double  xRadius,
double  yRadius 
)
static

Creates a rounded rectangular path.

The path is constructed in a counter-clockwise direction, starting at the top-left corner of the rectangle. If either one of the radius parameters contains the value 0.0, the returned path is a plain rectangle without rounded corners.

Parameters
aRectThe rectangle that defines the basic shape of the path.
xRadiusThe radius of each corner oval along the x-axis. Values larger than half the rectangle's width are clamped to half the width.
yRadiusThe radius of each corner oval along the y-axis. Values larger than half the rectangle's height are clamped to half the height.

◆ roundedRect() [2/2]

static BezierPath CeresEngine::BezierPath::roundedRect ( const Rect2 &  aRect,
const double  xRadius,
const double  yRadius 
)
inlinestatic

Creates a rounded rectangular path.

The path is constructed in a counter-clockwise direction, starting at the top-left corner of the rectangle. If either one of the radius parameters contains the value 0.0, the returned path is a plain rectangle without rounded corners.

Parameters
aRectThe rectangle that defines the basic shape of the path.
xRadiusThe radius of each corner oval along the x-axis. Values larger than half the rectangle's width are clamped to half the width.
yRadiusThe radius of each corner oval along the y-axis. Values larger than half the rectangle's height are clamped to half the height.

◆ setFlatness()

void CeresEngine::BezierPath::setFlatness ( double  flatness)

The accuracy with which curves are rendered.

The flatness value specifies the accuracy (or smoothness) with which curves are rendered. It is also the maximum error tolerance (measured in pixels) for rendering curves, where smaller numbers give smoother curves at the expense of more computation. The exact interpretation may vary slightly on different rendering devices.

◆ setWindingRule()

void CeresEngine::BezierPath::setWindingRule ( WindingRule  windingRule)

The winding rule used to fill the path.

◆ toSVG()

String CeresEngine::BezierPath::toSVG ( ) const

◆ transform()

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

Transforms all points in the path using the specified transform.

This method applies the transform to the path's points immediately.

Parameters
aTransformThe transform to apply to the path.

◆ transformed()

BezierPath CeresEngine::BezierPath::transformed ( const AffineTransform &  aTransform) const

Transforms all points in the path using the specified transform.

This method applies the transform to the path's points immediately.

Parameters
aTransformThe transform to apply to the path.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const BezierPath lhs,
const BezierPath rhs 
)
friend

◆ operator==

bool operator== ( const BezierPath lhs,
const BezierPath rhs 
)
friend

Member Data Documentation

◆ mElements

Deque<Element, AnyAllocator> CeresEngine::BezierPath::mElements {gDefaultAllocator()}
private

An array of BezierPath elements.

◆ mFlatness

double CeresEngine::BezierPath::mFlatness = 0.6
private

The accuracy with which curves are rendered.

The flatness value specifies the accuracy (or smoothness) with which curves are rendered. It is also the maximum error tolerance (measured in pixels) for rendering curves, where smaller numbers give smoother curves at the expense of more computation. The exact interpretation may vary slightly on different rendering devices.

◆ mWindingRule

WindingRule CeresEngine::BezierPath::mWindingRule = WindingRule::NonZero
private

The winding rule used to fill the path.


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