Hot Door CORE 0.8.2
Adobe® Illustrator® Plug-in Library
|
Allows for path manipulation, metadata access, trimming, extending, etc. More...
#include <hdicorePathArt.h>
Public Types | |
enum | WindingOrderType { WindingUnknown = 0 , Clockwise = 1 , CounterClockwise = 2 } |
Describes which direction the (closed) art is wound. | |
enum | SegPointSelectionState { SegPointNotSelected = 0 , SegPointAnchorSelected = 1 << 0 , SegPointInSelected = 1 << 1 , SegPointOutSelected = 1 << 2 , SegPointAllSelected = (SegPointAnchorSelected | SegPointInSelected | SegPointOutSelected) } |
Describes how an individual segment point is selected, if at all. More... | |
enum | TrimDirectionType { TrimGreaterDirectionOnly = 1 << 0 , TrimLesserDirectionOnly = 1 << 1 , TrimBothDirections = (TrimGreaterDirectionOnly | TrimLesserDirectionOnly) } |
Describes which direction a trim should take place (to the greater, lesser, or both sides of a given reference point) | |
enum | TrimError { NoTrimError = 0 , HitDataArtMustMatchTrimPathArtError = 10 , TrimPathIsClosedError = 20 , TrimPathNeedsAtLeast2PointsError = 30 , InvalidSourcePathForTrimming = 40 } |
Describes various errors that can occur when trimming a path. | |
enum | ExtendError { NoExtendError = 0 , HitDataArtMustMatchExtendPathArtError = 110 , NoExtendIntersectionsFoundError = 120 , ExtendPathEndSegmentsOnlyError = 130 , ExtendPathIsClosedError = 140 , ExtendPathNeedsAtLeast2PointsError = 150 , InvalidSourcePathForExtending = 160 } |
Describes various errors that can occur when trimming a path. | |
enum | StrokeAlignment { UnknownStrokeAlignment = 0 , CenterStrokeAlignment = 10 , InsideStrokeAlignment = 20 , OutsideStrokeAlignment = 30 } |
Describes how a path's stroke should be aligned. | |
typedef std::vector< ArtboardSegPoint > | ArtboardSegPointVector |
typedef std::vector< std::shared_ptr< HitData > > | HitDataVector |
Public Member Functions | |
~PathArt () | |
Destructs a PathArt object. | |
bool | isGuide () const |
Gets whether the path is a guide. | |
bool | closed () const |
Gets whether the target path is closed. | |
void | setClosed (const bool closed_) |
Sets whether the target path is closed. | |
PathStyle | style () const |
Gets the target path's style. | |
void | setStyle (const PathStyle &style_) |
Sets the target path's style. | |
int16_t | segCount () const |
Gets the count of segments in the path, taking into account phantom segments of closed paths. | |
int16_t | segPointCount () const |
Gets the count of individual segment points in the path. | |
void | setSegCount (const int16_t count_) |
Sets the count of segments in the path. | |
void | setSegPointCount (const int16_t count_) |
Sets the count of individual segment points in the path. | |
std::unique_ptr< hdi::core::Bezier > | bezier (const int16_t segIndex_) const |
Gets a Bezier object for a given segment index. | |
ArtboardPoint | midPoint () const |
Gets the midpoint along a path. | |
void | endPoints (ArtboardPoint &start__, ArtboardPoint &end__) const |
Gets the end points of a path. | |
bool | hasLength () const |
Gets whether the path has any length. | |
double | length () const |
Gets the total length of the path. | |
double | sublength (const int16_t startSegPt_, const int16_t endSegPt_) const |
Gets the length of a subpath from one segment point to another. | |
double | sublength (const int16_t startSeg_, const double startT_, const int16_t endSeg_, const double endT_) const |
Gets the length of a subpath, from segment point at a t-value to another. | |
double | tAtLength (const int16_t segNum_, const double length_) const |
Gets the t-value at a given length of a given path segment. | |
double | area () const |
Gets the area of the path. | |
bool | hasStraightSegs () const |
Gets whether each individual path segment is straight. | |
bool | isStraight () const |
Gets whether the entire path forms a perfectly straight line. | |
bool | isRectangular () const |
Gets whether the entire path forms a rectangular shape. | |
bool | isCircular () const |
Gets whether the entire path forms a circle. | |
bool | isEllipse () const |
Gets whether the entire path forms an ellipse. | |
ArtboardPoint | centroid () const |
Calculates the centroid of the path. | |
bool | angle (Angle &angle__) const |
Gets the angle of the path relative to the x-axis, if the path is a perfectly straight line. | |
ArtboardSegPointVector | segs (const int16_t segIndex_, const int16_t count_) const |
Gets a series of points describing the requested path segments. | |
ArtboardSegPointVector | segPoints (const int16_t segPtIndex_, const int16_t count_) const |
Gets a series of path segment points. | |
ArtboardSegPointVector | phantomSeg () const |
Gets two segment points describing the phantom segment of a path. | |
ArtboardSegPointVector | phantomSegPoints () const |
Gets the two phantom segment points. | |
void | setSegs (const int16_t segIndex_, const ArtboardSegPointVector &segPts_) |
Sets a series of segments in the path to new values. | |
void | setSegPoints (const int16_t segPtIndex_, const ArtboardSegPointVector &segPts_) |
Sets a series of segment points in the path to new values. | |
bool | allSegPointsSelected () const |
Gets whether all the segments points of a path are selected. | |
bool | segSelected (const int16_t segIndex_) const |
Gets whether a given segment is selected. | |
SegPointSelectionState | segPointSelected (const int16_t segPtIndex_) const |
Gets the selection state of a given segment point. | |
bool | setSegPointSelected (const int16_t segPtIndex_, const SegPointSelectionState selected_) |
Sets the selection state of a given segment point. | |
void | insertSegs (const int16_t segIndex_, const ArtboardSegPointVector &segPts_) |
Inserts new segments into the target path at a given segment index. | |
void | insertSegPoints (const int16_t segPtIndex_, const ArtboardSegPointVector &segPts_) |
Inserts new segment points into the target path after a given segment point index. | |
void | deleteSegs (const int16_t segIndex_, const int16_t count_) |
Deletes a given number of segments from a given segment index forward. | |
void | deleteSegPoints (const int16_t segPtIndex_, const int16_t count_) |
Deletes a given number of segment points from a given segment point index forward. | |
void | rotateSegPoints (const int16_t delta_) |
Rotates segment point indices by a given delta, while keeping the points at the same location in space. | |
void | reverseSegs () |
Reverses the winding order of the segment points in the path. | |
WindingOrderType | windingOrder () const |
Gets the winding order of the path. | |
void | setWindingOrder (const WindingOrderType winding_) |
Sets the winding order of the path. | |
void | setStrokeAlignment (const StrokeAlignment align_) |
Sets the stroke alignment for the target path. | |
void | insertSegPointAtT (const int16_t segIndex_, const double t_) |
"Safely" inserts a new segment point in a given segment | |
int16_t | segPointClosestToPoint (const ArtboardPoint &pt_) const |
Gets the index of the segment point that is closest to a given point in space. | |
bool | containsPoint (const ArtboardPoint &pt_) const |
Gets whether a given point is contained inside the path. | |
bool | simplify (const double flatness_) |
Attempts to reduce the number of segment points in the path by converting them to a series of points and then re-fitting curves to the points. Any corner segments are preserved. | |
HitDataVector | getIntersections (const int16_t max_=0, const bool guides_=false) const |
Gets all path segment intersections along the target path. | |
HitDataVector | getIntersections (const Art &target_, const int16_t max_=0, const bool guides_=false) const |
Gets path segment intersections along the target path. | |
TrimError | trim (const HitData ¢er_, const bool delete_, const TrimDirectionType dir_, const bool guides_, Art &split__) |
Trims a path around a given "center" point, either to one or both sides. | |
ExtendError | extend (const HitData &from_, const HitData &to_, const bool guides_) |
Extends a path from a given "point" to another "point". | |
Static Public Attributes | |
static const int16_t | maxSegments = 32000 |
Maximum number of segments allowed in a path. | |
Friends | |
class | Art |
Allows for path manipulation, metadata access, trimming, extending, etc.
Describes how an individual segment point is selected, if at all.
hdi::core::PathArt::~PathArt | ( | ) |
Destructs a PathArt object.
bool hdi::core::PathArt::allSegPointsSelected | ( | ) | const |
Gets whether all the segments points of a path are selected.
bool hdi::core::PathArt::angle | ( | Angle & | angle__ | ) | const |
Gets the angle of the path relative to the x-axis, if the path is a perfectly straight line.
angle__ | Return-by-reference for the angle of the path |
double hdi::core::PathArt::area | ( | ) | const |
Gets the area of the path.
std::unique_ptr< hdi::core::Bezier > hdi::core::PathArt::bezier | ( | const int16_t | segIndex_ | ) | const |
ArtboardPoint hdi::core::PathArt::centroid | ( | ) | const |
Calculates the centroid of the path.
bool hdi::core::PathArt::closed | ( | ) | const |
Gets whether the target path is closed.
bool hdi::core::PathArt::containsPoint | ( | const ArtboardPoint & | pt_ | ) | const |
Gets whether a given point is contained inside the path.
pt_ | The point in question |
void hdi::core::PathArt::deleteSegPoints | ( | const int16_t | segPtIndex_, |
const int16_t | count_ | ||
) |
Deletes a given number of segment points from a given segment point index forward.
segPtIndex_ | Index number of the first segment point to delete |
count_ | Number of segment points to delete from segIndex_ forward (inclusive) |
void hdi::core::PathArt::deleteSegs | ( | const int16_t | segIndex_, |
const int16_t | count_ | ||
) |
Deletes a given number of segments from a given segment index forward.
segIndex_ | Index number of the first segment to delete |
count_ | Number of segments to delete from segIndex_ forward (inclusive) |
void hdi::core::PathArt::endPoints | ( | ArtboardPoint & | start__, |
ArtboardPoint & | end__ | ||
) | const |
Gets the end points of a path.
start__ | Return-by-reference for the start point (i.e. segment index 0, t-value 0.0) |
end__ | Return-by-reference for the end point (i.e. segment index n-1, t-value 1.0) |
ExtendError hdi::core::PathArt::extend | ( | const HitData & | from_, |
const HitData & | to_, | ||
const bool | guides_ | ||
) |
Extends a path from a given "point" to another "point".
from_ | HitData object describing the point from which the extension should take place |
to_ | HitData object describing the path and segment to which the target should be extended |
guides_ | Whether guides should be included when extending |
HitDataVector hdi::core::PathArt::getIntersections | ( | const Art & | target_, |
const int16_t | max_ = 0 , |
||
const bool | guides_ = false |
||
) | const |
Gets path segment intersections along the target path.
This method only gets intersections between a path and a provided target piece of art
target_ | Piece of art to check against for intersections with the target path |
max_ | If desired, limits the max count of intersections, in whichever order they are found first; pass 0 for "unlimited" |
guides_ | Whether guides should be included in the search |
HitDataVector hdi::core::PathArt::getIntersections | ( | const int16_t | max_ = 0 , |
const bool | guides_ = false |
||
) | const |
Gets all path segment intersections along the target path.
max_ | If desired, limits the max count of intersections, in whichever order they are found first; pass 0 for "unlimited" |
guides_ | Whether guides should be included in the search |
bool hdi::core::PathArt::hasLength | ( | ) | const |
Gets whether the path has any length.
bool hdi::core::PathArt::hasStraightSegs | ( | ) | const |
Gets whether each individual path segment is straight.
void hdi::core::PathArt::insertSegPointAtT | ( | const int16_t | segIndex_, |
const double | t_ | ||
) |
"Safely" inserts a new segment point in a given segment
segIndex_ | Index number of the segment in which the new point will be added |
t_ | T-value along the given path segment at which the new point will be added |
void hdi::core::PathArt::insertSegPoints | ( | const int16_t | segPtIndex_, |
const ArtboardSegPointVector & | segPts_ | ||
) |
Inserts new segment points into the target path after a given segment point index.
segPtIndex_ | Segment point index, after which the new seg points will be inserted |
segPts_ | Vector of new segment points |
void hdi::core::PathArt::insertSegs | ( | const int16_t | segIndex_, |
const ArtboardSegPointVector & | segPts_ | ||
) |
Inserts new segments into the target path at a given segment index.
segIndex_ | Segment index, in which the new segs will start |
segPts_ | Vector of new segment points describing the segments |
bool hdi::core::PathArt::isCircular | ( | ) | const |
Gets whether the entire path forms a circle.
bool hdi::core::PathArt::isEllipse | ( | ) | const |
Gets whether the entire path forms an ellipse.
bool hdi::core::PathArt::isGuide | ( | ) | const |
Gets whether the path is a guide.
bool hdi::core::PathArt::isRectangular | ( | ) | const |
Gets whether the entire path forms a rectangular shape.
bool hdi::core::PathArt::isStraight | ( | ) | const |
Gets whether the entire path forms a perfectly straight line.
double hdi::core::PathArt::length | ( | ) | const |
Gets the total length of the path.
ArtboardPoint hdi::core::PathArt::midPoint | ( | ) | const |
Gets the midpoint along a path.
ArtboardSegPointVector hdi::core::PathArt::phantomSeg | ( | ) | const |
Gets two segment points describing the phantom segment of a path.
ArtboardSegPointVector hdi::core::PathArt::phantomSegPoints | ( | ) | const |
Gets the two phantom segment points.
void hdi::core::PathArt::reverseSegs | ( | ) |
Reverses the winding order of the segment points in the path.
void hdi::core::PathArt::rotateSegPoints | ( | const int16_t | delta_ | ) |
Rotates segment point indices by a given delta, while keeping the points at the same location in space.
delta_ | The number of positions to move each segment point |
int16_t hdi::core::PathArt::segCount | ( | ) | const |
Gets the count of segments in the path, taking into account phantom segments of closed paths.
int16_t hdi::core::PathArt::segPointClosestToPoint | ( | const ArtboardPoint & | pt_ | ) | const |
Gets the index of the segment point that is closest to a given point in space.
pt_ | The point in question |
int16_t hdi::core::PathArt::segPointCount | ( | ) | const |
Gets the count of individual segment points in the path.
ArtboardSegPointVector hdi::core::PathArt::segPoints | ( | const int16_t | segPtIndex_, |
const int16_t | count_ | ||
) | const |
Gets a series of path segment points.
segPtIndex_ | Index number of the first segment point in question |
count_ | Number of segment points requested from segIndex_ forward (inclusive) |
SegPointSelectionState hdi::core::PathArt::segPointSelected | ( | const int16_t | segPtIndex_ | ) | const |
Gets the selection state of a given segment point.
segPtIndex_ | Index number of the segment point in question |
ArtboardSegPointVector hdi::core::PathArt::segs | ( | const int16_t | segIndex_, |
const int16_t | count_ | ||
) | const |
Gets a series of points describing the requested path segments.
segIndex_ | Index number of the first segment in question |
count_ | Number of segments requested from segIndex_ forward (inclusive) |
bool hdi::core::PathArt::segSelected | ( | const int16_t | segIndex_ | ) | const |
Gets whether a given segment is selected.
segIndex_ | Index number of the segment in question |
void hdi::core::PathArt::setClosed | ( | const bool | closed_ | ) |
Sets whether the target path is closed.
closed_ | true to close the path, false to open it |
void hdi::core::PathArt::setSegCount | ( | const int16_t | count_ | ) |
Sets the count of segments in the path.
count_ | New segment count |
void hdi::core::PathArt::setSegPointCount | ( | const int16_t | count_ | ) |
Sets the count of individual segment points in the path.
count_ | New segment point count |
void hdi::core::PathArt::setSegPoints | ( | const int16_t | segPtIndex_, |
const ArtboardSegPointVector & | segPts_ | ||
) |
Sets a series of segment points in the path to new values.
segPtIndex_ | Index number of the first segment point to set |
segPts_ | Vector of new segment points |
bool hdi::core::PathArt::setSegPointSelected | ( | const int16_t | segPtIndex_, |
const SegPointSelectionState | selected_ | ||
) |
Sets the selection state of a given segment point.
segPtIndex_ | Index number of the segment point in question |
selected_ | New segment point selection state enum value |
void hdi::core::PathArt::setSegs | ( | const int16_t | segIndex_, |
const ArtboardSegPointVector & | segPts_ | ||
) |
Sets a series of segments in the path to new values.
segIndex_ | Index number of the first segment to set |
segPts_ | Vector of new segment points describing the segments |
void hdi::core::PathArt::setStrokeAlignment | ( | const StrokeAlignment | align_ | ) |
Sets the stroke alignment for the target path.
align_ | New stroke alignment setting |
void hdi::core::PathArt::setStyle | ( | const PathStyle & | style_ | ) |
Sets the target path's style.
style_ | New path styling info |
void hdi::core::PathArt::setWindingOrder | ( | const WindingOrderType | winding_ | ) |
Sets the winding order of the path.
winding_ | New path winding order |
bool hdi::core::PathArt::simplify | ( | const double | flatness_ | ) |
Attempts to reduce the number of segment points in the path by converting them to a series of points and then re-fitting curves to the points. Any corner segments are preserved.
flatness_ | An upper bound on the error between the line segments and the true curve |
PathStyle hdi::core::PathArt::style | ( | ) | const |
Gets the target path's style.
double hdi::core::PathArt::sublength | ( | const int16_t | startSeg_, |
const double | startT_, | ||
const int16_t | endSeg_, | ||
const double | endT_ | ||
) | const |
Gets the length of a subpath, from segment point at a t-value to another.
startSeg_ | Starting segment point number for calculating path length |
startT_ | T-value along startSeg_ seg to begin the calculation |
endSeg_ | Ending segment point number for calculating path length |
endT_ | T-value along endSeg_ seg to end the calculation |
double hdi::core::PathArt::sublength | ( | const int16_t | startSegPt_, |
const int16_t | endSegPt_ | ||
) | const |
Gets the length of a subpath from one segment point to another.
startSegPt_ | Starting segment point number for calculating path length |
endSegPt_ | Ending segment point number for calculating path length |
double hdi::core::PathArt::tAtLength | ( | const int16_t | segNum_, |
const double | length_ | ||
) | const |
Gets the t-value at a given length of a given path segment.
segNum_ | Segment number in which the given sublength resides |
length_ | Length within the given segment number for which a t-value is desired |
TrimError hdi::core::PathArt::trim | ( | const HitData & | center_, |
const bool | delete_, | ||
const TrimDirectionType | dir_, | ||
const bool | guides_, | ||
Art & | split__ | ||
) |
Trims a path around a given "center" point, either to one or both sides.
center_ | HitData object describing the "center" from which the trims will take place |
delete_ | Whether portion(s) of the path beyond the intersection(s) should be deleted |
dir_ | Which direction the trim(s) should take place |
guides_ | Whether guides should be taken into account for trimming |
split__ | Return-by-reference for the second piece of path art, if necessary |
WindingOrderType hdi::core::PathArt::windingOrder | ( | ) | const |
Gets the winding order of the path.