CUGL 2.1
Cornell University Game Library
Public Member Functions | List of all members
cugl::PathFactory Class Reference

#include <CUPathFactory.h>

Public Member Functions

 PathFactory ()
 
 PathFactory (float tol)
 
float getTolerance () const
 
void setTolerance (float tol)
 
Path2 makeLine (const Vec2 origin, const Vec2 dest) const
 
Path2 makeLine (float ox, float oy, float dx, float dy) const
 
Path2makeLine (Path2 *path, const Vec2 origin, const Vec2 dest) const
 
Path2makeLine (Path2 *path, float ox, float oy, float dx, float dy) const
 
Path2 makeTriangle (const Vec2 a, const Vec2 b, const Vec2 c) const
 
Path2 makeTriangle (float ax, float ay, float bx, float by, float cx, float cy) const
 
Path2makeTriangle (Path2 *path, const Vec2 a, const Vec2 b, const Vec2 c) const
 
Path2makeTriangle (Path2 *path, float ax, float ay, float bx, float by, float cx, float cy) const
 
Path2 makeRect (const Vec2 origin, const Vec2 size) const
 
Path2 makeRect (const Rect rect) const
 
Path2 makeRect (float x, float y, float w, float h) const
 
Path2makeRect (Path2 *path, const Vec2 origin, const Vec2 size) const
 
Path2makeRect (Path2 *path, const Rect rect) const
 
Path2makeRect (Path2 *path, float x, float y, float w, float h) const
 
Path2 makeNgon (const Vec2 center, float radius, Uint32 sides) const
 
Path2 makeNgon (float cx, float cy, float radius, Uint32 sides) const
 
Path2makeNgon (Path2 *path, const Vec2 center, float radius, float sides) const
 
Path2makeNgon (Path2 *path, float cx, float cy, float radius, Uint32 sides) const
 
Path2 makeEllipse (const Vec2 center, const Vec2 size) const
 
Path2 makeEllipse (float cx, float cy, float sx, float sy) const
 
Path2makeEllipse (Path2 *path, const Vec2 center, const Vec2 size) const
 
Path2makeEllipse (Path2 *path, float cx, float cy, float sx, float sy) const
 
Path2 makeCircle (const Vec2 center, float radius) const
 
Path2 makeCircle (float cx, float cy, float radius) const
 
Path2makeCircle (Path2 *path, const Vec2 center, float radius) const
 
Path2makeCircle (Path2 *path, float cx, float cy, float radius) const
 
Path2 makeArc (const Vec2 center, float radius, float start, float degrees) const
 
Path2 makeArc (float cx, float cy, float radius, float start, float degrees) const
 
Path2makeArc (Path2 *path, const Vec2 center, float radius, float start, float degrees) const
 
Path2makeArc (Path2 *path, float cx, float cy, float radius, float start, float degrees) const
 
Path2 makeRoundedRect (const Vec2 origin, const Size size, float radius) const
 
Path2 makeRoundedRect (const Rect rect, float radius) const
 
Path2 makeRoundedRect (float x, float y, float w, float h, float r) const
 
Path2makeRoundedRect (Path2 *path, const Vec2 origin, const Size size, float radius) const
 
Path2makeRoundedRect (Path2 *path, const Rect rect, float radius) const
 
Path2makeRoundedRect (Path2 *path, float x, float y, float w, float h, float r) const
 
Path2 makeCapsule (const Vec2 origin, const Size size) const
 
Path2 makeCapsule (const Rect rect) const
 
Path2 makeCapsule (float x, float y, float w, float h) const
 
Path2makeCapsule (Path2 *path, const Vec2 origin, const Size size) const
 
Path2makeCapsule (Path2 *path, const Rect rect) const
 
Path2makeCapsule (Path2 *path, float x, float y, float w, float h) const
 
Path2 makeCapsule (poly2::Capsule shape, const Vec2 origin, const Size size) const
 
Path2 makeCapsule (poly2::Capsule shape, const Rect rect) const
 
Path2 makeCapsule (poly2::Capsule shape, float x, float y, float w, float h) const
 
Path2makeCapsule (Path2 *path, poly2::Capsule shape, const Vec2 origin, const Size size) const
 
Path2makeCapsule (Path2 *path, poly2::Capsule shape, const Rect rect) const
 
