JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::PathFlatteningIterator Class Referencefinal

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

#include <juce_PathIterator.h>

Collaboration diagram for juce::PathFlatteningIterator:

Public Member Functions

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

Public Attributes

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

Private Attributes

const bool isIdentityTransform
 
const Pathpath
 
const floatsource
 
HeapBlock< floatstackBase { 32 }
 
floatstackPos
 
size_t stackSize = 32
 
float subPathCloseX = 0
 
float subPathCloseY = 0
 
const float toleranceSquared
 
const AffineTransform transform
 

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

{Graphics}

Constructor & Destructor Documentation

◆ PathFlatteningIterator()

juce::PathFlatteningIterator::PathFlatteningIterator ( const Path path,
const AffineTransform transform = AffineTransform(),
float  tolerance = Path::defaultToleranceForMeasurement 
)

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()

juce::PathFlatteningIterator::~PathFlatteningIterator ( )

Destructor.

Member Function Documentation

◆ isLastInSubpath()

bool juce::PathFlatteningIterator::isLastInSubpath ( ) const
noexcept

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

◆ next()

bool juce::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.

Member Data Documentation

◆ closesSubPath

bool juce::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.

◆ isIdentityTransform

const bool juce::PathFlatteningIterator::isIdentityTransform
private

◆ path

const Path& juce::PathFlatteningIterator::path
private

◆ source

const float* juce::PathFlatteningIterator::source
private

◆ stackBase

HeapBlock<float> juce::PathFlatteningIterator::stackBase { 32 }
private

◆ stackPos

float* juce::PathFlatteningIterator::stackPos
private

◆ stackSize

size_t juce::PathFlatteningIterator::stackSize = 32
private

◆ subPathCloseX

float juce::PathFlatteningIterator::subPathCloseX = 0
private

◆ subPathCloseY

float juce::PathFlatteningIterator::subPathCloseY = 0
private

◆ subPathIndex

int juce::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.

◆ toleranceSquared

const float juce::PathFlatteningIterator::toleranceSquared
private

◆ transform

const AffineTransform juce::PathFlatteningIterator::transform
private

◆ x1

float juce::PathFlatteningIterator::x1

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

◆ x2

float juce::PathFlatteningIterator::x2

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

◆ y1

float juce::PathFlatteningIterator::y1

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

◆ y2

float juce::PathFlatteningIterator::y2

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


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