path2d.c File Reference


Detailed Description

This file is in the public domain.

Definition in file path2d.c.

#include "path2d.h"

Go to the source code of this file.

Data Structures

struct  SEGITERATOR
struct  RECTITERATOR
struct  ELLIPSEITERATOR
struct  RRITERATOR
struct  PATHSEGITERATOR
struct  CURVEFLATSTATUS
struct  CURVEFLATTENER
struct  FLATPATHINTERNAL

Defines

#define PCV   0.77614237491539666
#define NCV   0.22385762508460333
#define NCV   0.22385762508460333
#define HORNERQUAD(x, a, b, c)   ( (a) + (x) * ( (b) + (x) * (c) ))
#define HORNERCUBIC(x, a, b, c, d)   ( (a) + (x) * ( (b) + (x) * ( (c) + (x) * (d) ) ))

Enumerations

enum  ArcInternalFlags { ArcCheckEndPoint = 1, ArcDrawLine = 2, ArcMoveTo = 4, ArcHaveEndCoords = 8 }
enum  CLOSEDPATHFLAGS { PathNewMoveTo = 0x01, PathEndOfPath = 0x02, PathMask = 0x07, PathHaveLineTo = 0x08 }

Functions

BOOL RectContainsPoint (RECTDBL *rc, double x, double y)
BOOL RectIntersectsRect (RECTDBL *rc, double x, double y, double x1, double y1)
BOOL RectContainsRect (RECTDBL *rc, double x, double y, double x1, double y1)
BOOL ViewSpaceCalcTransformEx (MATRIX *xfmDst, RECTDBL *rcViewport, RECTDBL *rcWindow, int align, int meetOrSlice)
 Calculates a transform matrix where units from one coordinate system are mapped to units in another coordinate system.
double CubeRoot (double x)
double PointDistance (double x1, double y1, double x2, double y2)
double SegmentDistanceSq (double x0, double y0, double x1, double y1, double ptx, double pty)
double QuadFlatnessSq (double *c)
double CubicFlatnessSq (double *c)
void CubicCurveFromQuadratic (double *pSrc, double *pDst)
 Converts a quadratic curve into a cubic curve.
double PerpendicularDistance (double x0, double y0, double x1, double y1, double ptx, double pty)
void LineSubdivide (double *src, double *left, double *right, double t)
 Subdivides a line into two lines, at the parameter value _t_.
void QuadSubdivide (double *src, double *left, double *right, double t)
 Subdivides a quadratic curve into two curves, at the parameter value _t_.
void CubicSubdivide (double *src, double *left, double *right, double t)
 Subdivides a cubic curve into two curves, at the parameter value _t_.
double * PathSegmentEndPoint (PATHSEGMENT *ps)
 Returns a pointer to the end point of the path segment _ps_, or NULL if the path segment has no end point.
BOOL PathMoveTo (ITEMARRAY *ia, double x, double y)
 Adds a "move to" command to the path.
BOOL PathAddPoint (ITEMARRAY *ia, double x, double y)
 Adds a "move to" command to the path, but only if its end point is different from the new position.
BOOL PathLineTo (ITEMARRAY *ia, double x, double y)
 Draws a line from the current position to a new one, starting at the path's current end point.
BOOL PathQuadTo (ITEMARRAY *ia, double x, double y, double x1, double y1)
 Adds a quadratic Bezier curve to the path, starting at the path's current end point.
BOOL PathCubicTo (ITEMARRAY *ia, double x, double y, double x1, double y1, double x2, double y2)
 Adds a cubic Bezier curve to the path, starting at the path's current end point.
BOOL PathSmoothQuadTo (ITEMARRAY *ia, double x, double y)
 Adds a quadratic Bezier curve to the path, starting at the path's current end point.
BOOL PathSmoothCubicTo (ITEMARRAY *ia, double x1, double y1, double x2, double y2)
 Adds a cubic Bezier curve to the path, starting at the path's current end point.
BOOL PathClose (ITEMARRAY *ia)
 Adds a "close path" command, where a straight line is drawn from the current position to the starting point.
BOOL PathAddSegment (ITEMARRAY *ia, PATHSEGMENT *ps)
 Adds a path segment to the path.
BOOL PathAppendPath (ITEMARRAY *ia, PATHITERATOR *pcb, LPVOID data, MATRIX *xfm, BOOL connect)
 Appends another path, in the form of a path iterator, to this path.
void DebugOutFullPathSegment (FULLPATHSEGMENT *ps, LPCTSTR add)
void DebugOutPathSegment (PATHSEGMENT *ps, LPCTSTR add)
 Displays output about a path segment to the debugger.
void DebugOutPathSegmentAsSvg (PATHSEGMENT *ps)
 Displays output about a path segment in SVG format to the debugger.
BOOL PathGetEndPoint (ITEMARRAY *ia, double *endpt)
 Finds the path's current end point.
void PathCardinalSplineTo (ITEMARRAY *path, double *coords, LONG numpoints, double tension)
 Adds a cardinal spline to the path, starting with the path's current point.
void PathAddCardinalSpline (ITEMARRAY *path, double *coords, LONG numpoints, double tension, BOOL closefigure)
 Adds a cardinal spline to the path.
BOOL PathTransform (ITEMARRAY *path, MATRIX *xfm)
 Applies an affine transform to the path.
BOOL PathSegmentTransform (PATHSEGMENT *ps, MATRIX *xfm)
 Applies a transform matrix to a path segment.