Path2makeCapsule (Path2 *path, poly2::Capsule shape, float x, float y, float w, float h) const
 
std::vector< Path2makeTraversal (const Poly2 &src, poly2::Traversal type) const
 
std::vector< Path2 > * makeTraversal (std::vector< Path2 > *paths, const Poly2 &src, poly2::Traversal type) const
 

Detailed Description

This class is a factory for generating common Path2 objects.

Most of the time that we create a path, we are using it to approximate a common shape, like a circle, or a rounded rectangle. Instead of embedding all of this functionality into Path2 (which already has enough to do on its own), we have factored this out into a a separate factory class. This factory can generate new path or reset existing ones (conserving memory).

Note that this factory only generates path, and does not create Path2 objects. It is intended for shapes that will be drawn as lines or extruded later. If you want a solid (e.g. triangulated) shape, use PolyFactory instead.

Constructor & Destructor Documentation

◆ PathFactory() [1/2]

cugl::PathFactory::PathFactory ( )

Creates a factory for generating common paths.

This factory will use the default tolerance.

◆ PathFactory() [2/2]

cugl::PathFactory::PathFactory ( float  tol)

Creates a factory for generating common paths with the given tolerance.

Parameters
tolThe curve tolerance for rounded shapes

Member Function Documentation

◆ getTolerance()

float cugl::PathFactory::getTolerance ( ) const
inline

Returns the curve tolerance for rounded shapes.

The tolerance guarantees that curved shapes have enough segments so that any points on the true shape are always within tolerance of the segmented approximation.

Rounded shapes include makeEllipse, makeCircle, makeArc, and makeRoundedRect.

Returns
the curve tolerance for rounded shapes.

◆ makeArc() [1/4]

Path2 cugl::PathFactory::makeArc ( const Vec2  center,
float  radius,
float  start,
float  degrees 
) const
inline

Returns a path that represents an arc of the given dimensions.

All arc measurements are in degrees, not radians.

