LMMS
Loading...
Searching...
No Matches
juce_Parallelogram.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
36template <typename ValueType>
38{
39public:
40 //==============================================================================
43 Parallelogram() = default;
44
46 Parallelogram (const Parallelogram&) = default;
47
50 Point<ValueType> topRightPosition,
51 Point<ValueType> bottomLeftPosition) noexcept
52 : topLeft (topLeftPosition), topRight (topRightPosition), bottomLeft (bottomLeftPosition)
53 {
54 }
55
58 : topLeft (rectangle.getTopLeft()),
59 topRight (rectangle.getTopRight()),
60 bottomLeft (rectangle.getBottomLeft())
61 {
62 }
63
64 Parallelogram& operator= (const Parallelogram&) = default;
65
67 ~Parallelogram() = default;
68
69 //==============================================================================
72
74 inline bool isFinite() const noexcept { return topLeft.isFinite() && topRight.isFinite() && bottomLeft.isFinite(); }
75
77 inline ValueType getWidth() const noexcept { return Line<ValueType> (topLeft, topRight).getLength(); }
78
81
82 //==============================================================================
85
88
91
94
95 //==============================================================================
97 bool operator== (const Parallelogram& other) const noexcept { return topLeft == other.topLeft && topRight == other.topRight && bottomLeft == other.bottomLeft; }
98
100 bool operator!= (const Parallelogram& other) const noexcept { return ! operator== (other); }
101
102 //==============================================================================
104 Parallelogram operator+ (Point<ValueType> deltaPosition) const noexcept
105 {
106 auto p = *this;
107 p += deltaPosition;
108 return p;
109 }
110
112 Parallelogram& operator+= (Point<ValueType> deltaPosition) noexcept
113 {
114 topLeft += deltaPosition;
115 topRight += deltaPosition;
116 bottomLeft += deltaPosition;
117 return *this;
118 }
119
121 Parallelogram operator- (Point<ValueType> deltaPosition) const noexcept
122 {
123 return operator+ (-deltaPosition);
124 }
125
127 Parallelogram& operator-= (Point<ValueType> deltaPosition) noexcept
128 {
129 return operator-= (-deltaPosition);
130 }
131
133 template <typename PointOrScalarType>
134 Parallelogram operator* (PointOrScalarType scaleFactor) const noexcept
135 {
136 auto p = *this;
137 p *= scaleFactor;
138 return p;
139 }
140
142 template <typename PointOrScalarType>
143 Parallelogram operator*= (PointOrScalarType scaleFactor) noexcept
144 {
145 topLeft *= scaleFactor;
146 topRight *= scaleFactor;
147 bottomLeft *= scaleFactor;
148 return *this;
149 }
150
151 //==============================================================================
157 Point<ValueType> getRelativePoint (Point<ValueType> relativePosition) const noexcept
158 {
159 return topLeft
160 + (topRight - topLeft) * relativePosition.x
161 + (bottomLeft - topLeft) * relativePosition.y;
162 }
163
165 Parallelogram transformedBy (const AffineTransform& transform) const noexcept
166 {
167 auto p = *this;
168 transform.transformPoints (p.topLeft.x, p.topLeft.y,
169 p.topRight.x, p.topRight.y,
170 p.bottomLeft.x, p.bottomLeft.y);
171
172 return p;
173 }
174
181
183};
184
185} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_AffineTransform.h:43
Definition juce_Line.h:47
ValueType getLength() const noexcept
Definition juce_Line.h:117
Parallelogram(Rectangle< ValueType > rectangle) noexcept
Definition juce_Parallelogram.h:57
ValueType getWidth() const noexcept
Definition juce_Parallelogram.h:77
Point< ValueType > getTopRight() const noexcept
Definition juce_Parallelogram.h:87
Parallelogram()=default
Parallelogram transformedBy(const AffineTransform &transform) const noexcept
Definition juce_Parallelogram.h:165
Parallelogram(Point< ValueType > topLeftPosition, Point< ValueType > topRightPosition, Point< ValueType > bottomLeftPosition) noexcept
Definition juce_Parallelogram.h:49
Point< ValueType > getTopLeft() const noexcept
Definition juce_Parallelogram.h:84
Point< ValueType > topLeft
Definition juce_Parallelogram.h:182
Point< ValueType > getBottomLeft() const noexcept
Definition juce_Parallelogram.h:90
Point< ValueType > getBottomRight() const noexcept
Definition juce_Parallelogram.h:93
Point< ValueType > topRight
Definition juce_Parallelogram.h:182
Point< ValueType > getRelativePoint(Point< ValueType > relativePosition) const noexcept
Definition juce_Parallelogram.h:157
Rectangle< ValueType > getBoundingBox() const noexcept
Definition juce_Parallelogram.h:176
bool isEmpty() const noexcept
Definition juce_Parallelogram.h:71
bool isFinite() const noexcept
Definition juce_Parallelogram.h:74
Point< ValueType > bottomLeft
Definition juce_Parallelogram.h:182
ValueType getHeight() const noexcept
Definition juce_Parallelogram.h:80
Parallelogram(const Parallelogram &)=default
~Parallelogram()=default
Definition juce_Point.h:42
Definition juce_Rectangle.h:67
static Rectangle findAreaContainingPoints(const Point< ValueType > *points, int numPoints) noexcept
Definition juce_Rectangle.h:901
Definition carla_juce.cpp:31
uch * p
Definition crypt.c:594
#define const
Definition zconf.h:137