static int SegIterator_GetWinding (LPVOID h)
static LPVOID SegIterator_Init (double *data, DWORD numpoints)
static void SegIterator_Free (LPVOID h)
static LPVOID LineIterator_Init (double *data)
static int LineIterator_Next (LPVOID h, PATHSEGMENT *ps)
static LPVOID QuadIterator_Init (double *data)
static int QuadIterator_Next (LPVOID h, PATHSEGMENT *ps)
static LPVOID CubicIterator_Init (double *data)
static int CubicIterator_Next (LPVOID h, PATHSEGMENT *ps)
static int RectPath_GetWinding (LPVOID h)
static LPVOID RectPath_Init (LPVOID data)
static void RectPath_Free (LPVOID h)
static int RectPath_Next (LPVOID h, PATHSEGMENT *ps)
static int EllipsePath_GetWinding (LPVOID h)
static LPVOID EllipsePath_Init (LPVOID data)
static void EllipsePath_Free (LPVOID h)
static int EllipsePath_Next (LPVOID handle, PATHSEGMENT *ps)
static int RoundRectPath_GetWinding (LPVOID h)
static LPVOID RoundRectPath_Init (LPVOID data)
static void RoundRectPath_Free (LPVOID h)
static int RoundRectPath_Next (LPVOID handle, PATHSEGMENT *ps)
static BOOL CubicCurveFromArc (double x0, double y0, double rx, double ry, double startangle, double sweepangle, double *P)
static double FixAngle (double radiusX, double radiusY, double angle)
static int CubicCurvesFromArc (double x, double y, double rx, double ry, double start, double sweep, double *vertices)
static BOOL PathAddArcInternal (ITEMARRAY *ia, ArcInternalFlags mode, double centerX, double centerY, double radiusX, double radiusY, double start, double sweep, double phi, double x0, double y0, double x, double y)
static BOOL PathAddSvgArcInternal (ITEMARRAY *ia, BOOL arcto, double x0, double y0, double x, double y, double rx, double ry, double phi, BOOL large_arc, BOOL sweep)
BOOL PathAddArcMultiSweep (ITEMARRAY *ia, double centerX, double centerY, double radiusX, double radiusY, double start, double sweep, double phi)
BOOL PathArcTo (ITEMARRAY *ia, double centerX, double centerY, double radiusX, double radiusY, double start, double sweep, double phi)
 Adds an arc segment to the path, defined using center parameterization, that is, where the arc is part of an ellipse defined using its center, radius, start and end angles, and rotation.
BOOL PathAddArc (ITEMARRAY *ia, double centerX, double centerY, double radiusX, double radiusY, double start, double sweep, double phi)
 Adds an arc segment to the path, defined using center parameterization.
BOOL PathSvgArcTo (ITEMARRAY *ia, double x, double y, double rx, double ry, double phi, BOOL largeArc, BOOL sweep)
 Adds an arc segment to the path where the arc is defined as having a start and end point as well as additional parameters that define an imaginary ellipse, as in the SVG specification.
BOOL PathAddSvgArc (ITEMARRAY *ia, double x0, double x1, double x, double y, double rx, double ry, double phi, BOOL largeArc, BOOL sweep)
 Adds an arc segment to the path where the arc is defined as having a start and end point as well as additional parameters that define an imaginary ellipse, as in the SVG specification.
BOOL EllipseContainsPoint (RECTDBL *rc, double x, double y)
BOOL EllipseContainsRect (RECTDBL *rc, double x0, double y0, double x1, double y1)
static int PathSegmentsNonZero_GetWinding (LPVOID h)
static int PathSegmentsEvenOdd_GetWinding (LPVOID h)
static LPVOID PathSegments_Init (LPVOID data)
static void PathSegments_Free (LPVOID h)
static int PathSegments_Next (LPVOID h, PATHSEGMENT *ps)
void FullPathContextInit (FULLPATHCONTEXT *fpc)
 Initializes a full path context for use in the iterator functions FullPathIteratorNext() and ClosedPathIteratorNext().
BOOL FullPathSegmentTransform (FULLPATHSEGMENT *ps, MATRIX *xfm)
 Applies a transform matrix to a full path segment.
void FullToPathSegment (FULLPATHSEGMENT *fullSegment, PATHSEGMENT *pathSegment)
int ClosedPathIteratorNext (PATHITERATOR *iter, LPVOID h, FULLPATHCONTEXT *fpc, FULLPATHSEGMENT *fps, MATRIX *matrix)
 An alternative path iterator where all subpaths are explicitly closed.
int FullPathIteratorNext (PATHITERATOR *iter, LPVOID h, FULLPATHCONTEXT *fpc, FULLPATHSEGMENT *fps, MATRIX *matrix)
 An alternative path iterator that includes the starting points of each path segment.
static void CurveFlattenerPush (CURVEFLATTENER *f)
static LPVOID CurveFlattenerCreate (double flatness, int flatnessmode)
static void CurveFlattenerFree (LPVOID pf)
static void CurveFlattenerReset (LPVOID pf, FULLPATHSEGMENT *fps)
BOOL QuadFlatEnough (double *curve, double tolerance, double *endpt)
BOOL CubicFlatEnough (double *curve, double tolerance, double *endpt)
static BOOL CurveFlattenerNextLine (CURVEFLATTENER *f, double *line)
static void MidpointCubicToQuad (double *cubic, double *quad)
static BOOL CubicIteratorNextQuadAlt (CURVEFLATTENER *f, double *quad)
static BOOL CubicIteratorNextQuad (CURVEFLATTENER *f, double *quad)
static LPVOID FlatPathIterator_InitInternal (FLATPATHPARAMS *fpp, int mode)
static LPVOID FlatPathIterator_Init (FLATPATHPARAMS *fpp)
static LPVOID CubicToQuadIterator_Init (FLATPATHPARAMS *fpp)
static void FlatPathIterator_Free (LPVOID h)
static int FlatPathIterator_GetWinding (LPVOID h)
static int FlatPathIterator_Next (LPVOID h, PATHSEGMENT *seg)
static int CubicToQuadIterator_Next (LPVOID h, PATHSEGMENT *seg)
int SolveLinear (double c[2], double s[1])
 Solves a linear equation and finds its non-complex roots.
int SolveQuadratic (double eqn[3], double s[2])
 Solves a quadratic equation and finds its non-complex roots.
static double NewtonFixup (double s, double c0, double c1, double c2, double c3)
int SolveCubic (double c[4], double s[3])
 Solves a cubic equation and finds its non-complex roots.
