From ed4f638ff7802a5909b9a1674f0aec185eb96f92 Mon Sep 17 00:00:00 2001 From: Tom Poole Date: Tue, 22 Mar 2022 11:31:53 +0000 Subject: [PATCH] Line: Add explicit methods for lengthening the start and end points --- modules/juce_graphics/geometry/juce_Line.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/modules/juce_graphics/geometry/juce_Line.h b/modules/juce_graphics/geometry/juce_Line.h index b938d07728..104f3246ed 100644 --- a/modules/juce_graphics/geometry/juce_Line.h +++ b/modules/juce_graphics/geometry/juce_Line.h @@ -329,6 +329,16 @@ public: && point.y < ((end.y - start.y) * (point.x - start.x)) / (end.x - start.x) + start.y; } + /** Returns a lengthened copy of this line. + + This will extend the line by a certain amount by moving the start away from the end + (leaving the end-point the same), and return the new line. + */ + Line withLengthenedStart (ValueType distanceToLengthenBy) const noexcept + { + return withShortenedStart (-distanceToLengthenBy); + } + //============================================================================== /** Returns a shortened copy of this line. @@ -340,6 +350,16 @@ public: return { getPointAlongLine (jmin (distanceToShortenBy, getLength())), end }; } + /** Returns a lengthened copy of this line. + + This will extend the line by a certain amount by moving the end away from the start + (leaving the start-point the same), and return the new line. + */ + Line withLengthenedEnd (ValueType distanceToLengthenBy) const noexcept + { + return withShortenedEnd (-distanceToLengthenBy); + } + /** Returns a shortened copy of this line. This will chop off part of the end of this line by a certain amount, (leaving the