Browse Source

Line: Add explicit methods for lengthening the start and end points

pull/22/head
Tom Poole 3 years ago
parent
commit
ed4f638ff7
1 changed files with 20 additions and 0 deletions
  1. +20
    -0
      modules/juce_graphics/geometry/juce_Line.h

+ 20
- 0
modules/juce_graphics/geometry/juce_Line.h View File

@@ -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


Loading…
Cancel
Save