double QuadControlPolygonLength (double *qc)
double QuadChordLength (double *qc)
double QuadCalcLength (double *qc, double tolerance)
double CubicControlPolygonLength (double *qc)
double CubicChordLength (double *qc)
double CubicCalcLength (double *qc, double tolerance)
double EllipseArea (double radiusX, double radiusY, MATRIX *xfm)
static BOOL RectAccumulate (RECTDBL *prc, double x, double y, BOOL first)
static int CubicDerivatives (double *zeros, double cur, double cp0, double cp1, double end)
int PathGetBounds (PATHITERATOR *pcb, LPVOID data, MATRIX *xfm, RECTDBL *prc)
 Calculates a path's bounding box.

Variables

static double ctrlpts [4][6]
static double rrctrlpts []
static int rrindices []
static int rrtypes []
PATHITERATOR RoundRectPath
 A path iterator that retrieves the path of a rounded rectangle.
PATHITERATOR EllipsePath
 A path iterator that retrieves the path of an ellipse.
PATHITERATOR RectPath
 A path iterator that retrieves the path of a rectangle.
PATHITERATOR LinePath
 A path iterator that retrieves the path of a line.
PATHITERATOR QuadPath
 A path iterator that retrieves the path of a quadratic curve.
PATHITERATOR CubicPath
 A path iterator that retrieves the path of a cubic curve.
PATHITERATOR PathSegmentsNonZero
 A path iterator that retrieves the segments of a path and uses the NONZERO fill rule.
PATHITERATOR PathSegmentsEvenOdd
 A path iterator that retrieves the segments of a path and uses the EVENODD fill rule.
PATHITERATOR FlatPathIterator
 A path iterator that converts all curves in a path into lines.
PATHITERATOR CubicToQuadIterator
 A path iterator that converts all cubic curves in a path into quadratic curves.


Define Documentation

#define HORNERCUBIC x,
a,
b,
c,
 )     ( (a) + (x) * ( (b) + (x) * ( (c) + (x) * (d) ) ))
 

Definition at line 2332 of file path2d.c.

#define HORNERQUAD x,
a,
b,
 )     ( (a) + (x) * ( (b) + (x) * (c) ))
 

Definition at line 2330 of file path2d.c.

#define NCV   0.22385762508460333
 

Definition at line 955 of file path2d.c.

#define NCV   0.22385762508460333
 

Definition at line 955 of file path2d.c.

#define PCV   0.77614237491539666
 

Definition at line 892 of file path2d.c.


Enumeration Type Documentation

enum ArcInternalFlags
 

Enumerator:
ArcCheckEndPoint 
ArcDrawLine 
ArcMoveTo 
ArcHaveEndCoords 

Definition at line 1168 of file path2d.c.

enum CLOSEDPATHFLAGS
 

Enumerator:
PathNewMoveTo 
PathEndOfPath 
PathMask 
PathHaveLineTo 

Definition at line 1532 of file path2d.c.


Function Documentation

int ClosedPathIteratorNext PATHITERATOR iter,
LPVOID  h,
FULLPATHCONTEXT fpc,
FULLPATHSEGMENT fps,
MATRIX matrix
 

An alternative path iterator where all subpaths are explicitly closed.

Parameters:
iter Pointer to a path iterator.
h Data handle created using the path iterator's Init function.
fpc Full path context (see FullPathContextInit).
fps Full path segment.
matrix A matrix to transform segments retrieved from the path iterator.

Definition at line 1539 of file path2d.c.

double CubeRoot double  x  )  [inline]
 

Definition at line 97 of file path2d.c.

double CubicCalcLength double *  qc,
double  tolerance
 

Definition at line 2545 of file path2d.c.

double CubicChordLength double *  qc  ) 
 

Definition at line 2542 of file path2d.c.

double CubicControlPolygonLength double *  qc  ) 
 

Definition at line 2537 of file path2d.c.

static BOOL CubicCurveFromArc double  x0,
double  y0,
double  rx,
double  ry,
double  startangle,
double  sweepangle,
double *  P
[static]
 

Definition at line 1073 of file path2d.c.

void CubicCurveFromQuadratic double *  pSrc,
double *  pDst
 

Converts a quadratic curve into a cubic curve.

Parameters:
pSrc Source quadratic curve: three pairs of double-precision values specifying the X and Y values of the curve's start point, control point, and end point.
pDst Receives the coordinates of the destination cubic curve: four pairs of double-precision values specifying the X and Y values of the curve's start point, control points, and end point.

Definition at line 143 of file path2d.c.

static int CubicCurvesFromArc double  x,
double  y,
double  rx,
double  ry,
double  start,
double  sweep,
double *  vertices
[static]
 

Definition at line 1126 of file path2d.c.

static int CubicDerivatives double *  zeros,
double  cur,
double  cp0,
double  cp1,
double  end
[static]
 

Definition at line 2586 of file path2d.c.

BOOL CubicFlatEnough double *  curve,
double  tolerance,
double *  endpt
 

Definition at line 1835 of file path2d.c.

double CubicFlatnessSq double *  c  ) 
 

Definition at line 137 of file path2d.c.

static LPVOID CubicIterator_Init double *  data  )  [static]
 

Definition at line 801 of file path2d.c.

static int CubicIterator_Next LPVOID  h,
PATHSEGMENT ps
[static]
 

Definition at line 804 of file path2d.c.

static BOOL CubicIteratorNextQuad CURVEFLATTENER f,
double *  quad
[static]
 

Definition at line 2114 of file path2d.c.

static BOOL CubicIteratorNextQuadAlt CURVEFLATTENER f,
double *  quad
[static]
 

Definition at line 2048 of file path2d.c.

void CubicSubdivide double *  src,
double *  left,
double *  right,
double  t
 

Subdivides a cubic curve into two curves, at the parameter value _t_.

Parameters:
src Source curve: four pairs of double-precision values specifying the X and Y values of the curve's start point, control points, and end point.
left Receives the coordinates of the left-sided curve. This can be NULL.
right Receives the coordinates of the right-sided curve. This can be NULL.
t A value from 0 through 1 that specifies where to divide the curve.

