JUCE  v5.1.1-3-g1a0b28c73
JUCE API
PathStrokeType Class Reference

Describes a type of stroke used to render a solid outline along a path. More...

#include <juce_PathStrokeType.h>

Collaboration diagram for PathStrokeType:

Public Types

enum  EndCapStyle {
  butt,
  square,
  rounded
}
 The type shape to use for the ends of lines. More...
 
enum  JointStyle {
  mitered,
  curved,
  beveled
}
 The type of shape to use for the corners between two adjacent line segments. More...
 

Public Member Functions

 PathStrokeType (float strokeThickness) noexcept
 Creates a stroke type with a given line-width, and default joint/end styles. More...
 
 PathStrokeType (float strokeThickness, JointStyle jointStyle, EndCapStyle endStyle=butt) noexcept
 Creates a stroke type. More...
 
 PathStrokeType (const PathStrokeType &) noexcept
 Creates a copy of another stroke type. More...
 
 ~PathStrokeType () noexcept
 Destructor. More...
 
void createDashedStroke (Path &destPath, const Path &sourcePath, const float *dashLengths, int numDashLengths, const AffineTransform &transform=AffineTransform(), float extraAccuracy=1.0f) const
 Applies this stroke type to a path, creating a dashed line. More...
 
void createStrokedPath (Path &destPath, const Path &sourcePath, const AffineTransform &transform=AffineTransform(), float extraAccuracy=1.0f) const
 Applies this stroke type to a path and returns the resultant stroke as another Path. More...
 
void createStrokeWithArrowheads (Path &destPath, const Path &sourcePath, float arrowheadStartWidth, float arrowheadStartLength, float arrowheadEndWidth, float arrowheadEndLength, const AffineTransform &transform=AffineTransform(), float extraAccuracy=1.0f) const
 Applies this stroke type to a path and returns the resultant stroke as another Path. More...
 
EndCapStyle getEndStyle () const noexcept
 Returns the end-cap style. More...
 
JointStyle getJointStyle () const noexcept
 Returns the joint style. More...
 
float getStrokeThickness () const noexcept
 Returns the stroke thickness. More...
 
bool operator!= (const PathStrokeType &) const noexcept
 Compares the stroke thickness, joint and end styles of two stroke types. More...
 
PathStrokeTypeoperator= (const PathStrokeType &) noexcept
 Copies another stroke onto this one. More...
 
bool operator== (const PathStrokeType &) const noexcept
 Compares the stroke thickness, joint and end styles of two stroke types. More...
 
void setEndStyle (EndCapStyle newStyle) noexcept
 Sets the end-cap style. More...
 
void setJointStyle (JointStyle newStyle) noexcept
 Sets the joint style. More...
 
void setStrokeThickness (float newThickness) noexcept
 Sets the stroke thickness. More...
 

Private Attributes

EndCapStyle endStyle
 
JointStyle jointStyle
 
float thickness
 

Detailed Description

Describes a type of stroke used to render a solid outline along a path.

A PathStrokeType object can be used directly to create the shape of an outline around a path, and is used by Graphics::strokePath to specify the type of stroke to draw.

See also
Path, Graphics::strokePath

Member Enumeration Documentation

◆ EndCapStyle

The type shape to use for the ends of lines.

Enumerator
butt 

Ends of lines are flat and don't extend beyond the end point.

square 

Ends of lines are flat, but stick out beyond the end point for half the thickness of the stroke.

rounded 

Ends of lines are rounded-off with a circular shape.

◆ JointStyle

The type of shape to use for the corners between two adjacent line segments.

Enumerator
mitered 

Indicates that corners should be drawn with sharp joints.

Note that for angles that curve back on themselves, drawing a mitre could require extending the point too far away from the path, so a mitre limit is imposed and any corners that exceed it are drawn as bevelled instead.

curved 

Indicates that corners should be drawn as rounded-off.

beveled 

Indicates that corners should be drawn with a line flattening their outside edge.

Constructor & Destructor Documentation

◆ PathStrokeType() [1/3]

PathStrokeType::PathStrokeType ( float  strokeThickness)
explicitnoexcept

Creates a stroke type with a given line-width, and default joint/end styles.

◆ PathStrokeType() [2/3]

PathStrokeType::PathStrokeType ( float  strokeThickness,
JointStyle  jointStyle,
EndCapStyle  endStyle = butt 
)
noexcept

Creates a stroke type.

Parameters
strokeThicknessthe width of the line to use
jointStylethe type of joints to use for corners
endStylethe type of end-caps to use for the ends of open paths.

◆ PathStrokeType() [3/3]

PathStrokeType::PathStrokeType ( const PathStrokeType )
noexcept

Creates a copy of another stroke type.

◆ ~PathStrokeType()

PathStrokeType::~PathStrokeType ( )
noexcept

Destructor.

Member Function Documentation

◆ createDashedStroke()

