1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

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

This commit is contained in:
Tom Poole 2022-03-22 11:31:53 +00:00
parent d5d9a02c8f
commit ed4f638ff7

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