Definition at line 238 of file path2d.c.

static LPVOID CubicToQuadIterator_Init FLATPATHPARAMS fpp  )  [static]
 

Definition at line 2238 of file path2d.c.

static int CubicToQuadIterator_Next LPVOID  h,
PATHSEGMENT seg
[static]
 

Definition at line 2285 of file path2d.c.

static LPVOID CurveFlattenerCreate double  flatness,
int  flatnessmode
[static]
 

Definition at line 1748 of file path2d.c.

static void CurveFlattenerFree LPVOID  pf  )  [static]
 

Definition at line 1766 of file path2d.c.

static BOOL CurveFlattenerNextLine CURVEFLATTENER f,
double *  line
[static]
 

Definition at line 1933 of file path2d.c.

static void CurveFlattenerPush CURVEFLATTENER f  )  [static]
 

Definition at line 1736 of file path2d.c.

static void CurveFlattenerReset LPVOID  pf,
FULLPATHSEGMENT fps
[static]
 

Definition at line 1775 of file path2d.c.

void DebugOutFullPathSegment FULLPATHSEGMENT ps,
LPCTSTR  add
 

Definition at line 477 of file path2d.c.

void DebugOutPathSegment PATHSEGMENT ps,
LPCTSTR  add
 

Displays output about a path segment to the debugger.

Definition at line 501 of file path2d.c.

void DebugOutPathSegmentAsSvg PATHSEGMENT ps  ) 
 

Displays output about a path segment in SVG format to the debugger.

No line breaks will be included.

Definition at line 527 of file path2d.c.

double EllipseArea double  radiusX,
double  radiusY,
MATRIX xfm
 

Definition at line 2571 of file path2d.c.

BOOL EllipseContainsPoint RECTDBL rc,
double  x,
double  y
 

Definition at line 1417 of file path2d.c.

BOOL EllipseContainsRect RECTDBL rc,
double  x0,
double  y0,
double  x1,
double  y1
 

Definition at line 1426 of file path2d.c.

static void EllipsePath_Free LPVOID  h  )  [static]
 

Definition at line 918 of file path2d.c.

static int EllipsePath_GetWinding LPVOID  h  )  [static]
 

Definition at line 900 of file path2d.c.

static LPVOID EllipsePath_Init LPVOID  data  )  [static]
 

Definition at line 903 of file path2d.c.

static int EllipsePath_Next LPVOID  handle,
PATHSEGMENT ps
[static]
 

Definition at line 921 of file path2d.c.

static double FixAngle double  radiusX,
double  radiusY,
double  angle
[static]
 

Definition at line 1099 of file path2d.c.

static void FlatPathIterator_Free LPVOID  h  )  [static]
 

Definition at line 2243 of file path2d.c.

static int FlatPathIterator_GetWinding LPVOID  h  )  [static]
 

Definition at line 2251 of file path2d.c.

static LPVOID FlatPathIterator_Init FLATPATHPARAMS fpp  )  [static]
 

Definition at line 2235 of file path2d.c.

static LPVOID FlatPathIterator_InitInternal FLATPATHPARAMS fpp,
int  mode
[static]
 

Definition at line 2209 of file path2d.c.

static int FlatPathIterator_Next LPVOID  h,
PATHSEGMENT seg
[static]
 

Definition at line 2256 of file path2d.c.

void FullPathContextInit FULLPATHCONTEXT fpc  ) 
 

Initializes a full path context for use in the iterator functions FullPathIteratorNext() and ClosedPathIteratorNext().

Definition at line 1491 of file path2d.c.

int FullPathIteratorNext PATHITERATOR iter,
LPVOID  h,
FULLPATHCONTEXT fpc,
FULLPATHSEGMENT fps,
MATRIX matrix
 

An alternative path iterator that includes the starting points of each path segment.

Parameters:
iter Pointer to a path iterator.
h Data handle created using the path iterator's Init function.
fpc Full path context (see FullPathContextInit).
fps Full path segment.
matrix A matrix to transform segments retrieved from the path iterator. This parameter can be NULL.

Definition at line 1651 of file path2d.c.

BOOL FullPathSegmentTransform FULLPATHSEGMENT ps,
MATRIX xfm
 

Applies a transform matrix to a full path segment.

Parameters:
ps Pointer to a full path segment.
xfm Transform to apply to the full path segment.
Returns:
TRUE if successful, FALSE otherwise.

Definition at line 1500 of file path2d.c.

void FullToPathSegment FULLPATHSEGMENT fullSegment,
PATHSEGMENT pathSegment
 

Definition at line 1524 of file path2d.c.

static LPVOID LineIterator_Init double *  data  )  [static]
 

Definition at line 753 of file path2d.c.

static int LineIterator_Next LPVOID  h,
PATHSEGMENT ps
[static]
 

Definition at line 756 of file path2d.c.

void LineSubdivide double *  src,
double *  left,
double *  right,
double  t
 

Subdivides a line into two lines, at the parameter value _t_.

Parameters:
src Source line: two pairs of double-precision values specifying the X and Y values of the line's end points.
left Receives the coordinates of the left-sided line. This can be NULL.
right Receives the coordinates of the right-sided line. This can be NULL.
t A value from 0 through 1 that specifies where to divide the line.

Definition at line 179 of file path2d.c.

static void MidpointCubicToQuad double *  cubic,
double *  quad
[static]
 

Definition at line 2035 of file path2d.c.

static double NewtonFixup double  s,
double  c0,
double  c1,
double  c2,
double  c3
[static]
 

Definition at line 2379 of file path2d.c.

BOOL PathAddArc ITEMARRAY ia,
double  centerX,
double  centerY,
double  radiusX,
double  radiusY,
double  start,
double  sweep,
double  phi
 

Adds an arc segment to the path, defined using center parameterization.

