49 void curveTo(
float x1,
float y1,
float x2,
float y2,
float x3,
float y3 ) {
curveTo(
Vec2f( x1, y1 ),
Vec2f( x2, y2 ),
Vec2f( x3, y3 ) ); }
50 void arc(
const Vec2f ¢er,
float radius,
float startRadians,
float endRadians,
bool forward =
true );
51 void arc(
float centerX,
float centerY,
float radius,
float startRadians,
float endRadians,
bool forward =
true ) {
arc(
Vec2f( centerX, centerY ), radius, startRadians, endRadians, forward ); }
53 void arcTo(
float x,
float y,
float tanX,
float tanY,
float radius) {
arcTo(
Vec2f( x, y ),
Vec2f( tanX, tanY ), radius ); }
57 bool isClosed()
const {
return ( mSegments.size() > 1 ) && mSegments.back() ==
CLOSE; }
62 bool empty()
const {
return mPoints.empty(); }
63 void clear() { mSegments.clear(); mPoints.clear(); }
79 std::vector<Vec2f>
subdivide(
float approximationScale = 1.0
f )
const;
89 const std::vector<Vec2f>&
getPoints()
const {
return mPoints; }
100 const std::vector<SegmentType>&
getSegments()
const {
return mSegments; }
119 float calcNormalizedTime(
float relativeTime,
bool wrap =
true,
float tolerance = 1.0e-03
f,
int maxIterations = 16 )
const;
121 float calcTimeForDistance(
float distance,
bool wrap =
true,
float tolerance = 1.0e-03
f,
int maxIterations = 16 )
const;
132 float segmentSolveTimeForDistance(
size_t segment,
float segmentLength,
float segmentRelativeDistance,
float tolerance,
int maxIterations )
const;
139 void arcHelper(
const Vec2f ¢er,
float radius,
float startRadians,
float endRadians,
bool forward );
140 void arcSegmentAsCubicBezier(
const Vec2f ¢er,
float radius,
float startRadians,
float endRadians );
141 void subdivideQuadratic(
float distanceToleranceSqr,
const Vec2f &p1,
const Vec2f &p2,
const Vec2f &p3,
int level, std::vector<Vec2f> *result )
const;
142 void subdivideCubic(
float distanceToleranceSqr,
const Vec2f &p1,
const Vec2f &p2,
const Vec2f &p3,
const Vec2f &p4,
int level, std::vector<Vec2f> *result )
const;
144 std::vector<Vec2f> mPoints;
145 std::vector<SegmentType> mSegments;
150 if( p.mPoints.empty() )
153 out <<
"M " << p.mPoints[0].x <<
" " << p.mPoints[0].y <<
" ";
156 for(
size_t s = 0;
s < p.mSegments.size(); ++
s ) {
158 out <<
"L " << p.mPoints[pt].x <<
" " << p.mPoints[pt].y <<
" ";
162 out <<
"Q " << p.mPoints[pt].x <<
" " << p.mPoints[pt].y <<
" " << p.mPoints[pt+1].x <<
" " << p.mPoints[pt+1].y <<
" ";
166 out <<
"C " << p.mPoints[pt].x <<
" " << p.mPoints[pt].y <<
" " << p.mPoints[pt+1].x <<
" " << p.mPoints[pt+1].y <<
" " << p.mPoints[pt+2].x <<
" " << p.mPoints[pt+2].y <<
" ";
187 float calcNormalizedTime(
float relativeTime,
bool wrap =
true,
float tolerance = 1.0e-03
f,
int maxIterations = 16 )
const;
189 float calcTimeForDistance(
float distance,
bool wrap =
true,
float tolerance = 1.0e-03
f,
int maxIterations = 16 )
const;
196 std::vector<float> mSegmentLengths;
void lineTo(float x, float y)
Definition: Path2d.h:45
std::vector< Vec2f > subdivide(float approximationScale=1.0f) const
Definition: Path2d.cpp:468
GLuint GLenum matrix
Definition: GLee.h:10032
Path2d()
Definition: Path2d.h:37
void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
Definition: Path2d.h:49
static int calcQuadraticBezierMonotoneRegions(const Vec2f p[3], float resultT[2])
Definition: Path2d.cpp:694
GLenum GLint GLint y
Definition: GLee.h:987
GLint level
Definition: GLee.h:1161
float calcTimeForDistance(float distance, bool wrap=true, float tolerance=1.0e-03f, int maxIterations=16) const
Calculates a t-value corresponding to arc length distance. If wrap then the t-value loops inside the ...
Definition: Path2d.cpp:1133
bool empty() const
Definition: Path2d.h:62
Vec2< float > Vec2f
Definition: Vector.h:1314
void getSegmentRelativeT(float t, size_t *segment, float *relativeT) const
Stores into segment the segment # associated with t, and if relativeT is not NULL, the t relative to its segment, in the range [0,1]
Definition: Path2d.cpp:362
void arcTo(const Vec2f &p, const Vec2f &t, float radius)
Definition: Path2d.cpp:254
float getLength() const
Definition: Path2d.h:184
const Vec2f & getPoint(size_t point) const
Definition: Path2d.h:91
bool contains(const Vec2f &pt) const
Returns whether the point pt is contained within the boundaries of the path.
Definition: Path2d.cpp:906
float calcLength() const
Calculates the length of the Path2d.
Definition: Path2d.cpp:941
void arc(const Vec2f ¢er, float radius, float startRadians, float endRadians, bool forward=true)
Definition: Path2d.cpp:178
std::vector< SegmentType > & getSegments()
Definition: Path2d.h:101
Rectf calcBoundingBox() const
Returns the bounding box around all control points. As with Shape2d, note this is not necessarily the...
Definition: Path2d.cpp:681
static Vec2< float > zero()
Definition: Vector.h:295
GLuint index
Definition: GLee.h:2259
void clear()
Definition: Path2d.h:63
const Path2d & getPath2d() const
Definition: Path2d.h:183
static int calcCubicBezierMonotoneRegions(const Vec2f p[4], float resultT[4])
Definition: Path2d.cpp:726
const std::vector< Vec2f > & getPoints() const
Definition: Path2d.h:89
std::vector< Vec2f > & getPoints()
Definition: Path2d.h:90
static Vec2f calcCubicBezierPos(const Vec2f p[4], float t)
Definition: Path2d.cpp:756
const Vec2f & getCurrentPoint() const
Definition: Path2d.h:93
static Vec2f calcQuadraticBezierDerivative(const Vec2f p[3], float t)
Definition: Path2d.cpp:719
void setPoint(size_t index, const Vec2f &p)
Definition: Path2d.h:94
Vec2f getTangent(float t) const
Returns the tangent on the curve at parameter t, which lies in the range [0,1]
Definition: Path2d.cpp:398
float calcSegmentLength(size_t segment, float minT=0, float maxT=1) const
Calculates the length of a specific segment in the range [minT,maxT], where minT and maxT range from ...
Definition: Path2d.cpp:970
Vec2f getPosition(float t) const
Returns the point on the curve at parameter t, which lies in the range [0,1]
Definition: Path2d.h:191
Vec2f getSegmentTangent(size_t segment, float t) const
Returns the point in segment # segment in the range [0,getNumSegments()) at parameter t in the range ...
Definition: Path2d.cpp:440
Vec2f getPosition(float t) const
Returns the point on the curve at parameter t, which lies in the range [0,1]
Definition: Path2d.cpp:390
Accelerates the calculation of various operations on Path2d. Useful if doing repeated calculations...
Definition: Path2d.h:179
Path2dCalcCache(const Path2d &path)
Definition: Path2d.cpp:1093
Rectf calcPreciseBoundingBox() const
Returns the precise bounding box around the curve itself. Slower to calculate than calcBoundingBox()...
Definition: Path2d.cpp:777
static Vec2f calcCubicBezierDerivative(const Vec2f p[4], float t)
Definition: Path2d.cpp:766
GLenum GLint x
Definition: GLee.h:987
Path2d transformCopy(const MatrixAffine2f &matrix) const
Returns a copy transformed by matrix.
Definition: Path2d.cpp:673
void arc(float centerX, float centerY, float radius, float startRadians, float endRadians, bool forward=true)
Definition: Path2d.h:51
void arcTo(float x, float y, float tanX, float tanY, float radius)
Definition: Path2d.h:53
void transform(const MatrixAffine2f &matrix)
Transforms the Path2d by matrix.
Definition: Path2d.cpp:667
Definition: BSpline.h:103
GLfloat GLfloat p
Definition: GLee.h:8473
Vec2f & getPoint(size_t point)
Definition: Path2d.h:92
bool isClosed() const
Definition: Path2d.h:57
std::ostream & operator<<(std::ostream &lhs, const ColorT< float > &rhs)
Definition: Color.cpp:203
void moveTo(float x, float y)
Sets the start point of the path to (x, y ). This is the only legal first command, and only legal as the first command.
Definition: Path2d.h:43
SegmentType getSegmentType(size_t segment) const
Definition: Path2d.h:98
void quadTo(const Vec2f &p1, const Vec2f &p2)
Definition: Path2d.cpp:157
float calcNormalizedTime(float relativeTime, bool wrap=true, float tolerance=1.0e-03f, int maxIterations=16) const
Calculates the t-value corresponding to relativeTime in the range [0,1) within epsilon of tolerance...
Definition: Path2d.cpp:1100
static Vec2f calcQuadraticBezierPos(const Vec2f p[3], float t)
Definition: Path2d.cpp:713
void reverse()
Reverses the order of the path's points, inverting its winding order.
Definition: Path2d.cpp:327
void close()
Closes the path, by drawing a straight line from the first to the last point. This is only legal as t...
Definition: Path2d.h:56
void quadTo(float x1, float y1, float x2, float y2)
Definition: Path2d.h:47
Definition: Exception.h:32
size_t getNumPoints() const
Definition: Path2d.h:65
void removeSegment(size_t segment)
Definition: Path2d.cpp:350
void moveTo(const Vec2f &p)
Sets the start point of the path to p. This is the only legal first command, and only legal as the fi...
Definition: Path2d.cpp:140
void scale(const Vec2f &amount, Vec2f scaleCenter=Vec2f::zero())
Scales the Path2d by amount.x on X and amount.y on Y around the center scaleCenter.
Definition: Path2d.cpp:661
void curveTo(const Vec2f &p1, const Vec2f &p2, const Vec2f &p3)
Definition: Path2d.cpp:167
Vec2f getSegmentPosition(size_t segment, float t) const
Returns the point in segment # segment in the range [0,getNumSegments()) at parameter t in the range ...
Definition: Path2d.cpp:406
float calcNormalizedTime(float relativeTime, bool wrap=true, float tolerance=1.0e-03f, int maxIterations=16) const
Calculates the t value corresponding to relativeTime in the range [0,1) within epsilon of tolerance...
Definition: Path2d.cpp:997
void lineTo(const Vec2f &p)
Definition: Path2d.cpp:148
GLdouble GLdouble t
Definition: GLee.h:1426
GLdouble s
Definition: GLee.h:1378
size_t getNumSegments() const
Definition: Path2d.h:64
GLclampf f
Definition: GLee.h:15307
friend std::ostream & operator<<(std::ostream &out, const Path2d &p)
Definition: Path2d.h:148
const std::vector< SegmentType > & getSegments() const
Definition: Path2d.h:100
static const int sSegmentTypePointCounts[]
Definition: Path2d.h:97
SegmentType
Definition: Path2d.h:96
float calcTimeForDistance(float distance, bool wrap=true, float tolerance=1.0e-03f, int maxIterations=16) const
Calculates a t-value corresponding to arc length distance. If wrap then the t-value loops inside the ...
Definition: Path2d.cpp:1028
float segmentSolveTimeForDistance(size_t segment, float segmentLength, float segmentRelativeDistance, float tolerance, int maxIterations) const
Solves the time corresponding to segmentRelativeDistance (a measure of arc length). Generally you should use calcNormalizedTime() or calcTimeForDistance() instead.
Definition: Path2d.cpp:1052