67 return ! operator== (other);
74 const float x2,
const float y2,
75 const float x3,
const float y3,
76 const float x4,
const float y4,
79 float& distanceBeyondLine1EndSquared)
noexcept
81 if (x2 != x3 || y2 != y3)
87 auto divisor = dx1 * dy2 - dx2 * dy1;
91 if (! ((dx1 == 0.0f && dy1 == 0.0f) || (dx2 == 0.0f && dy2 == 0.0f)))
93 if (dy1 == 0.0f && dy2 != 0.0f)
95 auto along = (y1 - y3) / dy2;
96 intersectionX = x3 + along * dx2;
99 distanceBeyondLine1EndSquared = intersectionX - x2;
100 distanceBeyondLine1EndSquared *= distanceBeyondLine1EndSquared;
101 if ((x2 > x1) == (intersectionX < x2))
102 distanceBeyondLine1EndSquared = -distanceBeyondLine1EndSquared;
104 return along >= 0 && along <= 1.0f;
107 if (dy2 == 0.0f && dy1 != 0.0f)
109 auto along = (y3 - y1) / dy1;
110 intersectionX = x1 + along * dx1;
113 distanceBeyondLine1EndSquared = (along - 1.0f) * dx1;
114 distanceBeyondLine1EndSquared *= distanceBeyondLine1EndSquared;
116 distanceBeyondLine1EndSquared = -distanceBeyondLine1EndSquared;
118 return along >= 0 && along <= 1.0f;
121 if (dx1 == 0.0f && dx2 != 0.0f)
123 auto along = (x1 - x3) / dx2;
125 intersectionY = y3 + along * dy2;
127 distanceBeyondLine1EndSquared = intersectionY - y2;
128 distanceBeyondLine1EndSquared *= distanceBeyondLine1EndSquared;
130 if ((y2 > y1) == (intersectionY < y2))
131 distanceBeyondLine1EndSquared = -distanceBeyondLine1EndSquared;
133 return along >= 0 && along <= 1.0f;
136 if (dx2 == 0.0f && dx1 != 0.0f)
138 auto along = (x3 - x1) / dx1;
140 intersectionY = y1 + along * dy1;
142 distanceBeyondLine1EndSquared = (along - 1.0f) * dy1;
143 distanceBeyondLine1EndSquared *= distanceBeyondLine1EndSquared;
145 distanceBeyondLine1EndSquared = -distanceBeyondLine1EndSquared;
147 return along >= 0 && along <= 1.0f;
151 intersectionX = 0.5f * (x2 + x3);
152 intersectionY = 0.5f * (y2 + y3);
154 distanceBeyondLine1EndSquared = 0.0f;
158 auto along1 = ((y1 - y3) * dx2 - (x1 - x3) * dy2) / divisor;
160 intersectionX = x1 + along1 * dx1;
161 intersectionY = y1 + along1 * dy1;
163 if (along1 >= 0 && along1 <= 1.0f)
165 auto along2 = ((y1 - y3) * dx1 - (x1 - x3) * dy1) / divisor;
167 if (along2 >= 0 && along2 <= 1.0f)
169 distanceBeyondLine1EndSquared = 0.0f;
174 distanceBeyondLine1EndSquared = along1 - 1.0f;
175 distanceBeyondLine1EndSquared *= distanceBeyondLine1EndSquared;
176 distanceBeyondLine1EndSquared *= (dx1 * dx1 + dy1 * dy1);
179 distanceBeyondLine1EndSquared = -distanceBeyondLine1EndSquared;
187 distanceBeyondLine1EndSquared = 0.0f;
193 const float maxMiterExtensionSquared,
const float width,
194 const float x1,
const float y1,
195 const float x2,
const float y2,
196 const float x3,
const float y3,
197 const float x4,
const float y4,
198 const float midX,
const float midY)
201 || (x3 == x4 && y3 == y4)
202 || (x1 == x2 && y1 == y2))
209 float jx, jy, distanceBeyondLine1EndSquared;
214 jx, jy, distanceBeyondLine1EndSquared))
222 if (distanceBeyondLine1EndSquared < maxMiterExtensionSquared
223 && distanceBeyondLine1EndSquared > 0.0f)
237 float angle1 = std::atan2 (x2 - midX, y2 - midY);
238 float angle2 = std::atan2 (x3 - midX, y3 - midY);
239 const float angleIncrement = 0.1f;
243 if (std::abs (angle1 - angle2) > angleIncrement)
253 angle1 -= angleIncrement;
254 while (angle1 > angle2)
257 midY +
width * std::cos (angle1));
259 angle1 -= angleIncrement;
269 angle1 += angleIncrement;
270 while (angle1 < angle2)
273 midY +
width * std::cos (angle1));
275 angle1 += angleIncrement;
288 const float x1,
const float y1,
289 const float x2,
const float y2,
298 float offx1, offy1, offx2, offy2;
311 auto offset =
width / len;
324 destPath.
lineTo (offx1, offy1);
325 destPath.
lineTo (offx2, offy2);
331 auto midx = (offx1 + offx2) * 0.5f;
332 auto midy = (offy1 + offy2) * 0.5f;
334 destPath.
cubicTo (x1 + (offx1 - x1) * 0.55f, y1 + (offy1 - y1) * 0.55f,
335 offx1 + (midx - offx1) * 0.45f, offy1 + (midy - offy1) * 0.45f,
338 destPath.
cubicTo (midx + (offx2 - midx) * 0.55f, midy + (offy2 - midy) * 0.55f,
339 offx2 + (x2 - offx2) * 0.45f, offy2 + (y2 - offy2) * 0.45f,
352 const float x1,
const float y1,
353 const float x2,
const float y2,
354 const float tipX,
const float tipY,
356 const float arrowheadWidth)
360 destPath.
lineTo (tipX, tipY);
374 while (amountAtEnd > 0 && subPath.
size() > 0)
377 auto dx =
l.rx2 -
l.rx1;
378 auto dy =
l.ry2 -
l.ry1;
381 if (len <= amountAtEnd && subPath.
size() > 1)
391 auto prop =
jmin (0.9999f, amountAtEnd / len);
402 while (amountAtStart > 0 && subPath.
size() > 0)
405 auto dx =
l.rx2 -
l.rx1;
406 auto dy =
l.ry2 -
l.ry1;
409 if (len <= amountAtStart && subPath.
size() > 1)
415 amountAtStart -= len;
419 auto prop =
jmin (0.9999f, amountAtStart / len);
432 const bool isClosed,
const float width,
const float maxMiterExtensionSquared,
438 if (arrowhead !=
nullptr)
443 auto lastX1 = firstLine.lx1;
444 auto lastY1 = firstLine.ly1;
445 auto lastX2 = firstLine.lx2;
446 auto lastY2 = firstLine.ly2;
456 if (arrowhead !=
nullptr && arrowhead->
startWidth > 0.0f)
457 addArrowhead (destPath, firstLine.rx2, firstLine.ry2, lastX1, lastY1, firstLine.x1, firstLine.y1,
460 addLineEnd (destPath, endStyle, firstLine.rx2, firstLine.ry2, lastX1, lastY1,
width);
463 for (
int i = 1;
i < subPath.
size(); ++
i)
468 maxMiterExtensionSquared,
width,
469 lastX1, lastY1, lastX2, lastY2,
470 l.lx1,
l.ly1,
l.lx2,
l.ly2,
486 maxMiterExtensionSquared,
width,
487 lastX1, lastY1, lastX2, lastY2,
488 l.lx1,
l.ly1,
l.lx2,
l.ly2,
496 destPath.
lineTo (lastX2, lastY2);
498 if (arrowhead !=
nullptr && arrowhead->
endWidth > 0.0f)
499 addArrowhead (destPath, lastX2, lastY2, lastLine.rx1, lastLine.ry1, lastLine.x2, lastLine.y2,
502 addLineEnd (destPath, endStyle, lastX2, lastY2, lastLine.rx1, lastLine.ry1,
width);
505 lastX1 = lastLine.rx1;
506 lastY1 = lastLine.ry1;
507 lastX2 = lastLine.rx2;
508 lastY2 = lastLine.ry2;
510 for (
int i = subPath.
size() - 1; --
i >= 0;)
515 maxMiterExtensionSquared,
width,
516 lastX1, lastY1, lastX2, lastY2,
517 l.rx1,
l.ry1,
l.rx2,
l.ry2,
529 maxMiterExtensionSquared,
width,
530 lastX1, lastY1, lastX2, lastY2,
531 lastLine.rx1, lastLine.ry1, lastLine.rx2, lastLine.ry2,
532 lastLine.x2, lastLine.y2);
537 destPath.
lineTo (lastX2, lastY2);
547 const float extraAccuracy,
const Arrowhead*
const arrowhead)
557 const Path* sourcePath = &source;
560 if (sourcePath == &destPath)
572 const float maxMiterExtensionSquared = 9.0f * thickness * thickness;
573 const float width = 0.5f * thickness;
585 const float minSegmentLength = 0.0001f;
591 if (subPath.
size() > 0)
593 addSubPath (destPath, subPath,
false,
width, maxMiterExtensionSquared, jointStyle, endStyle, arrowhead);
604 float dx =
l.x2 -
l.x1;
605 float dy =
l.y2 -
l.y1;
607 auto hypotSquared = dx * dx +
dy *
dy;
611 auto len = std::sqrt (hypotSquared);
615 l.rx1 =
l.rx2 =
l.lx1 =
l.lx2 =
l.x1;
616 l.ry1 =
l.ry2 =
l.ly1 =
l.ly2 =
l.y1;
620 auto offset =
width / len;
639 addSubPath (destPath, subPath,
true,
width, maxMiterExtensionSquared, jointStyle, endStyle, arrowhead);
650 if (subPath.
size() > 0)
651 addSubPath (destPath, subPath,
false,
width, maxMiterExtensionSquared, jointStyle, endStyle, arrowhead);
659 transform, extraAccuracy,
nullptr);
663 const Path& sourcePath,
664 const float* dashLengths,
667 float extraAccuracy)
const
679 float pos = 0.0f, lineLen = 0.0f, lineEndPos = 0.0f;
680 float dx = 0.0f,
dy = 0.0f;
684 const bool isSolid = ((dashNum & 1) == 0);
685 const float dashLen = dashLengths [dashNum++ % numDashLengths];
693 while (pos > lineEndPos)
697 if (isSolid && ! first)
704 if (isSolid && ! first)
712 lineEndPos += lineLen;
716 const float alpha = (pos - (lineEndPos - lineLen)) / lineLen;
719 newDestPath.
lineTo (it.
x1 + dx * alpha,
728 const Path& sourcePath,
729 const float arrowheadStartWidth,
const float arrowheadStartLength,
730 const float arrowheadEndWidth,
const float arrowheadEndLength,
732 const float extraAccuracy)
const
735 head.startWidth = arrowheadStartWidth;
736 head.startLength = arrowheadStartLength;
737 head.endWidth = arrowheadEndWidth;
738 head.endLength = arrowheadEndLength;
741 destPath, sourcePath, transform, extraAccuracy, &
head);
Type jmin(const Type a, const Type b)
Definition MathsFunctions.h:60
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_Array.h:56
void removeLast(int howManyToRemove=1)
Definition juce_Array.h:939
void ensureStorageAllocated(int minNumElements)
Definition juce_Array.h:1065
void clearQuick()
Definition juce_Array.h:198
int size() const noexcept
Definition juce_Array.h:215
void remove(int indexToRemove)
Definition juce_Array.h:767
void add(const ElementType &newElement)
Definition juce_Array.h:418
ElementType & getReference(int index) noexcept
Definition juce_Array.h:267
Definition juce_Line.h:47
Point< ValueType > getPointAlongLine(ValueType distanceFromStart) const noexcept
Definition juce_Line.h:204
Definition juce_PathIterator.h:42
bool closesSubPath
Definition juce_PathIterator.h:83
bool next()
Definition juce_PathIterator.cpp:60
float y2
Definition juce_PathIterator.h:76
float x2
Definition juce_PathIterator.h:75
float y1
Definition juce_PathIterator.h:74
float x1
Definition juce_PathIterator.h:73
int subPathIndex
Definition juce_PathIterator.h:90
bool isLastInSubpath() const noexcept
Definition juce_PathIterator.cpp:54
Definition juce_Path.h:65
static const float defaultToleranceForMeasurement
Definition juce_Path.h:90
void startNewSubPath(float startX, float startY)
Definition juce_Path.cpp:216
void cubicTo(float controlPoint1X, float controlPoint1Y, float controlPoint2X, float controlPoint2Y, float endPointX, float endPointY)
Definition juce_Path.cpp:268
void clear() noexcept
Definition juce_Path.cpp:151
void closeSubPath()
Definition juce_Path.cpp:292
void lineTo(float endX, float endY)
Definition juce_Path.cpp:233
void swapWithPath(Path &) noexcept
Definition juce_Path.cpp:157
void setUsingNonZeroWinding(bool isNonZeroWinding) noexcept
Definition juce_Path.cpp:168
float thickness
Definition juce_PathStrokeType.h:199
JointStyle
Definition juce_PathStrokeType.h:47
@ beveled
Definition juce_PathStrokeType.h:54
@ mitered
Definition juce_PathStrokeType.h:48
void createStrokedPath(Path &destPath, const Path &sourcePath, const AffineTransform &transform=AffineTransform(), float extraAccuracy=1.0f) const
Definition juce_PathStrokeType.cpp:655
PathStrokeType(float strokeThickness) noexcept
Definition juce_PathStrokeType.cpp:29
JointStyle jointStyle
Definition juce_PathStrokeType.h:200
EndCapStyle
Definition juce_PathStrokeType.h:60
@ square
Definition juce_PathStrokeType.h:62
@ butt
Definition juce_PathStrokeType.h:61
void createDashedStroke(Path &destPath, const Path &sourcePath, const float *dashLengths, int numDashLengths, const AffineTransform &transform=AffineTransform(), float extraAccuracy=1.0f) const
Definition juce_PathStrokeType.cpp:662
~PathStrokeType() noexcept
Definition juce_PathStrokeType.cpp:54
EndCapStyle endStyle
Definition juce_PathStrokeType.h:201
void createStrokeWithArrowheads(Path &destPath, const Path &sourcePath, float arrowheadStartWidth, float arrowheadStartLength, float arrowheadEndWidth, float arrowheadEndLength, const AffineTransform &transform=AffineTransform(), float extraAccuracy=1.0f) const
Definition juce_PathStrokeType.cpp:727
int * l
Definition inflate.c:1579
register unsigned i
Definition inflate.c:1575
static int width
Definition pugl.h:1593
Definition juce_PathStrokeType.cpp:72
static void addEdgeAndJoint(Path &destPath, const PathStrokeType::JointStyle style, const float maxMiterExtensionSquared, const float width, const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4, const float midX, const float midY)
Definition juce_PathStrokeType.cpp:191
static bool lineIntersection(const float x1, const float y1, const float x2, const float y2, const float x3, const float y3, const float x4, const float y4, float &intersectionX, float &intersectionY, float &distanceBeyondLine1EndSquared) noexcept
Definition juce_PathStrokeType.cpp:73
static void createStroke(const float thickness, const PathStrokeType::JointStyle jointStyle, const PathStrokeType::EndCapStyle endStyle, Path &destPath, const Path &source, const AffineTransform &transform, const float extraAccuracy, const Arrowhead *const arrowhead)
Definition juce_PathStrokeType.cpp:543
static void shortenSubPath(Array< LineSection > &subPath, float amountAtStart, float amountAtEnd)
Definition juce_PathStrokeType.cpp:372
static void addArrowhead(Path &destPath, const float x1, const float y1, const float x2, const float y2, const float tipX, const float tipY, const float width, const float arrowheadWidth)
Definition juce_PathStrokeType.cpp:351
static void addLineEnd(Path &destPath, const PathStrokeType::EndCapStyle style, const float x1, const float y1, const float x2, const float y2, const float width)
Definition juce_PathStrokeType.cpp:286
static void addSubPath(Path &destPath, Array< LineSection > &subPath, const bool isClosed, const float width, const float maxMiterExtensionSquared, const PathStrokeType::JointStyle jointStyle, const PathStrokeType::EndCapStyle endStyle, const Arrowhead *const arrowhead)
Definition juce_PathStrokeType.cpp:431
Definition carla_juce.cpp:31
RangedDirectoryIterator end(const RangedDirectoryIterator &)
Definition juce_RangedDirectoryIterator.h:184
Type juce_hypot(Type a, Type b) noexcept
Definition juce_MathsFunctions.h:352
static constexpr FloatType twoPi
Definition juce_MathsFunctions.h:385
static constexpr FloatType pi
Definition juce_MathsFunctions.h:382
Definition juce_PathStrokeType.cpp:346
float endWidth
Definition juce_PathStrokeType.cpp:348
float endLength
Definition juce_PathStrokeType.cpp:348
float startWidth
Definition juce_PathStrokeType.cpp:347
float startLength
Definition juce_PathStrokeType.cpp:347
Definition juce_PathStrokeType.cpp:366
float ry1
Definition juce_PathStrokeType.cpp:369
float ry2
Definition juce_PathStrokeType.cpp:369
float y2
Definition juce_PathStrokeType.cpp:367
float rx2
Definition juce_PathStrokeType.cpp:369
float rx1
Definition juce_PathStrokeType.cpp:369
float lx1
Definition juce_PathStrokeType.cpp:368
float ly2
Definition juce_PathStrokeType.cpp:368
float lx2
Definition juce_PathStrokeType.cpp:368
float x1
Definition juce_PathStrokeType.cpp:367
float y1
Definition juce_PathStrokeType.cpp:367
float ly1
Definition juce_PathStrokeType.cpp:368
float x2
Definition juce_PathStrokeType.cpp:367
dy
Definition zipinfo.c:2288