Parameters:
ia Item array containing path segments.
centerX X coordinate for the center of the ellipse that the arc's points are on.
centerY Y coordinate for the center of the ellipse that the arc's points are on.
radiusX X-radius of the ellipse. The absolute value of this parameter will be used. If this value is 0, this function does nothing.
radiusY Y-radius of the ellipse. The absolute value of this parameter will be used. If this value is 0, this function does nothing.
start Starting angle of the arc, in degrees. The angle given here is adjusted modulo 360 degrees. 0 represents the 3-o'clock position, 90 represents the 6 o'clock position, and 180 represents the 9 o'clock position.
sweep Difference between the starting angle of the arc and the ending angle of the arc, in degrees. If this parameter is positive, the arc is drawn clockwise; otherwise, the angle is drawn counterclockwise. If the parameter is 360 or greater or is -360 or less, the result is a complete ellipse and the end of the arc becomes equal to its starting point.
phi Rotation of the ellipse about the X-axis, in degrees.
Returns:
TRUE if successful, FALSE otherwise.
Remarks:
In center parameterization, an arc is defined as part of an ellipse with a center, radius, start and end angles, and rotation. When the arc is added, this function converts the arc into cubic Bezier curves. Up to five path segments will be added to the path in this way.

Definition at line 1383 of file path2d.c.

static BOOL PathAddArcInternal ITEMARRAY ia,
ArcInternalFlags  mode,
double  centerX,
double  centerY,
double  radiusX,
double  radiusY,
double  start,
double  sweep,
double  phi,
double  x0,
double  y0,
double  x,
double  y
[static]
 

Definition at line 1175 of file path2d.c.

BOOL PathAddArcMultiSweep ITEMARRAY ia,
double  centerX,
double  centerY,
double  radiusX,
double  radiusY,
double  start,
double  sweep,
double  phi
 

Definition at line 1344 of file path2d.c.

void PathAddCardinalSpline ITEMARRAY path,
double *  coords,
LONG  numpoints,
double  tension,
BOOL  closefigure
 

Adds a cardinal spline to the path.

Parameters:
path Item array containing path segments.
coords An array of pairs of Double values specifying the X and Y values of each end point in the curve. The first point in the array specifies the curve's starting point.
numpoints The number of points (pairs of coordinates) in the _coords_ array. This value must be 2 or greater.
tension Specifies the tension of the curve.
closefigure If TRUE, this function draws a closed curve.

Definition at line 639 of file path2d.c.

BOOL PathAddPoint ITEMARRAY ia,
double  x,
double  y
 

Adds a "move to" command to the path, but only if its end point is different from the new position.

Parameters:
ia Item array containing path segments.
x X coordinate of a point.
y Y coordinate of a point.
Returns:
FALSE if out of memory or the path is invalid, TRUE otherwise.

Definition at line 311 of file path2d.c.

BOOL PathAddSegment ITEMARRAY ia,
PATHSEGMENT ps
 

Adds a path segment to the path.

Parameters:
ia Item array containing path segments.
ps Path segment.
Returns:
TRUE if successful. If the function fails, for example, if the path is NULL, returns FALSE.

Definition at line 404 of file path2d.c.

BOOL PathAddSvgArc ITEMARRAY ia,
double  x0,
double  x1,
double  x,
double  y,
double  rx,
double  ry,
double  phi,
BOOL  largeArc,
BOOL  sweep
 

Adds an arc segment to the path where the arc is defined as having a start and end point as well as additional parameters that define an imaginary ellipse, as in the SVG specification.

When the arc is added, this function converts the arc into cubic Bezier curves.

Parameters:
ia Item array containing path segments.
x0 X coordinate of the arc's starting point. This function will add a MoveTo command for the arc's starting point before drawing.
x1 Y coordinate of the arc's starting point.
x X coordinate of the arc's end point. If the arc's starting and ending points are equal, then the function draws nothing, but still returns TRUE for success.
y Y coordinate of the arc's end point.
radiusX X-radius of the ellipse. The absolute value of this parameter will be used. If this value is 0, then this function will draw a straight line.
radiusY Y-radius of the ellipse. The absolute value of this parameter will be used. If this value is 0, then this function will draw a straight line.
phi Rotation of the ellipse about the X axis, in degrees. The value of this parameter will be adjusted modulo 360 degrees.
largeArc In most cases, there are four solutions for ellipse arcs that satisfy the parameters given above. Two of these solutions have larger arc sweeps than the other two. If this parameter is TRUE, one of the two solutions with larger arc sweeps will be used.
sweep Two of the four arc solutions are drawn counterclockwise, and the other two are drawn clockwise. If this parameter is TRUE, the arc is drawn clockwise, or in a "positive angle" direction.
Returns:
TRUE if successful, FALSE otherwise.

Definition at line 1406 of file path2d.c.

static BOOL PathAddSvgArcInternal ITEMARRAY ia,
BOOL  arcto,
double  x0,
double  y0,
double  x,
double  y,
double  rx,
double  ry,
double  phi,
BOOL  large_arc,
BOOL  sweep
[static]
 

Definition at line 1247 of file path2d.c.

BOOL PathAppendPath ITEMARRAY ia,
PATHITERATOR pcb,
LPVOID  data,
MATRIX xfm,
BOOL  connect
 

Appends another path, in the form of a path iterator, to this path.

Definition at line 424 of file path2d.c.

BOOL PathArcTo ITEMARRAY ia,
double  centerX,
double  centerY,
double  radiusX,
double  radiusY,
double  start,
double  sweep,
double  phi
 

Adds an arc segment to the path, defined using center parameterization, that is, where the arc is part of an ellipse defined using its center, radius, start and end angles, and rotation.

When the arc is added, this function converts the arc into cubic Bezier curves. Before drawing the arc, this function will draw a line from the current position to the starting point of the arc. See PathAddArc() for information on the parameters and return value.

Definition at line 1366 of file path2d.c.

void PathCardinalSplineTo ITEMARRAY path,
double *  coords,
LONG  numpoints,
double  tension
 