void PathStrokeType::createDashedStroke ( Path destPath,
const Path sourcePath,
const float *  dashLengths,
int  numDashLengths,
const AffineTransform transform = AffineTransform(),
float  extraAccuracy = 1.0f 
) const

Applies this stroke type to a path, creating a dashed line.

This is similar to createStrokedPath, but uses the array passed in to break the stroke up into a series of dashes.

Parameters
destPaththe resultant stroked outline shape will be copied into this path. Note that it's ok for the source and destination Paths to be the same object, so you can easily turn a path into a stroked version of itself.
sourcePaththe path to use as the source
dashLengthsAn array of alternating on/off lengths. E.g. { 2, 3, 4, 5 } will create a line of length 2, then skip a length of 3, then add a line of length 4, skip 5, and keep repeating this pattern.
numDashLengthsThe number of lengths in the dashLengths array. This should really be an even number, otherwise the pattern will get out of step as it repeats.
transforman optional transform to apply to the points from the source path as they are being used
extraAccuracyif this is greater than 1.0, it will subdivide the path to a higher resolution, which improves the quality if you'll later want to enlarge the stroked path. So for example, if you're planning on drawing the stroke at 3x the size that you're creating it, you should set this to 3.

◆ createStrokedPath()

void PathStrokeType::createStrokedPath ( Path destPath,
const Path sourcePath,
const AffineTransform transform = AffineTransform(),
float  extraAccuracy = 1.0f 
) const

Applies this stroke type to a path and returns the resultant stroke as another Path.

Parameters
destPaththe resultant stroked outline shape will be copied into this path. Note that it's ok for the source and destination Paths to be the same object, so you can easily turn a path into a stroked version of itself.
sourcePaththe path to use as the source
transforman optional transform to apply to the points from the source path as they are being used
extraAccuracyif this is greater than 1.0, it will subdivide the path to a higher resolution, which improves the quality if you'll later want to enlarge the stroked path. So for example, if you're planning on drawing the stroke at 3x the size that you're creating it, you should set this to 3.
See also
createDashedStroke

◆ createStrokeWithArrowheads()

void PathStrokeType::createStrokeWithArrowheads ( Path destPath,
const Path sourcePath,
float  arrowheadStartWidth,
float  arrowheadStartLength,
float  arrowheadEndWidth,
float  arrowheadEndLength,
const AffineTransform transform = AffineTransform(),
float  extraAccuracy = 1.0f 
) const

Applies this stroke type to a path and returns the resultant stroke as another Path.

Parameters
destPaththe resultant stroked outline shape will be copied into this path. Note that it's ok for the source and destination Paths to be the same object, so you can easily turn a path into a stroked version of itself.
sourcePaththe path to use as the source
arrowheadStartWidththe width of the arrowhead at the start of the path
arrowheadStartLengththe length of the arrowhead at the start of the path
arrowheadEndWidththe width of the arrowhead at the end of the path
arrowheadEndLengththe length of the arrowhead at the end of the path
transforman optional transform to apply to the points from the source path as they are being used
extraAccuracyif this is greater than 1.0, it will subdivide the path to a higher resolution, which improves the quality if you'll later want to enlarge the stroked path. So for example, if you're planning on drawing the stroke at 3x the size that you're creating it, you should set this to 3.
See also
createDashedStroke

◆ getEndStyle()

EndCapStyle PathStrokeType::getEndStyle ( ) const
inlinenoexcept

Returns the end-cap style.

◆ getJointStyle()

JointStyle PathStrokeType::getJointStyle ( ) const
inlinenoexcept

Returns the joint style.

◆ getStrokeThickness()

float PathStrokeType::getStrokeThickness ( ) const
inlinenoexcept

Returns the stroke thickness.

◆ operator!=()

bool PathStrokeType::operator!= ( const PathStrokeType ) const
noexcept

Compares the stroke thickness, joint and end styles of two stroke types.

◆ operator=()

PathStrokeType& PathStrokeType::operator= ( const PathStrokeType )
noexcept

Copies another stroke onto this one.

◆ operator==()

bool PathStrokeType::operator== ( const PathStrokeType ) const
noexcept

Compares the stroke thickness, joint and end styles of two stroke types.

◆ setEndStyle()

void PathStrokeType::setEndStyle ( EndCapStyle  newStyle)
inlinenoexcept

Sets the end-cap style.

References operator!=(), and operator==().

◆ setJointStyle()

void PathStrokeType::setJointStyle ( JointStyle  newStyle)
inlinenoexcept

Sets the joint style.

◆ setStrokeThickness()

void PathStrokeType::setStrokeThickness ( float  newThickness)
inlinenoexcept

Sets the stroke thickness.

Member Data Documentation

◆ endStyle

EndCapStyle PathStrokeType::endStyle
private

◆ jointStyle

JointStyle PathStrokeType::jointStyle
private

◆ thickness

float PathStrokeType::thickness
private

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