Parameters
centerThe arc center point (of the defining circle
radiusThe radius from the center point
startThe starting angle in degrees
degreesThe number of degrees to generate
Returns
a path that represents an arc of the given dimensions.

◆ makeArc() [2/4]

Path2 cugl::PathFactory::makeArc ( float  cx,
float  cy,
float  radius,
float  start,
float  degrees 
) const

Returns a path that represents an arc of the given dimensions.

All arc measurements are in degrees, not radians.

Parameters
cxThe x-coordinate of the center point
cyThe y-coordinate of the center point
radiusThe radius from the center point
startThe starting angle in degrees
degreesThe number of degrees to generate
Returns
a path that represents an arc of the given dimensions.

◆ makeArc() [3/4]

Path2* cugl::PathFactory::makeArc ( Path2 path,
const Vec2  center,
float  radius,
float  start,
float  degrees 
) const
inline

Stores an arc in the provided buffer.

All arc measurements are in degrees, not radians.

The arc will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
centerThe arc center point (of the defining circle
radiusThe radius from the center point
startThe starting angle in degrees
degreesThe number of degrees to generate
Returns
a reference to the buffer for chaining.

◆ makeArc() [4/4]

Path2* cugl::PathFactory::makeArc ( Path2 path,
float  cx,
float  cy,
float  radius,
float  start,
float  degrees 
) const

Stores an arc in the provided buffer.

All arc measurements are in degrees, not radians.

The arc will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
cxThe x-coordinate of the center point
cyThe y-coordinate of the center point
radiusThe radius from the center point
startThe starting angle in degrees
degreesThe number of degrees to generate
Returns
a reference to the buffer for chaining.

◆ makeCapsule() [1/12]

Path2 cugl::PathFactory::makeCapsule ( const Rect  rect) const
inline

Returns a path that represents a (full) capsule of the given dimensions.

A capsule is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom. Otherwise it will be oriented horizontally.

Parameters
rectThe enclosing rectangle
Returns
a path that represents a (full) capsule of the given dimensions.

◆ makeCapsule() [2/12]

Path2 cugl::PathFactory::makeCapsule ( const Vec2  origin,
const Size  size 
) const
inline

Returns a path that represents a (full) capsule of the given dimensions.

A capsule is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom. Otherwise it will be oriented horizontally.

Parameters
originThe enclosing rectangle origin
sizeThe enclosing rectangle size
Returns
a path that represents a (full) capsule of the given dimensions.

◆ makeCapsule() [3/12]

Path2 cugl::PathFactory::makeCapsule ( float  x,
float  y,
float  w,
float  h 
) const

Returns a path that represents a (full) capsule of the given dimensions.

A capsule is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom. Otherwise it will be oriented horizontally.

Parameters
xThe x-coordinate of the bottom left corner of the bounding box
yThe y-coordinate of the bottom left corner of the bounding box
wThe capsule width
hThe capsule height
Returns
a path that represents a (full) capsule of the given dimensions.

◆ makeCapsule() [4/12]

Path2* cugl::PathFactory::makeCapsule ( Path2 path,
const Rect  rect 
) const
inline

Stores a (full) capsule in the provided buffer.

A capsule is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom. Otherwise it will be oriented horizontally.

The capsule will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
rectThe enclosing rectangle
Returns
a reference to the buffer for chaining.

◆ makeCapsule() [5/12]

Path2* cugl::PathFactory::makeCapsule ( Path2 path,
const Vec2  origin,
const Size  size 
) const
inline

Stores a (full) capsule in the provided buffer.

A capsule is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom. Otherwise it will be oriented horizontally.

The capsule will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
originThe enclosing rectangle origin
sizeThe enclosing rectangle size
Returns
a reference to the buffer for chaining.

◆ makeCapsule() [6/12]

Path2* cugl::PathFactory::makeCapsule ( Path2 path,
float  x,
float  y,
float  w,
float  h 
) const

Stores a (full) capsule in the provided buffer.

A capsule is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom.Otherwise it will be oriented horizontally.

The capsule will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
xThe x-coordinate of the bottom left corner of the bounding box
yThe y-coordinate of the bottom left corner of the bounding box
wThe capsule width
hThe capsule height
Returns
a reference to the buffer for chaining.

◆ makeCapsule() [7/12]

Path2* cugl::PathFactory::makeCapsule ( Path2 path,
poly2::Capsule  shape,
const Rect  rect 
) const
inline

Stores a capsule in the provided buffer.

A capsule typically is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom. Otherwise it will be oriented horizontally.

This method allows for the creation of half-capsules, simply by using the enumeration poly2::Capsule. The enumeration specifies which side should be rounded in case of a half-capsule. Half-capsules are sized so that the corresponding full capsule would fit in the bounding box.

The capsule will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
shapeThe capsule shape
rectThe enclosing rectangle
Returns
a reference to the buffer for chaining.

◆ makeCapsule() [8/12]

Path2* cugl::PathFactory::makeCapsule ( Path2 path,
poly2::Capsule  shape,
const Vec2  origin,
const Size  size 
) const
inline

Stores a capsule in the provided buffer.

A capsule typically is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom. Otherwise it will be oriented horizontally.

This method allows for the creation of half-capsules, simply by using the enumeration poly2::Capsule. The enumeration specifies which side should be rounded in case of a half-capsule. Half-capsules are sized so that the corresponding full capsule would fit in the bounding box.

The capsule will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
shapeThe capsule shape
originThe enclosing rectangle origin
sizeThe enclosing rectangle size
Returns
a reference to the buffer for chaining.

◆ makeCapsule() [9/12]

Path2* cugl::PathFactory::makeCapsule ( Path2 path,
poly2::Capsule  shape,
float  x,
float  y,
float  w,
float  h 
) const

Stores a capsule in the provided buffer.

A capsule typically is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom. Otherwise it will be oriented horizontally.

This method allows for the creation of half-capsules, simply by using the enumeration poly2::Capsule. The enumeration specifies which side should be rounded in case of a half-capsule. Half-capsules are sized so that the corresponding full capsule would fit in the bounding box.

The capsule will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
shapeThe capsule shape
xThe x-coordinate of the bottom left corner of the bounding box
yThe y-coordinate of the bottom left corner of the bounding box
wThe capsule width
hThe capsule height
Returns
a reference to the buffer for chaining.

◆ makeCapsule() [10/12]

Path2 cugl::PathFactory::makeCapsule ( poly2::Capsule  shape,
const Rect  rect 
) const
inline

Returns a path that represents a capsule of the given dimensions.

A capsule typically is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom. Otherwise it will be oriented horizontally.

This method allows for the creation of half-capsules, simply by using the enumeration poly2::Capsule. The enumeration specifies which side should be rounded in case of a half-capsule. Half-capsules are sized so that the corresponding full capsule would fit in the bounding box.

Parameters
shapeThe capsule shape
rectThe enclosing rectangle
Returns
a path that represents a capsule of the given dimensions.

◆ makeCapsule() [11/12]

Path2 cugl::PathFactory::makeCapsule ( poly2::Capsule  shape,
const Vec2  origin,
const Size  size 
) const
inline

Returns a path that represents a capsule of the given dimensions.

A capsule typically is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom. Otherwise it will be oriented horizontally.

This method allows for the creation of half-capsules, simply by using the enumeration poly2::Capsule. The enumeration specifies which side should be rounded in case of a half-capsule. Half-capsules are sized so that the corresponding full capsule would fit in the bounding box.

Parameters
shapeThe capsule shape
originThe enclosing rectangle origin
sizeThe enclosing rectangle size
Returns
a path that represents a capsule of the given dimensions.

◆ makeCapsule() [12/12]

Path2 cugl::PathFactory::makeCapsule ( poly2::Capsule  shape,
float  x,
float  y,
float  w,
float  h 
) const

Returns a path that represents a (full) capsule of the given dimensions.

A capsule typically is a pill-like shape that fits inside of given rectangle. If width < height, the capsule will be oriented vertically with the rounded portions at the top and bottom. Otherwise it will be oriented horizontally.

This method allows for the creation of half-capsules, simply by using the enumeration poly2::Capsule. The enumeration specifies which side should be rounded in case of a half-capsule. Half-capsules are sized so that the corresponding full capsule would fit in the bounding box.

Parameters
shapeThe capsule shape
xThe x-coordinate of the bottom left corner of the bounding box
yThe y-coordinate of the bottom left corner of the bounding box
wThe capsule width
hThe capsule height
Returns
a path that represents a capsule of the given dimensions.

◆ makeCircle() [1/4]

Path2 cugl::PathFactory::makeCircle ( const Vec2  center,
float  radius 
) const
inline

Returns a path that represents a circle of the given dimensions.

Parameters
centerThe circle center point
radiusThe circle radius
Returns
a path that represents an circle of the given dimensions.

◆ makeCircle() [2/4]

Path2 cugl::PathFactory::makeCircle ( float  cx,
float  cy,
float  radius 
) const

Returns a path that represents a circle of the given dimensions.

Parameters
cxThe x-coordinate of the center point
cyThe y-coordinate of the center point
radiusThe circle radius
Returns
a path that represents an circle of the given dimensions.

◆ makeCircle() [3/4]

Path2* cugl::PathFactory::makeCircle ( Path2 path,
const Vec2  center,
float  radius 
) const
inline

Stores a circle in the provided buffer.

The circle will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
centerThe circle center point
radiusThe circle radius
Returns
a reference to the buffer for chaining.

◆ makeCircle() [4/4]

Path2* cugl::PathFactory::makeCircle ( Path2 path,
float  cx,
float  cy,
float  radius 
) const

Stores a circle in the provided buffer.

The circle will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
cxThe x-coordinate of the center point
cyThe y-coordinate of the center point
radiusThe circle radius
Returns
a reference to the buffer for chaining.

◆ makeEllipse() [1/4]

Path2 cugl::PathFactory::makeEllipse ( const Vec2  center,
const Vec2  size 
) const
inline

Returns a path that represents an ellipse of the given dimensions.

Parameters
centerThe ellipse center point
sizeThe size of the ellipse
Returns
a path that represents an ellipse of the given dimensions.

◆ makeEllipse() [2/4]

Path2 cugl::PathFactory::makeEllipse ( float  cx,
float  cy,
float  sx,
float  sy 
) const

Returns a path that represents an ellipse of the given dimensions.

Parameters
cxThe x-coordinate of the center point
cyThe y-coordinate of the center point
sxThe size (diameter) along the x-axis
syThe size (diameter) along the y-axis
Returns
a path that represents an ellipse of the given dimensions.

◆ makeEllipse() [3/4]

Path2* cugl::PathFactory::makeEllipse ( Path2 path,
const Vec2  center,
const Vec2  size 
) const
inline

Stores an ellipse in the provided buffer.

The ellipse will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
centerThe ellipse center point
sizeThe size of the ellipse
Returns
a reference to the buffer for chaining.

◆ makeEllipse() [4/4]

Path2* cugl::PathFactory::makeEllipse ( Path2 path,
float  cx,
float  cy,
float  sx,
float  sy 
) const

Stores an ellipse in the provided buffer.

The ellipse will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
cxThe x-coordinate of the center point
cyThe y-coordinate of the center point
sxThe size (diameter) along the x-axis
syThe size (diameter) along the y-axis
Returns
a reference to the buffer for chaining.

◆ makeLine() [1/4]

Path2 cugl::PathFactory::makeLine ( const Vec2  origin,
const Vec2  dest 
) const
inline

Returns a path that represents a line segment from origin to dest.

Parameters
originThe line origin
destThe line destination
Returns
a path that represents a line segment from origin to dest.

◆ makeLine() [2/4]

Path2 cugl::PathFactory::makeLine ( float  ox,
float  oy,
float  dx,
float  dy 
) const

Returns a path that represents a line segment from origin to dest.

Parameters
oxThe x-coordinate of the origin
oyThe y-coordinate of the origin
dxThe x-coordinate of the destination
dyThe y-coordinate of the destination
Returns
a path that represents a line segment from origin to dest.

◆ makeLine() [3/4]

Path2* cugl::PathFactory::makeLine ( Path2 path,
const Vec2  origin,
const Vec2  dest 
) const
inline

Stores a line segment from origin to dest in the provided buffer.

The line will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
originThe line origin
destThe line destination
Returns
a reference to the buffer for chaining.

◆ makeLine() [4/4]

Path2* cugl::PathFactory::makeLine ( Path2 path,
float  ox,
float  oy,
float  dx,
float  dy 
) const

Stores a line segment from origin to dest in the provided buffer.

The line will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
oxThe x-coordinate of the origin
oyThe y-coordinate of the origin
dxThe x-coordinate of the destination
dyThe y-coordinate of the destination
Returns
a reference to the buffer for chaining.

◆ makeNgon() [1/4]

Path2 cugl::PathFactory::makeNgon ( const Vec2  center,
float  radius,
Uint32  sides 
) const
inline

Returns a path that represents a regular, many-sided polygon.

The polygon will be centered at the given origin with the given radius. A regular polygon is essentially a circle where the number of segments is explicit (instead of implicit from the curve tolerance).

Parameters
centerThe polygon center point
radiusThe polygon radius
sidesThe number of sides
Returns
a path that represents a regular, many-sided polygon.

◆ makeNgon() [2/4]

Path2 cugl::PathFactory::makeNgon ( float  cx,
float  cy,
float  radius,
Uint32  sides 
) const

Returns a path that represents a regular, many-sided polygon.

The polygon will be centered at the given origin with the given radius. A regular polygon is essentially a circle where the number of segments is explicit (instead of implicit from the curve tolerance).

Parameters
cxThe x-coordinate of the center point
cyThe y-coordinate of the center point
radiusThe polygon radius
sidesThe number of sides
Returns
a path that represents a regular, many-sided polygon.

◆ makeNgon() [3/4]

Path2* cugl::PathFactory::makeNgon ( Path2 path,
const Vec2  center,
float  radius,
float  sides 
) const
inline

Stores a regular, many-sided polygon in the provided buffer.

The polygon will be centered at the given origin with the given radius. A regular polygon is essentially a circle where the number of segments is explicit (instead of implicit from the curve tolerance).

The polygon will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
centerThe polygon center point
radiusThe polygon radius
sidesThe number of sides
Returns
a reference to the buffer for chaining.

◆ makeNgon() [4/4]

Path2* cugl::PathFactory::makeNgon ( Path2 path,
float  cx,
float  cy,
float  radius,
Uint32  sides 
) const

Stores a regular, many-sided polygon in the provided buffer.

The polygon will be centered at the given origin with the given radius. A regular polygon is essentially a circle where the number of segments is explicit (instead of implicit from the curve tolerance).

The polygon will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
cxThe x-coordinate of the center point
cyThe y-coordinate of the center point
radiusThe polygon radius
sidesThe number of sides
Returns
a reference to the buffer for chaining.

◆ makeRect() [1/6]

Path2 cugl::PathFactory::makeRect ( const Rect  rect) const
inline

Returns a path that represents a rectangle

Parameters
rectThe rectangle
Returns
a path that represents a rectangle

◆ makeRect() [2/6]

Path2 cugl::PathFactory::makeRect ( const Vec2  origin,
const Vec2  size 
) const
inline

Returns a path that represents a rectangle

Parameters
originThe rectangle origin
sizeThe rectangle size
Returns
a path that represents a rectangle

◆ makeRect() [3/6]

Path2 cugl::PathFactory::makeRect ( float  x,
float  y,
float  w,
float  h 
) const

Returns a path that represents a rectangle

Parameters
xThe x-coordinate of the bottom left corner
yThe y-coordinate of the bottom left corner
wThe rectangle width
hThe rectangle height
Returns
a path that represents a rectangle

◆ makeRect() [4/6]

Path2* cugl::PathFactory::makeRect ( Path2 path,
const Rect  rect 
) const
inline

Stores a rectangle in the provided buffer.

The rectangle will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
rectThe rectangle to create
Returns
a reference to the buffer for chaining.

◆ makeRect() [5/6]

Path2* cugl::PathFactory::makeRect ( Path2 path,
const Vec2  origin,
const Vec2  size 
) const
inline

Stores a rectangle in the provided buffer.

The rectangle will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
originThe rectangle origin
sizeThe rectangle size
Returns
a reference to the buffer for chaining.

◆ makeRect() [6/6]

Path2* cugl::PathFactory::makeRect ( Path2 path,
float  x,
float  y,
float  w,
float  h 
) const

Stores a rectangle in the provided buffer.

The rectangle will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
xThe x-coordinate of the bottom left corner
yThe y-coordinate of the bottom left corner
wThe rectangle width
hThe rectangle height
Returns
a reference to the buffer for chaining.

◆ makeRoundedRect() [1/6]

Path2 cugl::PathFactory::makeRoundedRect ( const Rect  rect,
float  radius 
) const
inline

Returns a path that represents a rounded rectangle of the given dimensions.

The radius should not exceed either half the width or half the height.

Parameters
rectThe enclosing rectangle
radiusThe radius of each corner
Returns
a path that represents a rounded rectangle of the given dimensions.

◆ makeRoundedRect() [2/6]

Path2 cugl::PathFactory::makeRoundedRect ( const Vec2  origin,
const Size  size,
float  radius 
) const
inline

Returns a path that represents a rounded rectangle of the given dimensions.

The radius should not exceed either half the width or half the height.

Parameters
originThe enclosing rectangle origin
sizeThe enclosing rectangle size
radiusThe radius of each corner
Returns
a path that represents a rounded rectangle of the given dimensions.

◆ makeRoundedRect() [3/6]

Path2 cugl::PathFactory::makeRoundedRect ( float  x,
float  y,
float  w,
float  h,
float  r 
) const

Returns a path that represents a rounded rectangle of the given dimensions.

The radius should not exceed either half the width or half the height.

Parameters
xThe x-coordinate of the bottom left corner of the bounding box
yThe y-coordinate of the bottom left corner of the bounding box
wThe rectangle width
hThe rectangle height
rThe radius of each corner
Returns
a path that represents a rounded rectangle of the given dimensions.

◆ makeRoundedRect() [4/6]

Path2* cugl::PathFactory::makeRoundedRect ( Path2 path,
const Rect  rect,
float  radius 
) const
inline

Stores a rounded rectangle in the provided buffer.

The radius should not exceed either half the width or half the height.

The rounded rectangle will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
rectThe enclosing rectangle
radiusThe radius of each corner
Returns
a reference to the buffer for chaining.

◆ makeRoundedRect() [5/6]

Path2* cugl::PathFactory::makeRoundedRect ( Path2 path,
const Vec2  origin,
const Size  size,
float  radius 
) const
inline

Stores a rounded rectangle in the provided buffer.

The radius should not exceed either half the width or half the height.

The rounded rectangle will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
originThe enclosing rectangle origin
sizeThe enclosing rectangle size
radiusThe radius of each corner
Returns
a reference to the buffer for chaining.

◆ makeRoundedRect() [6/6]

Path2* cugl::PathFactory::makeRoundedRect ( Path2 path,
float  x,
float  y,
float  w,
float  h,
float  r 
) const

Stores a rounded rectangle in the provided buffer.

The radius should not exceed either half the width or half the height.

The rounded rectangle will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
xThe x-coordinate of the bottom left corner of the bounding box
yThe y-coordinate of the bottom left corner of the bounding box
wThe rectangle width
hThe rectangle height
rThe radius of each corner
Returns
a reference to the buffer for chaining.

◆ makeTraversal() [1/2]

std::vector<Path2> cugl::PathFactory::makeTraversal ( const Poly2 src,
poly2::Traversal  type 
) const

Returns a path set representing a wire frame of an existing polygon.

Traversals generate not just one path, but a sequence of paths (which may all be either open or closed). This method provides four types of traversals: NONE, OPEN, CLOSED and INTERIOR. The open and closed traversals apply to the boundary of the polygon. If there is more than one boundary, then each boundary is traversed separately.

The interior traversal creates a wire frame a polygon triangulation. That means it will generate a separate path for each triangle.

Parameters
srcThe source polygon to traverse
typeThe traversal type
Returns
a path set representing a wire frame of an existing polygon.

◆ makeTraversal() [2/2]

std::vector<Path2>* cugl::PathFactory::makeTraversal ( std::vector< Path2 > *  paths,
const Poly2 src,
poly2::Traversal  type 
) const

Stores a wire frame of an existing polygon in the provided buffer.

Traversals generate not just one path, but a sequence of paths (which may all be either open or closed). This method provides four types of traversals: NONE, OPEN, CLOSED and INTERIOR. The open and closed traversals apply to the boundary of the polygon. If there is more than one boundary, then each boundary is traversed separately.

The interior traversal creates a wire frame a polygon triangulation. That means it will generate a separate path for each triangle.

The traversal will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathsThe container to store the result
srcThe source polygon to traverse
typeThe traversal type
Returns
a reference to the buffer for chaining.

◆ makeTriangle() [1/4]

Path2 cugl::PathFactory::makeTriangle ( const Vec2  a,
const Vec2  b,
const Vec2  c 
) const
inline

Returns a path that represents a simple triangle.

Parameters
aThe first vertex.
bThe second vertex.
cThe third vertex.
Returns
a path that represents a simple triangle.

◆ makeTriangle() [2/4]

Path2 cugl::PathFactory::makeTriangle ( float  ax,
float  ay,
float  bx,
float  by,
float  cx,
float  cy 
) const

Returns a path that represents a simple triangle.

Parameters
axThe x-coordinate of the first vertex.
ayThe y-coordinate of the first vertex.
bxThe x-coordinate of the second vertex.
byThe y-coordinate of the second vertex.
cxThe x-coordinate of the third vertex.
cyThe y-coordinate of the third vertex.
Returns
a path that represents a simple triangle.

◆ makeTriangle() [3/4]

Path2* cugl::PathFactory::makeTriangle ( Path2 path,
const Vec2  a,
const Vec2  b,
const Vec2  c 
) const
inline

Stores a simple triangle in the provided buffer.

The triangle will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
aThe first vertex
bThe second vertex
cThe third vertex
Returns
a reference to the buffer for chaining.

◆ makeTriangle() [4/4]

Path2* cugl::PathFactory::makeTriangle ( Path2 path,
float  ax,
float  ay,
float  bx,
float  by,
float  cx,
float  cy 
) const

Stores a simple triangle in the provided buffer.

The triangle will be appended to the buffer. You should clear the buffer first if you do not want to preserve the original data.

Parameters
pathThe path to store the result
axThe x-coordinate of the first vertex
ayThe y-coordinate of the first vertex
bxThe x-coordinate of the second vertex
byThe y-coordinate of the second vertex
cxThe x-coordinate of the third vertex
cyThe y-coordinate of the third vertex
Returns
a reference to the buffer for chaining.

◆ setTolerance()

void cugl::PathFactory::setTolerance ( float  tol)
inline

Sets the curve tolerance for rounded shapes.

The tolerance guarantees that curved shapes have enough segments so that any points on the true shape are always within tolerance of the segmented approximation.

Rounded shapes include makeEllipse, makeCircle, makeArc, and makeRoundedRect.

Parameters
tolThe curve tolerance for rounded shapes.

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