Adds a cardinal spline to the path, starting with the path's current point.

Parameters:
path Item array containing path segments.
coords An array of pairs of Double values specifying the X and Y values of each end point in the curve.
numpoints The number of points (pairs of coordinates) in the _coords_ array. This value must be 1 or greater.
tension Specifies the tension of the curve. "A tension of 0 corresponds to infinite physical tension, forcing the curve to take the shortest way (straight lines) between points. A tension of 1 corresponds to no physical tension, allowing the spline to take the path of least total bend. With tension values greater than 1, the curve behaves like a compressed spring, pushed to take a longer path." [http://msdn2.microsoft.com/en-us/library/4cf6we5y.aspx]

Definition at line 594 of file path2d.c.

BOOL PathClose ITEMARRAY ia  ) 
 

Adds a "close path" command, where a straight line is drawn from the current position to the starting point.

Due to stroking, closing a path in this way is distinct from adding a line to the starting point "manually".

Parameters:
ia Item array containing path segments.
Returns:
TRUE if successful, FALSE if out of memory or the path is empty.

Definition at line 393 of file path2d.c.

BOOL PathCubicTo ITEMARRAY ia,
double  x,
double  y,
double  x1,
double  y1,
double  x2,
double  y2
 

Adds a cubic Bezier curve to the path, starting at the path's current end point.

Parameters:
ia Item array containing path segments.
x X coordinate of the curve's first control point.
y Y coordinate of the curve's first control point.
x1 X coordinate of the curve's second control point.
y1 Y coordinate of the curve's second control point.
x2 X coordinate of the curve's end point.
y2 Y coordinate of the curve's end point.
Returns:
TRUE if successful, FALSE if out of memory or the path is empty.

Definition at line 343 of file path2d.c.

int PathGetBounds PATHITERATOR pcb,
LPVOID  data,
MATRIX xfm,
RECTDBL prc
 

Calculates a path's bounding box.

Parameters:
ps Path iterator.
data Path data or parameters for the path iterator.
xfm Transform to apply to each path segment in the path before calculating. This parameter can be NULL.
prc Receives the bounding box of the path.
Returns:
-1 on error, 1 if successful, and 0 if the path is empty.

Definition at line 2592 of file path2d.c.

BOOL PathGetEndPoint ITEMARRAY ia,
double *  endpt
 

Finds the path's current end point.

Parameters:
ia Item array containing path segments.
endpt An array of two doubles to receive the X and Y coordinates of the end point.
Returns:
TRUE if the path currently has an end point, or FALSE otherwise.

Definition at line 553 of file path2d.c.

BOOL PathLineTo ITEMARRAY ia,
double  x,
double  y
 

Draws a line from the current position to a new one, starting at the path's current end point.

Parameters:
ia Item array containing path segments.
x X coordinate of the line's end point.
y Y coordinate of the line's end point.
Returns:
FALSE if out of memory or the path is invalid, TRUE otherwise.

Definition at line 321 of file path2d.c.

BOOL PathMoveTo ITEMARRAY ia,
double  x,
double  y
 

Adds a "move to" command to the path.

Parameters:
ia Item array containing path segments.
x X coordinate of a point.
y Y coordinate of a point.
Returns:
TRUE if successful, FALSE otherwise.

Definition at line 301 of file path2d.c.

BOOL PathQuadTo ITEMARRAY ia,
double  x,
double  y,
double  x1,
double  y1
 

Adds a quadratic Bezier curve to the path, starting at the path's current end point.

Parameters:
ia Item array containing path segments.
x X coordinate of the curve's control point.
y Y coordinate of the curve's control point.
x1 X coordinate of the curve's end point.
y1 Y coordinate of the curve's end point.
Returns:
TRUE if successful, FALSE if out of memory or the path is empty.

Definition at line 331 of file path2d.c.

double* PathSegmentEndPoint PATHSEGMENT ps  ) 
 

Returns a pointer to the end point of the path segment _ps_, or NULL if the path segment has no end point.

Definition at line 286 of file path2d.c.

static void PathSegments_Free LPVOID  h  )  [static]
 

Definition at line 1458 of file path2d.c.

static LPVOID PathSegments_Init LPVOID  data  )  [static]
 

Definition at line 1447 of file path2d.c.

static int PathSegments_Next LPVOID  h,
PATHSEGMENT ps
[static]
 

Definition at line 1461 of file path2d.c.

static int PathSegmentsEvenOdd_GetWinding LPVOID  h  )  [static]
 

Definition at line 1444 of file path2d.c.

static int PathSegmentsNonZero_GetWinding LPVOID  h  )  [static]
 

Definition at line 1441 of file path2d.c.

BOOL PathSegmentTransform PATHSEGMENT ps,
MATRIX xfm
 

Applies a transform matrix to a path segment.

Parameters:
ps Pointer to a path segment.
xfm Transform to apply to the path segment.
Returns:
TRUE if successful, FALSE otherwise.

Definition at line 701 of file path2d.c.

BOOL PathSmoothCubicTo ITEMARRAY ia,
double  x1,
double  y1,
double  x2,
double  y2
 

Adds a cubic Bezier curve to the path, starting at the path's current end point.

Parameters:
ia Item array containing path segments.
x1 X coordinate of the curve's second control point.
y1 Y coordinate of the curve's second control point.
x X coordinate of the curve's end point.
y Y coordinate of the curve's end point.
Returns:
TRUE if successful, FALSE if out of memory or the path is empty.
Remarks:
The curve's first control point is defined as the reflection of the previous cubic curve's second control point, or as the current point if the last command was not a cubic curve. More accurately, the new control point equals (2 * LastControlPoint) + CurrentPoint .

Definition at line 376 of file path2d.c.

BOOL PathSmoothQuadTo ITEMARRAY ia,
double  x,
double  y
 

Adds a quadratic Bezier curve to the path, starting at the path's current end point.

The curve's control point is defined as the reflection of the previous quadratic curve's control point, or as the current point if the last command was not a quadratic curve. More accurately, the new control point equals (2 * LastControlPoint) + CurrentPoint .

