JUCE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
PathFlatteningIterator Class Reference

Flattens a Path object into a series of straight-line sections. More...

Public Member Functions

 PathFlatteningIterator (const Path &path, const AffineTransform &transform=AffineTransform::identity, float tolerance=defaultTolerance)
 Creates a PathFlatteningIterator.
 
 ~PathFlatteningIterator ()
 Destructor.
 
bool next ()
 Fetches the next line segment from the path.
 
bool isLastInSubpath () const noexcept
 Returns true if the current segment is the last in the current sub-path.
 

Public Attributes

float x1
 The x position of the start of the current line segment.
 
float y1
 The y position of the start of the current line segment.
 
float x2
 The x position of the end of the current line segment.
 
float y2
 The y position of the end of the current line segment.
 
bool closesSubPath
 Indicates whether the current line segment is closing a sub-path.
 
int subPathIndex
 The index of the current line within the current sub-path.
 

Static Public Attributes

static const float defaultTolerance
 This is the default value that should be used for the tolerance value (see the constructor parameters).
 

Detailed Description

Flattens a Path object into a series of straight-line sections.

Use one of these to iterate through a Path object, and it will convert all the curves into line sections so it's easy to render or perform geometric operations on.

See Also
Path

Constructor & Destructor Documentation

PathFlatteningIterator::PathFlatteningIterator ( const Path path,
const AffineTransform transform = AffineTransform::identity,
float  tolerance = defaultTolerance 
)

Creates a PathFlatteningIterator.

After creation, use the next() method to initialise the fields in the object with the first line's position.

Parameters
paththe path to iterate along
transforma transform to apply to each point in the path being iterated
tolerancethe amount by which the curves are allowed to deviate from the lines into which they are being broken down - a higher tolerance contains less lines, so can be generated faster, but will be less smooth.
PathFlatteningIterator::~PathFlatteningIterator ( )

Destructor.

Member Function Documentation

bool PathFlatteningIterator::next ( )

Fetches the next line segment from the path.

This will update the member variables x1, y1, x2, y2, subPathIndex and closesSubPath so that they describe the new line segment.

Returns
false when there are no more lines to fetch.
bool PathFlatteningIterator::isLastInSubpath ( ) const
noexcept

Returns true if the current segment is the last in the current sub-path.

Member Data Documentation

float PathFlatteningIterator::x1

The x position of the start of the current line segment.

float PathFlatteningIterator::y1

The y position of the start of the current line segment.

float PathFlatteningIterator::x2

The x position of the end of the current line segment.

float PathFlatteningIterator::y2

The y position of the end of the current line segment.

bool PathFlatteningIterator::closesSubPath

Indicates whether the current line segment is closing a sub-path.

If the current line is the one that connects the end of a sub-path back to the start again, this will be true.

int PathFlatteningIterator::subPathIndex

The index of the current line within the current sub-path.

E.g. you can use this to see whether the line is the first one in the subpath by seeing if it's 0.

const float PathFlatteningIterator::defaultTolerance
static

This is the default value that should be used for the tolerance value (see the constructor parameters).


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