|
CeresEngine 0.2.0
A game development framework
|
A type that describes a conjunction of shapes that can be filled and stroked. More...
#include <CeresEngine/Graphics/Shape.hpp>
Classes | |
| struct | Element |
| An element is composed of a path and one or more commands to be done on that path. More... | |
Public Types | |
| enum class | LineCapStyle { Butt , Round , Square } |
| Constants that specify the shape of endpoints for an open path when it is stroked. More... | |
| enum class | LineJoinStyle { Miter , Round , Bevel } |
| Constants that specify the shape of the joins between connected segments of a stroked path. More... | |
| enum class | BlendMode { Normal , Multiply , Screen , Overlay , Darken , Lighten , ColorDodge , ColorBurn , SoftLight , HardLight , Difference , Exclusion , Hue , Saturation , Color , Luminosity , Clear , Copy , SourceIn , SourceOut , SourceAtop , DestinationOver , DestinationIn , DestinationOut , DestinationAtop , XorOp , PlusDarker , PlusLighter } |
| Compositing operations for images. More... | |
| enum class | ElementType { Fill , Stroke } |
| using | ElementIterator = typename Deque< Element >::const_iterator |
| An iterator type that allows iterating over the shape elements. | |
| using | allocator_type = AnyStdAllocator< Shape > |
Public Member Functions | |
| Shape () | |
| Creates a new empty shape using a default allocator. | |
| Shape (AnyAllocatorReference allocator) | |
| Creates a new empty shape using a custom allocator. | |
| Shape (const Shape &other) | |
| Shape & | operator= (const Shape &other) |
| Shape (const Shape &other, AnyAllocatorReference allocator) | |
| Shape (Shape &&other) noexcept | |
| Shape & | operator= (Shape &&other) noexcept |
| ~Shape ()=default | |
| template<typename Allocator > | |
| Shape (std::allocator_arg_t, const Allocator &allocator) | |
| Creates a new empty shape using a custom allocator. | |
| template<typename Allocator > | |
| Shape (std::allocator_arg_t, const Allocator &allocator, const Shape &other) | |
| 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. | |
| 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. | |
| void | fill (const BezierPath &path, const Paint &paint, BlendMode blendMode=BlendMode::Normal) |
Paints the region enclosed by the path. | |
| void | fill (BezierPath &&path, const Paint &paint, BlendMode blendMode=BlendMode::Normal) |
Paints the region enclosed by the path. | |
| void | append (const Shape &aShape) |
| Appends the contents of the specified shape object to the shape. | |
| void | append (Shape &&aShape) |
| Appends the contents of the specified shape object to the shape. | |
| Shape & | operator+= (const Shape &aShape) |
| Appends the contents of the specified shape object to the shape. | |
| Shape & | operator+= (Shape &&aShape) |
| Appends the contents of the specified shape object to the shape. | |
| Shape | operator+ (const Shape &aShape) const |
| Appends the contents of the specified shape object to the shape. | |
| Shape | operator+ (Shape &&aShape) const |
| Appends the contents of the specified shape object to the shape. | |
| void | transform (const AffineTransform &aTransform) |
| Transforms all points in the shape using the specified transform. | |
| Shape | transformed (const AffineTransform &aTransform) const & |
| Transforms all points in the shape using the specified transform. | |
| Shape && | transformed (const AffineTransform &aTransform) && |
| Transforms all points in the shape using the specified transform. | |
| bool | contains (const Point2 &aPoint) const |
| Returns a Boolean value that indicates whether the shape contains the specified point. | |
| bool | operator& (const Point2 &aPoint) const |
| Returns a Boolean value that indicates whether the shape contains the specified point. | |
| void | flatten () |
| Computes a flattened version of the shape object. | |
| Shape | flattened () const & |
| Computes a flattened version of the shape object. | |
| Shape && | flattened () && |
| Computes a flattened version of the shape object. | |
| void | reverse () |
| Computes a shape containing the reversed contents of the current shape path objects. | |
| Shape | reversed () const & |
| Computes a shape containing the reversed contents of the current shape path objects. | |
| Shape && | reversed () && |
| Computes a shape containing the reversed contents of the current shape path objects. | |
| Rect2 | getBounds () const |
| The bounding box of the shape. | |
| Rect2 | getControlPointBounds () const |
| The bounding box of the shape, including any control points. | |
| Rect2 | getBoundsAccurate () const |
| The bounding box of the shape. | |
| bool | isEmpty () const |
| A Boolean value that indicates whether the shape is empty. | |
| UInt32 | getElementCount () const |
| The total number of shape elements in the shape. | |
| const Element & | getElement (UInt32 index) const |
| Returns the type of shape element at the specified index. | |
| const Element & | operator[] (const UInt32 index) const |
| Returns the type of shape element at the specified index. | |
| 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. | |
| AnyAllocatorReference | getAllocator () const noexcept |
Private Member Functions | |
| const BezierPath & | appendPath (const BezierPath &path) |
| Appends a path to the internal list of paths. | |
| const BezierPath & | appendPath (BezierPath &&path) |
| Appends a path to the internal list of paths. | |
| Element & | appendElement (ElementType type, const BezierPath &path) |
| Appends a new element to the shape. | |
| Element & | appendElement (ElementType type, BezierPath &&path) |
| Appends a new element to the shape. | |
Private Attributes | |
| Deque< BezierPath, AnyAllocator > | mPaths {gDefaultAllocator()} |
| A vector that stores a unique copy of each path. | |
| Deque< Element, AnyAllocator > | mElements {gDefaultAllocator()} |
| A vector of all elements in the shape. | |
A type that describes a conjunction of shapes that can be filled and stroked.
For a given Shape object, you can stroke the path's outline or fill the region occupied by a BezierPath. Using methods of Shape, 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.
| using CeresEngine::Shape::ElementIterator = typename Deque<Element>::const_iterator |
An iterator type that allows iterating over the shape elements.
Compositing operations for images.
These blend mode constants represent the Porter-Duff blend modes. The symbols in the equations for these blend modes are:
You can find more information on blend modes, including examples of images produced using them, and many mathematical descriptions of the modes, in PDF Reference, Fourth Edition, Version 1.5, Adobe Systems, Inc. If you are a former QuickDraw developer, it may be helpful for you to think of blend modes as an alternative to transfer modes.
Constants that specify the shape of endpoints for an open path when it is stroked.
Constants that specify the shape of the joins between connected segments of a stroked path.
|
explicit |
Creates a new empty shape using a default allocator.
|
explicit |
Creates a new empty shape using a custom allocator.
| allocator | The allocator to be used for memory allocations. |
| CeresEngine::Shape::Shape | ( | const Shape & | other, |
| AnyAllocatorReference | allocator | ||
| ) |
|
noexcept |
|
default |
|
inlineexplicit |
Creates a new empty shape using a custom allocator.
| allocator | The allocator to be used for memory allocations. |
|
inlineexplicit |
Appends the contents of the specified shape object to the shape.
This method adds the commands used to create aShape to the end of the receiver's shape.
| aShape | The shape to add to the receiver. |
Appends the contents of the specified shape object to the shape.
This method adds the commands used to create aShape to the end of the receiver's shape.
| aShape | The shape to add to the receiver. |
|
private |
Appends a new element to the shape.
The path will be appended to the internal path list if needed.
| type | The shape element type. |
| path | The shape bezier path. If needed, will be appended into the internal list. |
|
private |
Appends a new element to the shape.
The path will be appended to the internal path list if needed.
| type | The shape element type. |
| path | The shape bezier path. If needed, will be appended into the internal list. |
|
private |
Appends a path to the internal list of paths.
If an equal path already exists, it is returned instead.
| path | The path to be appended. |
|
private |
Appends a path to the internal list of paths.
If an equal path already exists, it is returned instead.
| path | The path to be appended. |
|
inline |
Returns an iterator that points to the first path element.
|
inline |
Returns an iterator that points to the first path element.
|
inline |
Returns an iterator that points to past-the-last path element.
Returns a Boolean value that indicates whether the shape contains the specified point.
This method checks the point against the shape 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.
| aPoint | The point to test against the shape, specified in the shape object's coordinate system. |
true if the shape's enclosed area contains the specified point; otherwise, false.
|
inline |
Returns an iterator that points to past-the-last path element.
| void CeresEngine::Shape::fill | ( | BezierPath && | path, |
| const Paint & | paint, | ||
| BlendMode | blendMode = BlendMode::Normal |
||
| ) |
Paints the region enclosed by the path.
This method fills the path using the given fill color and the receiver's current winding rule. If the path contains any open subpaths, this method implicitly closes them before painting the fill region.
The painted region includes the pixels right up to, but not including, the path line itself. For paths with large line widths, this can result in overlap between the fill region and the stroked path (which is itself centered on the path line).
| path | The path to be filled. |
| paint | The color to fill the path with. |
| void CeresEngine::Shape::fill | ( | const BezierPath & | path, |
| const Paint & | paint, | ||
| BlendMode | blendMode = BlendMode::Normal |
||
| ) |
Paints the region enclosed by the path.
This method fills the path using the given fill color and the receiver's current winding rule. If the path contains any open subpaths, this method implicitly closes them before painting the fill region.
The painted region includes the pixels right up to, but not including, the path line itself. For paths with large line widths, this can result in overlap between the fill region and the stroked path (which is itself centered on the path line).
| path | The path to be filled. |
| paint | The color to fill the path with. |
| void CeresEngine::Shape::flatten | ( | ) |
Computes a flattened version of the shape object.
Flattening a shape converts all it's paths segments into straight line approximations. The granularity of the approximations is controlled by the path's current flatness value, which is set using the BezierPath::setFlatness method.
|
inline |
Computes a flattened version of the shape object.
Flattening a shape converts all it's paths segments into straight line approximations. The granularity of the approximations is controlled by the path's current flatness value, which is set using the BezierPath::setFlatness method.
| Shape CeresEngine::Shape::flattened | ( | ) | const & |
Computes a flattened version of the shape object.
Flattening a shape converts all it's paths segments into straight line approximations. The granularity of the approximations is controlled by the path's current flatness value, which is set using the BezierPath::setFlatness method.
|
inlinenoexcept |
| Rect2 CeresEngine::Shape::getBounds | ( | ) | const |
The bounding box of the shape.
This property contains the rectangle that encloses the shape of the receiver. If the shape contains curve segments, the bounding box encloses the curve but may not enclose the control points used to calculate the curve.
If the shape is empty, this method returns an empty rect.
| Rect2 CeresEngine::Shape::getBoundsAccurate | ( | ) | const |
The bounding box of the shape.
This property contains the rectangle that encloses the shape of the receiver. This method performs a more accurate bounding box calculation by flattening the shape paths. This is a slow operation, so only use it when you actually need a precise bounding box.
If the shape is empty, this method returns an empty rect.
| Rect2 CeresEngine::Shape::getControlPointBounds | ( | ) | const |
The bounding box of the shape, including any control points.
This property contains the rectangle that encloses the receiver's path. If the shape contains curve segments, the bounding box encloses the control points of the curves as well as the curves themselves.
Returns the type of shape element at the specified index.
Path elements describe the commands used to draw a path and include basic commands such as filling and stroking. The elements are stored in the order of their execution.
| index | The index of the desired shape element. |
Element structure. | UInt32 CeresEngine::Shape::getElementCount | ( | ) | const |
The total number of shape elements in the shape.
Each element type corresponds to one of the operations described in ElementType.
| bool CeresEngine::Shape::isEmpty | ( | ) | const |
A Boolean value that indicates whether the shape is empty.
The value of this property is true if the shape contains no elements, or false if it contains at least one element.
Returns a Boolean value that indicates whether the shape contains the specified point.
This method checks the point against the shape 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.
| aPoint | The point to test against the shape, specified in the shape object's coordinate system. |
true if the shape's enclosed area contains the specified point; otherwise, false.Appends the contents of the specified shape object to the shape.
This method adds the commands used to create aShape to the end of the receiver's shape.
| aShape | The shape to add to the receiver. |
Appends the contents of the specified shape object to the shape.
This method adds the commands used to create aShape to the end of the receiver's shape.
| aShape | The shape to add to the receiver. |
Appends the contents of the specified shape object to the shape.
This method adds the commands used to create aShape to the end of the receiver's shape.
| aShape | The shape to add to the receiver. |
Appends the contents of the specified shape object to the shape.
This method adds the commands used to create aShape to the end of the receiver's shape.
| aShape | The shape to add to the receiver. |
Returns the type of shape element at the specified index.
Path elements describe the commands used to draw a path and include basic commands such as filling and stroking. The elements are stored in the order of their execution.
| index | The index of the desired shape element. |
Element structure. | void CeresEngine::Shape::reverse | ( | ) |
Computes a shape containing the reversed contents of the current shape path objects.
The reversed shape 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 shape is created by reversing each whole or partial subpath in the path object individually.
|
inline |
Computes a shape containing the reversed contents of the current shape path objects.
The reversed shape 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 shape is created by reversing each whole or partial subpath in the path object individually.
| Shape CeresEngine::Shape::reversed | ( | ) | const & |
Computes a shape containing the reversed contents of the current shape path objects.
The reversed shape 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 shape is created by reversing each whole or partial subpath in the path object individually.
| void CeresEngine::Shape::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.
The drawn line is centered on the path with its sides parallel to the path segment. This method uses the current drawing attributes associated with the receiver. If a particular attribute is not set for the receiver, this method uses the corresponding default attribute.
| path | The path to be stroked. |
| paint | The paint to stroke the path with. |
| void CeresEngine::Shape::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.
The drawn line is centered on the path with its sides parallel to the path segment. This method uses the current drawing attributes associated with the receiver. If a particular attribute is not set for the receiver, this method uses the corresponding default attribute.
| path | The path to be stroked. |
| paint | The paint to stroke the path with. |
Transforms all points in the shape using the specified transform.
This method applies the transform to the shape path's points immediately.
| aTransform | The transform to apply to the shape. |
Transforms all points in the shape using the specified transform.
This method applies the transform to the shape path's points immediately.
| aTransform | The transform to apply to the shape. |
Transforms all points in the shape using the specified transform.
This method applies the transform to the shape path's points immediately.
| aTransform | The transform to apply to the shape. |
|
private |
A vector of all elements in the shape.
|
private |
A vector that stores a unique copy of each path.