Parameters:
ia Item array containing path segments.
x X coordinate of the curve's end point.
y Y coordinate of the curve's end point.
Returns:
TRUE if successful, FALSE if out of memory or the path is empty.

Definition at line 359 of file path2d.c.

BOOL PathSvgArcTo ITEMARRAY ia,
double  x,
double  y,
double  rx,
double  ry,
double  phi,
BOOL  largeArc,
BOOL  sweep
 

Adds an arc segment to the path where the arc is defined as having a start and end point as well as additional parameters that define an imaginary ellipse, as in the SVG specification.

When the arc is added, this function converts the arc into cubic Bezier curves. The start point is considered to be the path's current point. See PathAddSvgArc() for information on the parameters and return value.

Definition at line 1398 of file path2d.c.

BOOL PathTransform ITEMARRAY path,
MATRIX xfm
 

Applies an affine transform to the path.

Parameters:
path Item array containing path segments.
xfm Affine transform matrix.
Returns:
TRUE if successful, FALSE otherwise.

Definition at line 691 of file path2d.c.

double PerpendicularDistance double  x0,
double  y0,
double  x1,
double  y1,
double  ptx,
double  pty
 

Definition at line 163 of file path2d.c.

double PointDistance double  x1,
double  y1,
double  x2,
double  y2
 

Definition at line 102 of file path2d.c.

double QuadCalcLength double *  qc,
double  tolerance
 

Definition at line 2507 of file path2d.c.

double QuadChordLength double *  qc  ) 
 

Definition at line 2504 of file path2d.c.

double QuadControlPolygonLength double *  qc  ) 
 

Definition at line 2500 of file path2d.c.

BOOL QuadFlatEnough double *  curve,
double  tolerance,
double *  endpt
 

Definition at line 1797 of file path2d.c.

double QuadFlatnessSq double *  c  ) 
 

Definition at line 133 of file path2d.c.

static LPVOID QuadIterator_Init double *  data  )  [static]
 

Definition at line 776 of file path2d.c.

static int QuadIterator_Next LPVOID  h,
PATHSEGMENT ps
[static]
 

Definition at line 779 of file path2d.c.

void QuadSubdivide double *  src,
double *  left,
double *  right,
double  t
 

Subdivides a quadratic curve into two curves, at the parameter value _t_.

Parameters:
src Source curve: three pairs of double-precision values specifying the X and Y values of the curve's start point, control point, and end point.
left Receives the coordinates of the left-sided curve. This can be NULL.
right Receives the coordinates of the right-sided curve. This can be NULL.
t A value from 0 through 1 that specifies where to divide the curve.

Definition at line 204 of file path2d.c.

static BOOL RectAccumulate RECTDBL prc,
double  x,
double  y,
BOOL  first
[static]
 

Definition at line 2578 of file path2d.c.

BOOL RectContainsPoint RECTDBL rc,
double  x,
double  y
 

Definition at line 5 of file path2d.c.

BOOL RectContainsRect RECTDBL rc,
double  x,
double  y,
double  x1,
double  y1
 

Definition at line 13 of file path2d.c.

BOOL RectIntersectsRect RECTDBL rc,
double  x,
double  y,
double  x1,
double  y1
 

Definition at line 8 of file path2d.c.

static void RectPath_Free LPVOID  h  )  [static]
 

Definition at line 850 of file path2d.c.

static int RectPath_GetWinding LPVOID  h  )  [static]
 

Definition at line 832 of file path2d.c.

static LPVOID RectPath_Init LPVOID  data  )  [static]
 

Definition at line 835 of file path2d.c.

static int RectPath_Next LPVOID  h,
PATHSEGMENT ps
[static]
 

Definition at line 853 of file path2d.c.

static void RoundRectPath_Free LPVOID  h  )  [static]
 

Definition at line 1006 of file path2d.c.

static int RoundRectPath_GetWinding LPVOID  h  )  [static]
 

Definition at line 991 of file path2d.c.

static LPVOID RoundRectPath_Init LPVOID  data  )  [static]
 

Definition at line 994 of file path2d.c.

static int RoundRectPath_Next LPVOID  handle,
PATHSEGMENT ps
[static]
 

Definition at line 1009 of file path2d.c.

static void SegIterator_Free LPVOID  h  )  [static]
 

Definition at line 750 of file path2d.c.

static int SegIterator_GetWinding LPVOID  h  )  [static]
 

Definition at line 732 of file path2d.c.

static LPVOID SegIterator_Init double *  data,
DWORD  numpoints
[static]
 

Definition at line 735 of file path2d.c.

double SegmentDistanceSq double  x0,
double  y0,
double  x1,
double  y1,
double  ptx,
double  pty
 

Definition at line 107 of file path2d.c.

int SolveCubic double  c[4],
double  s[3]
 

Solves a cubic equation and finds its non-complex roots.

Parameters:
c Coefficients for the cubic equation of the form ax^3 + bx^2 + cx + d = 0, where a, b, c, and d correspond to c[3], c[2], c[1], and c[0], respectively.
s Holds the solutions to the equation.
Returns:
Number of non-complex solutions found.

Definition at line 2414 of file path2d.c.

int SolveLinear double  c[2],
double  s[1]
 

Solves a linear equation and finds its non-complex roots.

Parameters:
c Coefficients for the linear equation of the form ax + b = 0, where a and b correspond to c[1] and c[0], respectively.
s Holds the solution to the equation.
Returns:
Number of non-complex solutions found.

Definition at line 2336 of file path2d.c.

int SolveQuadratic double  c[3],
double  s[2]
 

Solves a quadratic equation and finds its non-complex roots.

Parameters:
c Coefficients for the quadratic equation of the form ax^2 + bx + c = 0, where a, b, and c correspond to c[2], c[1], and c[0], respectively.
s Holds the solutions to the equation.
Returns:
Number of non-complex solutions found.

Definition at line 2346 of file path2d.c.

