1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Parallelogram: Fix implementations of isEmpty and operator-=

Previously, isEmpty sometimes incorrectly returned true for non-empty
parallelograms.

operator-= called itself, leading to infinite recursion.
This commit is contained in:
reuk 2024-04-29 15:02:42 +01:00
parent 83dcaf3c39
commit 44a04370a9
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
37 changed files with 177 additions and 3 deletions

View file

@ -1840,6 +1840,7 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/geometry/juce_EdgeTable.h"
"../../../../../modules/juce_graphics/geometry/juce_Line.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.h"
"../../../../../modules/juce_graphics/geometry/juce_PathIterator.cpp"
@ -4336,6 +4337,7 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/geometry/juce_EdgeTable.h"
"../../../../../modules/juce_graphics/geometry/juce_Line.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.h"
"../../../../../modules/juce_graphics/geometry/juce_PathIterator.cpp"

View file

@ -2132,6 +2132,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2881,6 +2881,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -2132,6 +2132,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2881,6 +2881,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -2132,6 +2132,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2881,6 +2881,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1602,6 +1602,7 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/geometry/juce_EdgeTable.h"
"../../../../../modules/juce_graphics/geometry/juce_Line.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.h"
"../../../../../modules/juce_graphics/geometry/juce_PathIterator.cpp"
@ -3780,6 +3781,7 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/geometry/juce_EdgeTable.h"
"../../../../../modules/juce_graphics/geometry/juce_Line.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.h"
"../../../../../modules/juce_graphics/geometry/juce_PathIterator.cpp"

View file

@ -1825,6 +1825,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2425,6 +2425,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1732,6 +1732,7 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/geometry/juce_EdgeTable.h"
"../../../../../modules/juce_graphics/geometry/juce_Line.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.h"
"../../../../../modules/juce_graphics/geometry/juce_PathIterator.cpp"
@ -4063,6 +4064,7 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/geometry/juce_EdgeTable.h"
"../../../../../modules/juce_graphics/geometry/juce_Line.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.h"
"../../../../../modules/juce_graphics/geometry/juce_PathIterator.cpp"

View file

@ -1959,6 +1959,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2632,6 +2632,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1959,6 +1959,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2632,6 +2632,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1959,6 +1959,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2632,6 +2632,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1621,6 +1621,7 @@ add_library( ${BINARY_NAME}
"../../../../../modules/juce_graphics/geometry/juce_EdgeTable.h"
"../../../../../modules/juce_graphics/geometry/juce_Line.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.h"
"../../../../../modules/juce_graphics/geometry/juce_PathIterator.cpp"
@ -3879,6 +3880,7 @@ set_source_files_properties(
"../../../../../modules/juce_graphics/geometry/juce_EdgeTable.h"
"../../../../../modules/juce_graphics/geometry/juce_Line.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram.h"
"../../../../../modules/juce_graphics/geometry/juce_Parallelogram_test.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.cpp"
"../../../../../modules/juce_graphics/geometry/juce_Path.h"
"../../../../../modules/juce_graphics/geometry/juce_PathIterator.cpp"

View file

@ -1846,6 +1846,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2479,6 +2479,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1028,6 +1028,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -1423,6 +1423,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1028,6 +1028,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -1423,6 +1423,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1028,6 +1028,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -1423,6 +1423,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1967,6 +1967,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2653,6 +2653,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1967,6 +1967,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2653,6 +2653,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1967,6 +1967,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2653,6 +2653,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -1845,6 +1845,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>

View file

@ -2476,6 +2476,9 @@
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_EdgeTable.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Parallelogram_test.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\modules\juce_graphics\geometry\juce_Path.cpp">
<Filter>JUCE Modules\juce_graphics\geometry</Filter>
</ClCompile>

View file

@ -76,8 +76,8 @@ public:
~Parallelogram() = default;
//==============================================================================
/** Returns true if the parallelogram has a width or height of more than zero. */
bool isEmpty() const noexcept { return topLeft != topRight || topLeft != bottomLeft; }
/** Returns true if the parallelogram has an area of zero. */
bool isEmpty() const noexcept { return topLeft == topRight || topLeft == bottomLeft || topRight == bottomLeft; }
/** Returns true if the parallelogram's coordinates are all finite numbers, i.e. not NaN or infinity. */
inline bool isFinite() const noexcept { return topLeft.isFinite() && topRight.isFinite() && bottomLeft.isFinite(); }
@ -135,7 +135,7 @@ public:
/** Moves this parallelogram by a given amount. */
Parallelogram& operator-= (Point<ValueType> deltaPosition) noexcept
{
return operator-= (-deltaPosition);
return operator+= (-deltaPosition);
}
/** Returns a parallelogram that has been scaled by the given amount, centred around the origin. */

View file

@ -0,0 +1,75 @@
/*
==============================================================================
This file is part of the JUCE framework.
Copyright (c) Raw Material Software Limited
JUCE is an open source framework subject to commercial or open source
licensing.
By downloading, installing, or using the JUCE framework, or combining the
JUCE framework with any other source code, object code, content or any other
copyrightable work, you agree to the terms of the JUCE End User Licence
Agreement, and all incorporated terms including the JUCE Privacy Policy and
the JUCE Website Terms of Service, as applicable, which will bind you. If you
do not agree to the terms of these agreements, we will not license the JUCE
framework to you, and you must discontinue the installation or download
process and cease use of the JUCE framework.
JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/
JUCE Privacy Policy: https://juce.com/juce-privacy-policy
JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/
Or:
You may also use this code under the terms of the AGPLv3:
https://www.gnu.org/licenses/agpl-3.0.en.html
THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL
WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED.
==============================================================================
*/
namespace juce
{
class ParallelogramTest : public UnitTest
{
public:
ParallelogramTest() : UnitTest ("Parallelogram", UnitTestCategories::graphics) {}
void runTest() override
{
beginTest ("isEmpty");
{
expect (! Parallelogram (Rectangle<int> (10, 10, 20, 20)).isEmpty());
expect (Parallelogram (Rectangle<int> (10, 10, 0, 20)).isEmpty());
expect (Parallelogram (Rectangle<int> (10, 10, 20, 0)).isEmpty());
expect (! Parallelogram (Point<int> (0, 0), Point<int> (10, 10), Point<int> (20, 0)).isEmpty());
expect (Parallelogram (Point<int> (0, 0), Point<int> (0, 0), Point<int> (20, 0)).isEmpty());
expect (Parallelogram (Point<int> (0, 0), Point<int> (10, 10), Point<int> (10, 10)).isEmpty());
expect (Parallelogram (Point<int> (20, 0), Point<int> (10, 10), Point<int> (20, 0)).isEmpty());
}
beginTest ("operators");
{
Parallelogram p (Rectangle<int> (10, 10, 20, 20));
p += Point<int> (5, 10);
expect (p.topLeft == Point<int> (15, 20));
expect (p.topRight == Point<int> (35, 20));
expect (p.bottomLeft == Point<int> (15, 40));
p -= Point<int> (10, 5);
expect (p.topLeft == Point<int> (5, 15));
expect (p.topRight == Point<int> (25, 15));
expect (p.bottomLeft == Point<int> (5, 35));
}
}
};
static ParallelogramTest parallelogramTest;
} // namespace juce

View file

@ -191,6 +191,7 @@
#include "effects/juce_GlowEffect.cpp"
#if JUCE_UNIT_TESTS
#include "geometry/juce_Parallelogram_test.cpp"
#include "geometry/juce_Rectangle_test.cpp"
#endif