40 : thickness (
other.thickness),
41 jointStyle (
other.jointStyle),
42 endStyle (
other.endStyle)
48 thickness =
other.thickness;
49 jointStyle =
other.jointStyle;
50 endStyle =
other.endStyle;
60 const auto tie = [] (
const PathStrokeType& p) {
return std::tie (p.thickness, p.jointStyle, p.endStyle); };
61 return tie (*
this) == tie (
other);
66 return ! operator== (
other);
70namespace PathStrokeHelpers
75 float distanceBeyondLine1EndSquared;
80 const float x2,
const float y2,
81 const float x3,
const float y3,
82 const float x4,
const float y4)
86 const auto dx1 = x2 - x1;
87 const auto dy1 = y2 -
y1;
88 const auto dx2 =
x4 - x3;
89 const auto dy2 =
y4 - y3;
104 const auto distanceBeyondLine1EndSquared = (x2 > x1) == (
intersectionX < x2)
109 distanceBeyondLine1EndSquared,
123 distanceBeyondLine1EndSquared,
134 const auto distanceBeyondLine1EndSquared = (y2 >
y1) == (
intersectionY < y2)
139 distanceBeyondLine1EndSquared,
153 distanceBeyondLine1EndSquared,
161 const auto distanceBeyondLine1EndSquared = 0.0f;
164 distanceBeyondLine1EndSquared,
189 distanceBeyondLine1EndSquared,
193 return { Point { x2, y2 }, 0.0f,
true };
196 static void addEdgeAndJoint (Path&
destPath,
199 const float x1,
const float y1,
200 const float x2,
const float y2,
201 const float x3,
const float y3,
202 const float x4,
const float y4,
214 const auto intersection = lineIntersection (x1, y1, x2, y2, x3, y3,
x4,
y4);
289 static void addLineEnd (Path&
destPath,
291 const float x1,
const float y1,
292 const float x2,
const float y2,
314 auto offset = width / len;
350 float startWidth, startLength;
351 float endWidth, endLength;
355 const float x1,
const float y1,
356 const float x2,
const float y2,
370 float x1,
y1, x2, y2;
371 float lx1, ly1, lx2, ly2;
372 float rx1, ry1, rx2, ry2;
380 auto dx =
l.rx2 -
l.rx1;
381 auto dy =
l.ry2 -
l.ry1;
408 auto dx =
l.rx2 -
l.rx1;
409 auto dy =
l.ry2 -
l.ry1;
444 auto& firstLine =
subPath.getReference (0);
446 auto lastX1 = firstLine.lx1;
447 auto lastY1 = firstLine.ly1;
448 auto lastX2 = firstLine.lx2;
449 auto lastY2 = firstLine.ly2;
457 destPath.startNewSubPath (firstLine.rx2, firstLine.ry2);
460 addArrowhead (
destPath, firstLine.rx2, firstLine.ry2,
lastX1,
lastY1, firstLine.x1, firstLine.y1,
466 for (
int i = 1; i <
subPath.size(); ++i)
468 const LineSection&
l =
subPath.getReference (i);
470 addEdgeAndJoint (
destPath, jointStyle,
473 l.lx1,
l.ly1,
l.lx2,
l.ly2,
488 addEdgeAndJoint (
destPath, jointStyle,
491 l.lx1,
l.ly1,
l.lx2,
l.ly2,
513 for (
int i =
subPath.size() - 1; --i >= 0;)
517 addEdgeAndJoint (
destPath, jointStyle,
520 l.rx1,
l.ry1,
l.rx2,
l.ry2,
531 addEdgeAndJoint (
destPath, jointStyle,
549 const AffineTransform& transform,
573 destPath.setUsingNonZeroWinding (
true);
576 const float width = 0.5f * thickness;
583 subPath.ensureStorageAllocated (512);
592 if (
it.subPathIndex == 0)
607 float dx =
l.x2 -
l.x1;
608 float dy =
l.y2 -
l.y1;
618 l.rx1 =
l.rx2 =
l.lx1 =
l.lx2 =
l.x1;
619 l.ry1 =
l.ry2 =
l.ly1 =
l.ly2 =
l.y1;
623 auto offset = width / len;
640 if (
it.closesSubPath)
661 PathStrokeHelpers::createStroke (thickness, jointStyle, endStyle,
destPath,
sourcePath,
667 const float* dashLengths,
683 float dx = 0.0f, dy = 0.0f;
716 first =
it.closesSubPath;
743 PathStrokeHelpers::createStroke (thickness, jointStyle, endStyle,
Holds a resizable array of primitive or copy-by-value objects.
Flattens a Path object into a series of straight-line sections.
Describes a type of stroke used to render a solid outline along a path.
bool operator==(const PathStrokeType &) const noexcept
Compares the stroke thickness, joint and end styles of two stroke types.
JointStyle
The type of shape to use for the corners between two adjacent line segments.
@ beveled
Indicates that corners should be drawn with a line flattening their outside edge.
@ mitered
Indicates that corners should be drawn with sharp joints.
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.
PathStrokeType(float strokeThickness) noexcept
Creates a stroke type with a given line-width, and default joint/end styles.
EndCapStyle
The type shape to use for the ends of lines.
@ square
Ends of lines are flat, but stick out beyond the end point for half the thickness of the stroke.
@ butt
Ends of lines are flat and don't extend beyond the end point.
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.
bool operator!=(const PathStrokeType &) const noexcept
Compares the stroke thickness, joint and end styles of two stroke types.
~PathStrokeType() noexcept
Destructor.
PathStrokeType & operator=(const PathStrokeType &) noexcept
Copies another stroke onto this one.
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.
A path is a sequence of lines and curves that may either form a closed shape or be open-ended.
A pair of (x, y) coordinates.
constexpr bool approximatelyEqual(Type a, Type b, Tolerance< Type > tolerance=Tolerance< Type >{} .withAbsolute(std::numeric_limits< Type >::min()) .withRelative(std::numeric_limits< Type >::epsilon()))
Returns true if the two floating-point numbers are approximately equal.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
RangedDirectoryIterator end(const RangedDirectoryIterator &)
Returns a default-constructed sentinel value.
constexpr NumericType square(NumericType n) noexcept
Returns the square of its argument.
Type juce_hypot(Type a, Type b) noexcept
Using juce_hypot is easier than dealing with the different types of hypot function that are provided ...
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
static constexpr FloatType twoPi
A predefined value for 2 * Pi.
static constexpr FloatType pi
A predefined value for Pi.