BOOL ViewSpaceCalcTransformEx MATRIX xfmDst,
RECTDBL rcViewport,
RECTDBL rcWindow,
int  align,
int  meetOrSlice
 

Calculates a transform matrix where units from one coordinate system are mapped to units in another coordinate system.

Parameters:
xfmDst Pointer to receive the calculated matrix.
rcViewport Rectangle specifying the origin and size of the viewport. Viewport coordinates are normally in pixels.
rcWindow Rectangle specifying the origin and size of the window, called "viewBox" in the SVG specification. Window coordinates are normally in logical, device-independent units.
align Specifies the alignment mode in case the viewport's aspect ratio differs from the window's aspect ratio. The following values are possible:
  • 0 - No alignment; the window will be scaled to fit the viewport.
  • 1 - Align to top-left.
  • 2 - Align to top-center.
  • 3 - Align to top-right.
  • 4 - Align to mid-left.
  • 5 - Align to center.
  • 6 - Align to mid-right.
  • 7 - Align to bottom-left.
  • 8 - Align to bottom-center.
  • 9 - Align to bottom-right.
meetOrSlice If TRUE ("slice"), then the viewport will be entirely covered by the window and the window will be scaled while preserving aspect ratio. If FALSE ("meet"), then the window will be scaled down so that it becomes entirely visible while preserving aspect ratio. This parameter is ignored if align is 0.
Returns:
TRUE if successful, FALSE otherwise. Returns FALSE if rcViewport, xfmDst, or rcWindow are NULL, or if rcViewport or rcWindow have negative widths or heights.

Definition at line 20 of file path2d.c.


Variable Documentation

double ctrlpts[4][6] [static]
 

Initial value:

{
 {1.0, 0.77614237491539666 , 0.77614237491539666 ,1.0,0.5,1.0},
 { 0.22385762508460333 ,1.0,0.0, 0.77614237491539666 ,0.0,0.5},
 {0.0, 0.22385762508460333 , 0.22385762508460333 ,0.0,0.5,0.0},
 { 0.77614237491539666 ,0.0,1.0, 0.22385762508460333 ,1.0,0.5}
}

Definition at line 894 of file path2d.c.

PATHITERATOR CubicPath
 

Initial value:

A path iterator that retrieves the path of a cubic curve.

The path data consists of four pairs of double-precision values describing the start point, control points, and end point of the curve.

Definition at line 1062 of file path2d.c.

PATHITERATOR CubicToQuadIterator
 

Initial value:

A path iterator that converts all cubic curves in a path into quadratic curves.

It takes a FLATPATHPARAMS structure as the path data.

Definition at line 2322 of file path2d.c.

PATHITERATOR EllipsePath
 

Initial value:

A path iterator that retrieves the path of an ellipse.

It takes a RECTDBL structure as the path data.

Definition at line 1038 of file path2d.c.

PATHITERATOR FlatPathIterator
 

Initial value:

A path iterator that converts all curves in a path into lines.

It takes a FLATPATHPARAMS structure as the path data.

Definition at line 2315 of file path2d.c.

PATHITERATOR LinePath
 

Initial value:

A path iterator that retrieves the path of a line.

The path data consists of two pairs of double-precision values describing the start point and end point of the line.

Definition at line 1050 of file path2d.c.

PATHITERATOR PathSegmentsEvenOdd
 

Initial value:

A path iterator that retrieves the segments of a path and uses the EVENODD fill rule.

It takes an ITEMARRAY with PATHSEGMENT structures as the path data.

Definition at line 1480 of file path2d.c.

PATHITERATOR PathSegmentsNonZero
 

Initial value:

A path iterator that retrieves the segments of a path and uses the NONZERO fill rule.

It takes an ITEMARRAY with PATHSEGMENT structures as the path data.

Definition at line 1473 of file path2d.c.

PATHITERATOR QuadPath
 

Initial value:

A path iterator that retrieves the path of a quadratic curve.

The path data consists of three pairs of double-precision values describing the start point, control point, and end point of the curve.

Definition at line 1056 of file path2d.c.

PATHITERATOR RectPath
 

Initial value:

A path iterator that retrieves the path of a rectangle.

It takes a RECTDBL structure as the path data.

Definition at line 1044 of file path2d.c.

PATHITERATOR RoundRectPath
 

Initial value:

A path iterator that retrieves the path of a rounded rectangle.

It takes a ROUNDRECT structure as the path data.

Definition at line 1032 of file path2d.c.

double rrctrlpts[] [static]
 

Initial value:

{
 0.0,0.0,0.0,0.5,
 0.0,0.0,1.0,-0.5,
 0.0,0.0,1.0,- 0.22385762508460333 ,
 0.0, 0.22385762508460333 ,1.0,0.0,
 0.0,0.5,1.0,0.0,
 1.0,-0.5,1.0,0.0,
 1.0,- 0.22385762508460333 ,1.0,0.0,
 1.0,0.0,1.0,- 0.22385762508460333 ,
 1.0,0.0,1.0,-0.5,
 1.0,0.0,0.0,0.5,
 1.0,0.0,0.0, 0.22385762508460333 ,
 1.0,- 0.22385762508460333 ,0.0,0.0,
 1.0,-0.5,0.0,0.0,
 0.0,0.5,0.0,0.0,
 0.0, 0.22385762508460333 ,0.0,0.0,
 0.0,0.0,0.0, 0.22385762508460333 ,
 0.0,0.0,0.0,0.5,
}

Definition at line 956 of file path2d.c.

int rrindices[] [static]
 

Initial value:

{
 0,4,8,20,24,36,40,52,56,68,68
}

Definition at line 975 of file path2d.c.

int rrtypes[] [static]
 

Initial value:

{
  1 ,
  2 , 4 ,
  2 , 4 ,
  2 , 4 ,
  2 , 4 ,
  5 
}

Definition at line 978 of file path2d.c.


Generated on Thu Mar 27 01:46:57 2008 for Item Arrays by  doxygen 1.4.6-NO