openshot-audio  0.1.6
juce_Rectangle.h
Go to the documentation of this file.
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2015 - ROLI Ltd.
6 
7  Permission is granted to use this software under the terms of either:
8  a) the GPL v2 (or any later version)
9  b) the Affero GPL v3
10 
11  Details of these licenses can be found at: www.gnu.org/licenses
12 
13  JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
14  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15  A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 
17  ------------------------------------------------------------------------------
18 
19  To release a closed-source product which uses JUCE, commercial licenses are
20  available: visit www.juce.com for more information.
21 
22  ==============================================================================
23 */
24 
25 #ifndef JUCE_RECTANGLE_H_INCLUDED
26 #define JUCE_RECTANGLE_H_INCLUDED
27 
28 
29 //==============================================================================
35 template <typename ValueType>
36 class Rectangle
37 {
38 public:
39  //==============================================================================
44  : w(), h()
45  {
46  }
47 
49  Rectangle (const Rectangle& other) noexcept
50  : pos (other.pos), w (other.w), h (other.h)
51  {
52  }
53 
55  Rectangle (ValueType initialX, ValueType initialY,
56  ValueType width, ValueType height) noexcept
57  : pos (initialX, initialY),
58  w (width), h (height)
59  {
60  }
61 
63  Rectangle (ValueType width, ValueType height) noexcept
64  : w (width), h (height)
65  {
66  }
67 
70  : pos (jmin (corner1.x, corner2.x),
71  jmin (corner1.y, corner2.y)),
72  w (corner1.x - corner2.x),
73  h (corner1.y - corner2.y)
74  {
75  if (w < ValueType()) w = -w;
76  if (h < ValueType()) h = -h;
77  }
78 
83  static Rectangle leftTopRightBottom (ValueType left, ValueType top,
84  ValueType right, ValueType bottom) noexcept
85  {
86  return Rectangle (left, top, right - left, bottom - top);
87  }
88 
90  {
91  pos = other.pos;
92  w = other.w; h = other.h;
93  return *this;
94  }
95 
98 
99  //==============================================================================
101  bool isEmpty() const noexcept { return w <= ValueType() || h <= ValueType(); }
102 
104  inline bool isFinite() const noexcept { return pos.isFinite() && juce_isfinite(w) && juce_isfinite(h); }
105 
107  inline ValueType getX() const noexcept { return pos.x; }
108 
110  inline ValueType getY() const noexcept { return pos.y; }
111 
113  inline ValueType getWidth() const noexcept { return w; }
114 
116  inline ValueType getHeight() const noexcept { return h; }
117 
119  inline ValueType getRight() const noexcept { return pos.x + w; }
120 
122  inline ValueType getBottom() const noexcept { return pos.y + h; }
123 
125  ValueType getCentreX() const noexcept { return pos.x + w / (ValueType) 2; }
126 
128  ValueType getCentreY() const noexcept { return pos.y + h / (ValueType) 2; }
129 
131  Point<ValueType> getCentre() const noexcept { return Point<ValueType> (pos.x + w / (ValueType) 2,
132  pos.y + h / (ValueType) 2); }
133 
137  ValueType getAspectRatio (bool widthOverHeight = true) const noexcept { return widthOverHeight ? w / h : h / w; }
138 
139  //==============================================================================
142 
144  inline void setPosition (Point<ValueType> newPos) noexcept { pos = newPos; }
145 
147  inline void setPosition (ValueType newX, ValueType newY) noexcept { pos.setXY (newX, newY); }
148 
151 
154 
157 
160 
163 
166 
168  void setSize (ValueType newWidth, ValueType newHeight) noexcept { w = newWidth; h = newHeight; }
169 
171  void setBounds (ValueType newX, ValueType newY,
172  ValueType newWidth, ValueType newHeight) noexcept { pos.x = newX; pos.y = newY; w = newWidth; h = newHeight; }
173 
175  inline void setX (ValueType newX) noexcept { pos.x = newX; }
176 
178  inline void setY (ValueType newY) noexcept { pos.y = newY; }
179 
181  inline void setWidth (ValueType newWidth) noexcept { w = newWidth; }
182 
184  inline void setHeight (ValueType newHeight) noexcept { h = newHeight; }
185 
187  inline void setCentre (ValueType newCentreX, ValueType newCentreY) noexcept { pos.x = newCentreX - w / (ValueType) 2;
188  pos.y = newCentreY - h / (ValueType) 2; }
189 
191  inline void setCentre (Point<ValueType> newCentre) noexcept { setCentre (newCentre.x, newCentre.y); }
192 
194  void setHorizontalRange (Range<ValueType> range) noexcept { pos.x = range.getStart(); w = range.getLength(); }
195 
197  void setVerticalRange (Range<ValueType> range) noexcept { pos.y = range.getStart(); h = range.getLength(); }
198 
200  Rectangle withX (ValueType newX) const noexcept { return Rectangle (newX, pos.y, w, h); }
201 
203  Rectangle withY (ValueType newY) const noexcept { return Rectangle (pos.x, newY, w, h); }
204 
206  Rectangle withPosition (ValueType newX, ValueType newY) const noexcept { return Rectangle (newX, newY, w, h); }
207 
209  Rectangle withPosition (Point<ValueType> newPos) const noexcept { return Rectangle (newPos.x, newPos.y, w, h); }
210 
213 
215  Rectangle withCentre (Point<ValueType> newCentre) const noexcept { return Rectangle (newCentre.x - w / (ValueType) 2,
216  newCentre.y - h / (ValueType) 2, w, h); }
217 
219  Rectangle withWidth (ValueType newWidth) const noexcept { return Rectangle (pos.x, pos.y, newWidth, h); }
220 
222  Rectangle withHeight (ValueType newHeight) const noexcept { return Rectangle (pos.x, pos.y, w, newHeight); }
223 
225  Rectangle withSize (ValueType newWidth, ValueType newHeight) const noexcept { return Rectangle (pos.x, pos.y, newWidth, newHeight); }
226 
228  Rectangle withSizeKeepingCentre (ValueType newWidth, ValueType newHeight) const noexcept { return Rectangle (pos.x + (w - newWidth) / (ValueType) 2,
229  pos.y + (h - newHeight) / (ValueType) 2, newWidth, newHeight); }
230 
235  void setLeft (ValueType newLeft) noexcept { w = jmax (ValueType(), pos.x + w - newLeft); pos.x = newLeft; }
236 
241  Rectangle withLeft (ValueType newLeft) const noexcept { return Rectangle (newLeft, pos.y, jmax (ValueType(), pos.x + w - newLeft), h); }
242 
247  void setTop (ValueType newTop) noexcept { h = jmax (ValueType(), pos.y + h - newTop); pos.y = newTop; }
248 
253  Rectangle withTop (ValueType newTop) const noexcept { return Rectangle (pos.x, newTop, w, jmax (ValueType(), pos.y + h - newTop)); }
254 
259  void setRight (ValueType newRight) noexcept { pos.x = jmin (pos.x, newRight); w = newRight - pos.x; }
260 
265  Rectangle withRight (ValueType newRight) const noexcept { return Rectangle (jmin (pos.x, newRight), pos.y, jmax (ValueType(), newRight - pos.x), h); }
266 
271  void setBottom (ValueType newBottom) noexcept { pos.y = jmin (pos.y, newBottom); h = newBottom - pos.y; }
272 
277  Rectangle withBottom (ValueType newBottom) const noexcept { return Rectangle (pos.x, jmin (pos.y, newBottom), w, jmax (ValueType(), newBottom - pos.y)); }
278 
280  Rectangle withTrimmedLeft (ValueType amountToRemove) const noexcept { return withLeft (pos.x + amountToRemove); }
281 
283  Rectangle withTrimmedRight (ValueType amountToRemove) const noexcept { return withWidth (w - amountToRemove); }
284 
286  Rectangle withTrimmedTop (ValueType amountToRemove) const noexcept { return withTop (pos.y + amountToRemove); }
287 
289  Rectangle withTrimmedBottom (ValueType amountToRemove) const noexcept { return withHeight (h - amountToRemove); }
290 
291  //==============================================================================
293  void translate (ValueType deltaX,
294  ValueType deltaY) noexcept
295  {
296  pos.x += deltaX;
297  pos.y += deltaY;
298  }
299 
301  Rectangle translated (ValueType deltaX,
302  ValueType deltaY) const noexcept
303  {
304  return Rectangle (pos.x + deltaX, pos.y + deltaY, w, h);
305  }
306 
309  {
310  return Rectangle (pos.x + deltaPosition.x, pos.y + deltaPosition.y, w, h);
311  }
312 
315  {
316  pos += deltaPosition;
317  return *this;
318  }
319 
322  {
323  return Rectangle (pos.x - deltaPosition.x, pos.y - deltaPosition.y, w, h);
324  }
325 
328  {
329  pos -= deltaPosition;
330  return *this;
331  }
332 
338  template <typename FloatType>
339  Rectangle operator* (FloatType scaleFactor) const noexcept
340  {
341  Rectangle r (*this);
342  r *= scaleFactor;
343  return r;
344  }
345 
351  template <typename FloatType>
352  Rectangle operator*= (FloatType scaleFactor) noexcept
353  {
354  Rectangle<FloatType> (pos.x * scaleFactor,
355  pos.y * scaleFactor,
356  w * scaleFactor,
357  h * scaleFactor).copyWithRounding (*this);
358  return *this;
359  }
360 
366  template <typename FloatType>
368  {
369  Rectangle<FloatType> (pos.x * scaleFactor.x,
370  pos.y * scaleFactor.y,
371  w * scaleFactor.x,
372  h * scaleFactor.y).copyWithRounding (*this);
373  return *this;
374  }
375 
377  template <typename FloatType>
378  Rectangle operator/ (FloatType scaleFactor) const noexcept
379  {
380  Rectangle r (*this);
381  r /= scaleFactor;
382  return r;
383  }
384 
386  template <typename FloatType>
387  Rectangle operator/= (FloatType scaleFactor) noexcept
388  {
389  Rectangle<FloatType> (pos.x / scaleFactor,
390  pos.y / scaleFactor,
391  w / scaleFactor,
392  h / scaleFactor).copyWithRounding (*this);
393  return *this;
394  }
395 
397  template <typename FloatType>
399  {
400  Rectangle<FloatType> (pos.x / scaleFactor.x,
401  pos.y / scaleFactor.y,
402  w / scaleFactor.x,
403  h / scaleFactor.y).copyWithRounding (*this);
404  return *this;
405  }
406 
412  void expand (ValueType deltaX,
413  ValueType deltaY) noexcept
414  {
415  const ValueType nw = jmax (ValueType(), w + deltaX * 2);
416  const ValueType nh = jmax (ValueType(), h + deltaY * 2);
417  setBounds (pos.x - deltaX, pos.y - deltaY, nw, nh);
418  }
419 
425  Rectangle expanded (ValueType deltaX,
426  ValueType deltaY) const noexcept
427  {
428  const ValueType nw = jmax (ValueType(), w + deltaX * 2);
429  const ValueType nh = jmax (ValueType(), h + deltaY * 2);
430  return Rectangle (pos.x - deltaX, pos.y - deltaY, nw, nh);
431  }
432 
438  Rectangle expanded (ValueType delta) const noexcept
439  {
440  return expanded (delta, delta);
441  }
442 
448  void reduce (ValueType deltaX,
449  ValueType deltaY) noexcept
450  {
451  expand (-deltaX, -deltaY);
452  }
453 
459  Rectangle reduced (ValueType deltaX,
460  ValueType deltaY) const noexcept
461  {
462  return expanded (-deltaX, -deltaY);
463  }
464 
470  Rectangle reduced (ValueType delta) const noexcept
471  {
472  return reduced (delta, delta);
473  }
474 
484  Rectangle removeFromTop (ValueType amountToRemove) noexcept
485  {
486  const Rectangle r (pos.x, pos.y, w, jmin (amountToRemove, h));
487  pos.y += r.h; h -= r.h;
488  return r;
489  }
490 
500  Rectangle removeFromLeft (ValueType amountToRemove) noexcept
501  {
502  const Rectangle r (pos.x, pos.y, jmin (amountToRemove, w), h);
503  pos.x += r.w; w -= r.w;
504  return r;
505  }
506 
516  Rectangle removeFromRight (ValueType amountToRemove) noexcept
517  {
518  amountToRemove = jmin (amountToRemove, w);
519  const Rectangle r (pos.x + w - amountToRemove, pos.y, amountToRemove, h);
520  w -= amountToRemove;
521  return r;
522  }
523 
533  Rectangle removeFromBottom (ValueType amountToRemove) noexcept
534  {
535  amountToRemove = jmin (amountToRemove, h);
536  const Rectangle r (pos.x, pos.y + h - amountToRemove, w, amountToRemove);
537  h -= amountToRemove;
538  return r;
539  }
540 
541  //==============================================================================
543  bool operator== (const Rectangle& other) const noexcept { return pos == other.pos && w == other.w && h == other.h; }
544 
546  bool operator!= (const Rectangle& other) const noexcept { return pos != other.pos || w != other.w || h != other.h; }
547 
549  bool contains (ValueType xCoord, ValueType yCoord) const noexcept
550  {
551  return xCoord >= pos.x && yCoord >= pos.y && xCoord < pos.x + w && yCoord < pos.y + h;
552  }
553 
555  bool contains (Point<ValueType> point) const noexcept
556  {
557  return point.x >= pos.x && point.y >= pos.y && point.x < pos.x + w && point.y < pos.y + h;
558  }
559 
561  bool contains (const Rectangle& other) const noexcept
562  {
563  return pos.x <= other.pos.x && pos.y <= other.pos.y
564  && pos.x + w >= other.pos.x + other.w && pos.y + h >= other.pos.y + other.h;
565  }
566 
569  {
570  return Point<ValueType> (jlimit (pos.x, pos.x + w, point.x),
571  jlimit (pos.y, pos.y + h, point.y));
572  }
573 
579  Point<ValueType> getRelativePoint (double relativeX, double relativeY) const noexcept
580  {
581  return Point<ValueType> (pos.x + static_cast <ValueType> (w * relativeX),
582  pos.y + static_cast <ValueType> (h * relativeY));
583  }
584 
586  bool intersects (const Rectangle& other) const noexcept
587  {
588  return pos.x + w > other.pos.x
589  && pos.y + h > other.pos.y
590  && pos.x < other.pos.x + other.w
591  && pos.y < other.pos.y + other.h
592  && w > ValueType() && h > ValueType()
593  && other.w > ValueType() && other.h > ValueType();
594  }
595 
597  bool intersects (const Line<ValueType>& line) const noexcept
598  {
599  return contains (line.getStart()) || contains (line.getEnd())
600  || line.intersects (Line<ValueType> (getTopLeft(), getTopRight()))
601  || line.intersects (Line<ValueType> (getTopRight(), getBottomRight()))
602  || line.intersects (Line<ValueType> (getBottomRight(), getBottomLeft()))
603  || line.intersects (Line<ValueType> (getBottomLeft(), getTopLeft()));
604  }
605 
610  {
611  const ValueType nx = jmax (pos.x, other.pos.x);
612  const ValueType ny = jmax (pos.y, other.pos.y);
613  const ValueType nw = jmin (pos.x + w, other.pos.x + other.w) - nx;
614  const ValueType nh = jmin (pos.y + h, other.pos.y + other.h) - ny;
615 
616  if (nw >= ValueType() && nh >= ValueType())
617  return Rectangle (nx, ny, nw, nh);
618 
619  return Rectangle();
620  }
621 
626  bool intersectRectangle (ValueType& otherX, ValueType& otherY, ValueType& otherW, ValueType& otherH) const noexcept
627  {
628  const ValueType maxX (jmax (otherX, pos.x));
629  otherW = jmin (otherX + otherW, pos.x + w) - maxX;
630 
631  if (otherW > ValueType())
632  {
633  const ValueType maxY (jmax (otherY, pos.y));
634  otherH = jmin (otherY + otherH, pos.y + h) - maxY;
635 
636  if (otherH > ValueType())
637  {
638  otherX = maxX; otherY = maxY;
639  return true;
640  }
641  }
642 
643  return false;
644  }
645 
649  bool intersectRectangle (Rectangle<ValueType>& rectangleToClip) const noexcept
650  {
651  return intersectRectangle (rectangleToClip.pos.x, rectangleToClip.pos.y,
652  rectangleToClip.w, rectangleToClip.h);
653  }
654 
660  Rectangle getUnion (const Rectangle& other) const noexcept
661  {
662  if (other.isEmpty()) return *this;
663  if (isEmpty()) return other;
664 
665  const ValueType newX = jmin (pos.x, other.pos.x);
666  const ValueType newY = jmin (pos.y, other.pos.y);
667 
668  return Rectangle (newX, newY,
669  jmax (pos.x + w, other.pos.x + other.w) - newX,
670  jmax (pos.y + h, other.pos.y + other.h) - newY);
671  }
672 
680  {
681  if (pos.x == other.pos.x && getRight() == other.getRight()
682  && (other.getBottom() >= pos.y && other.pos.y <= getBottom()))
683  {
684  const ValueType newY = jmin (pos.y, other.pos.y);
685  h = jmax (getBottom(), other.getBottom()) - newY;
686  pos.y = newY;
687  return true;
688  }
689 
690  if (pos.y == other.pos.y && getBottom() == other.getBottom()
691  && (other.getRight() >= pos.x && other.pos.x <= getRight()))
692  {
693  const ValueType newX = jmin (pos.x, other.pos.x);
694  w = jmax (getRight(), other.getRight()) - newX;
695  pos.x = newX;
696  return true;
697  }
698 
699  return false;
700  }
701 
709  {
710  int inside = 0;
711  const ValueType otherR (other.getRight());
712  if (pos.x >= other.pos.x && pos.x < otherR) inside = 1;
713  const ValueType otherB (other.getBottom());
714  if (pos.y >= other.pos.y && pos.y < otherB) inside |= 2;
715  const ValueType r (pos.x + w);
716  if (r >= other.pos.x && r < otherR) inside |= 4;
717  const ValueType b (pos.y + h);
718  if (b >= other.pos.y && b < otherB) inside |= 8;
719 
720  switch (inside)
721  {
722  case 1 + 2 + 8: w = r - otherR; pos.x = otherR; return true;
723  case 1 + 2 + 4: h = b - otherB; pos.y = otherB; return true;
724  case 2 + 4 + 8: w = other.pos.x - pos.x; return true;
725  case 1 + 4 + 8: h = other.pos.y - pos.y; return true;
726  }
727 
728  return false;
729  }
730 
738  Rectangle constrainedWithin (const Rectangle& areaToFitWithin) const noexcept
739  {
740  const ValueType newW (jmin (w, areaToFitWithin.getWidth()));
741  const ValueType newH (jmin (h, areaToFitWithin.getHeight()));
742 
743  return Rectangle (jlimit (areaToFitWithin.getX(), areaToFitWithin.getRight() - newW, pos.x),
744  jlimit (areaToFitWithin.getY(), areaToFitWithin.getBottom() - newH, pos.y),
745  newW, newH);
746  }
747 
754  {
755  typedef typename TypeHelpers::SmallestFloatType<ValueType>::type FloatType;
756 
757  FloatType x1 = static_cast<FloatType> (pos.x), y1 = static_cast<FloatType> (pos.y);
758  FloatType x2 = static_cast<FloatType> (pos.x + w), y2 = static_cast<FloatType> (pos.y);
759  FloatType x3 = static_cast<FloatType> (pos.x), y3 = static_cast<FloatType> (pos.y + h);
760  FloatType x4 = static_cast<FloatType> (x2), y4 = static_cast<FloatType> (y3);
761 
762  transform.transformPoints (x1, y1, x2, y2);
763  transform.transformPoints (x3, y3, x4, y4);
764 
765  const FloatType rx1 = jmin (x1, x2, x3, x4);
766  const FloatType rx2 = jmax (x1, x2, x3, x4);
767  const FloatType ry1 = jmin (y1, y2, y3, y4);
768  const FloatType ry2 = jmax (y1, y2, y3, y4);
769 
770  Rectangle r;
771  Rectangle<FloatType> (rx1, ry1, rx2 - rx1, ry2 - ry1).copyWithRounding (r);
772  return r;
773  }
774 
780  {
781  const int x1 = floorAsInt (pos.x);
782  const int y1 = floorAsInt (pos.y);
783  const int x2 = ceilAsInt (pos.x + w);
784  const int y2 = ceilAsInt (pos.y + h);
785 
786  return Rectangle<int> (x1, y1, x2 - x1, y2 - y1);
787  }
788 
793  {
794  return Rectangle<float> (static_cast<float> (pos.x), static_cast<float> (pos.y),
795  static_cast<float> (w), static_cast<float> (h));
796  }
797 
802  {
803  return Rectangle<double> (static_cast<double> (pos.x), static_cast<double> (pos.y),
804  static_cast<double> (w), static_cast<double> (h));
805  }
806 
811  template <typename TargetType>
813  {
815  copyWithRounding (r);
816  return r;
817  }
818 
820  static Rectangle findAreaContainingPoints (const Point<ValueType>* const points, const int numPoints) noexcept
821  {
822  if (numPoints == 0)
823  return Rectangle();
824 
825  ValueType minX (points[0].x);
826  ValueType maxX (minX);
827  ValueType minY (points[0].y);
828  ValueType maxY (minY);
829 
830  for (int i = 1; i < numPoints; ++i)
831  {
832  minX = jmin (minX, points[i].x);
833  maxX = jmax (maxX, points[i].x);
834  minY = jmin (minY, points[i].y);
835  maxY = jmax (maxY, points[i].y);
836  }
837 
838  return Rectangle (minX, minY, maxX - minX, maxY - minY);
839  }
840 
841  //==============================================================================
846  static bool intersectRectangles (ValueType& x1, ValueType& y1, ValueType& w1, ValueType& h1,
847  const ValueType x2, const ValueType y2, const ValueType w2, const ValueType h2) noexcept
848  {
849  const ValueType x (jmax (x1, x2));
850  w1 = jmin (x1 + w1, x2 + w2) - x;
851 
852  if (w1 > ValueType())
853  {
854  const ValueType y (jmax (y1, y2));
855  h1 = jmin (y1 + h1, y2 + h2) - y;
856 
857  if (h1 > ValueType())
858  {
859  x1 = x; y1 = y;
860  return true;
861  }
862  }
863 
864  return false;
865  }
866 
867  //==============================================================================
877  String toString() const
878  {
879  String s;
880  s.preallocateBytes (32);
881  s << pos.x << ' ' << pos.y << ' ' << w << ' ' << h;
882  return s;
883  }
884 
895  static Rectangle fromString (StringRef stringVersion)
896  {
897  StringArray toks;
898  toks.addTokens (stringVersion.text.findEndOfWhitespace(), ",; \t\r\n", "");
899 
900  return Rectangle (parseIntAfterSpace (toks[0]),
901  parseIntAfterSpace (toks[1]),
902  parseIntAfterSpace (toks[2]),
903  parseIntAfterSpace (toks[3]));
904  }
905 
906  #ifndef DOXYGEN
907  // This has been renamed by transformedBy, in order to match the method names used in the Point class.
908  JUCE_DEPRECATED_WITH_BODY (Rectangle transformed (const AffineTransform& t) const noexcept, { return transformedBy (t); })
909  #endif
910 
911 private:
912  template <typename OtherType> friend class Rectangle;
913 
915  ValueType w, h;
916 
917  static int parseIntAfterSpace (StringRef s) noexcept
918  { return s.text.findEndOfWhitespace().getIntValue32(); }
919 
920  void copyWithRounding (Rectangle<int>& result) const noexcept { result = getSmallestIntegerContainer(); }
921  void copyWithRounding (Rectangle<float>& result) const noexcept { result = toFloat(); }
922  void copyWithRounding (Rectangle<double>& result) const noexcept { result = toDouble(); }
923 
924  static int floorAsInt (int n) noexcept { return n; }
925  static int floorAsInt (float n) noexcept { return (int) std::floor (n); }
926  static int floorAsInt (double n) noexcept { return (int) std::floor (n); }
927  static int ceilAsInt (int n) noexcept { return n; }
928  static int ceilAsInt (float n) noexcept { return (int) std::ceil (n); }
929  static int ceilAsInt (double n) noexcept { return (int) std::ceil (n); }
930 };
931 
932 
933 #endif // JUCE_RECTANGLE_H_INCLUDED
Rectangle(Point< ValueType > corner1, Point< ValueType > corner2) noexcept
Definition: juce_Rectangle.h:69
bool contains(const Rectangle &other) const noexcept
Definition: juce_Rectangle.h:561
Rectangle withBottom(ValueType newBottom) const noexcept
Definition: juce_Rectangle.h:277
Rectangle withLeft(ValueType newLeft) const noexcept
Definition: juce_Rectangle.h:241
void setCentre(Point< ValueType > newCentre) noexcept
Definition: juce_Rectangle.h:191
Rectangle withPosition(Point< ValueType > newPos) const noexcept
Definition: juce_Rectangle.h:209
ValueType w
Definition: juce_Rectangle.h:915
Rectangle(ValueType width, ValueType height) noexcept
Definition: juce_Rectangle.h:63
ValueType getWidth() const noexcept
Definition: juce_Rectangle.h:113
int addTokens(StringRef stringToTokenise, bool preserveQuotedStrings)
Definition: juce_StringArray.cpp:345
Rectangle withPosition(ValueType newX, ValueType newY) const noexcept
Definition: juce_Rectangle.h:206
bool operator!=(const Rectangle &other) const noexcept
Definition: juce_Rectangle.h:546
void setCentre(ValueType newCentreX, ValueType newCentreY) noexcept
Definition: juce_Rectangle.h:187
Rectangle translated(ValueType deltaX, ValueType deltaY) const noexcept
Definition: juce_Rectangle.h:301
static int ceilAsInt(int n) noexcept
Definition: juce_Rectangle.h:927
Rectangle withSize(ValueType newWidth, ValueType newHeight) const noexcept
Definition: juce_Rectangle.h:225
String::CharPointerType text
Definition: juce_StringRef.h:119
Rectangle removeFromRight(ValueType amountToRemove) noexcept
Definition: juce_Rectangle.h:516
void setTop(ValueType newTop) noexcept
Definition: juce_Rectangle.h:247
ValueType getRight() const noexcept
Definition: juce_Rectangle.h:119
void setHeight(ValueType newHeight) noexcept
Definition: juce_Rectangle.h:184
Point< ValueType > getCentre() const noexcept
Definition: juce_Rectangle.h:131
ValueType getAspectRatio(bool widthOverHeight=true) const noexcept
Definition: juce_Rectangle.h:137
Rectangle withCentre(Point< ValueType > newCentre) const noexcept
Definition: juce_Rectangle.h:215
void expand(ValueType deltaX, ValueType deltaY) noexcept
Definition: juce_Rectangle.h:412
Definition: juce_Line.h:44
#define noexcept
Definition: juce_CompilerSupport.h:141
void copyWithRounding(Rectangle< float > &result) const noexcept
Definition: juce_Rectangle.h:921
bool reduceIfPartlyContainedIn(const Rectangle &other) noexcept
Definition: juce_Rectangle.h:708
ValueType getCentreX() const noexcept
Definition: juce_Rectangle.h:125
Rectangle getUnion(const Rectangle &other) const noexcept
Definition: juce_Rectangle.h:660
ValueType getX() const noexcept
Definition: juce_Rectangle.h:107
Point< ValueType > getBottomLeft() const noexcept
Definition: juce_Rectangle.h:156
static int floorAsInt(double n) noexcept
Definition: juce_Rectangle.h:926
Rectangle withY(ValueType newY) const noexcept
Definition: juce_Rectangle.h:203
String toString() const
Definition: juce_Rectangle.h:877
Rectangle withZeroOrigin() const noexcept
Definition: juce_Rectangle.h:212
ValueType getHeight() const noexcept
Definition: juce_Rectangle.h:116
Type jmin(const Type a, const Type b)
Definition: juce_core.h:113
Rectangle withRight(ValueType newRight) const noexcept
Definition: juce_Rectangle.h:265
Definition: juce_Range.h:44
Rectangle transformedBy(const AffineTransform &transform) const noexcept
Definition: juce_Rectangle.h:753
void setHorizontalRange(Range< ValueType > range) noexcept
Definition: juce_Rectangle.h:194
Rectangle expanded(ValueType deltaX, ValueType deltaY) const noexcept
Definition: juce_Rectangle.h:425
bool intersects(const Rectangle &other) const noexcept
Definition: juce_Rectangle.h:586
Rectangle withTrimmedLeft(ValueType amountToRemove) const noexcept
Definition: juce_Rectangle.h:280
Rectangle withTrimmedTop(ValueType amountToRemove) const noexcept
Definition: juce_Rectangle.h:286
Range< ValueType > getVerticalRange() const noexcept
Definition: juce_Rectangle.h:165
void copyWithRounding(Rectangle< double > &result) const noexcept
Definition: juce_Rectangle.h:922
Rectangle & operator-=(Point< ValueType > deltaPosition) noexcept
Definition: juce_Rectangle.h:327
Rectangle operator/=(FloatType scaleFactor) noexcept
Definition: juce_Rectangle.h:387
Rectangle< float > toFloat() const noexcept
Definition: juce_Rectangle.h:792
void setLeft(ValueType newLeft) noexcept
Definition: juce_Rectangle.h:235
bool contains(ValueType xCoord, ValueType yCoord) const noexcept
Definition: juce_Rectangle.h:549
void copyWithRounding(Rectangle< int > &result) const noexcept
Definition: juce_Rectangle.h:920
static int ceilAsInt(double n) noexcept
Definition: juce_Rectangle.h:929
Definition: juce_Point.h:39
Definition: juce_String.h:43
Rectangle operator*(FloatType scaleFactor) const noexcept
Definition: juce_Rectangle.h:339
long b
Definition: jpegint.h:371
static Rectangle findAreaContainingPoints(const Point< ValueType > *const points, const int numPoints) noexcept
Definition: juce_Rectangle.h:820
Rectangle withHeight(ValueType newHeight) const noexcept
Definition: juce_Rectangle.h:222
Rectangle< TargetType > toType() const noexcept
Definition: juce_Rectangle.h:812
Rectangle removeFromLeft(ValueType amountToRemove) noexcept
Definition: juce_Rectangle.h:500
#define const
Range< ValueType > getHorizontalRange() const noexcept
Definition: juce_Rectangle.h:162
void setBounds(ValueType newX, ValueType newY, ValueType newWidth, ValueType newHeight) noexcept
Definition: juce_Rectangle.h:171
ValueType getBottom() const noexcept
Definition: juce_Rectangle.h:122
Rectangle & operator+=(Point< ValueType > deltaPosition) noexcept
Definition: juce_Rectangle.h:314
void setX(ValueType newX) noexcept
Definition: juce_Rectangle.h:175
Definition: juce_Rectangle.h:36
Rectangle(ValueType initialX, ValueType initialY, ValueType width, ValueType height) noexcept
Definition: juce_Rectangle.h:55
static int parseIntAfterSpace(StringRef s) noexcept
Definition: juce_Rectangle.h:917
Point< ValueType > getBottomRight() const noexcept
Definition: juce_Rectangle.h:159
void setSize(ValueType newWidth, ValueType newHeight) noexcept
Definition: juce_Rectangle.h:168
Rectangle operator/(FloatType scaleFactor) const noexcept
Definition: juce_Rectangle.h:378
Rectangle withWidth(ValueType newWidth) const noexcept
Definition: juce_Rectangle.h:219
bool isFinite() const noexcept
Definition: juce_Rectangle.h:104
Rectangle & operator=(const Rectangle &other) noexcept
Definition: juce_Rectangle.h:89
Rectangle() noexcept
Definition: juce_Rectangle.h:43
void setY(ValueType newY) noexcept
Definition: juce_Rectangle.h:178
static Rectangle fromString(StringRef stringVersion)
Definition: juce_Rectangle.h:895
Rectangle operator+(Point< ValueType > deltaPosition) const noexcept
Definition: juce_Rectangle.h:308
void setRight(ValueType newRight) noexcept
Definition: juce_Rectangle.h:259
Rectangle withTrimmedBottom(ValueType amountToRemove) const noexcept
Definition: juce_Rectangle.h:289
Rectangle< double > toDouble() const noexcept
Definition: juce_Rectangle.h:801
Rectangle withX(ValueType newX) const noexcept
Definition: juce_Rectangle.h:200
bool intersectRectangle(ValueType &otherX, ValueType &otherY, ValueType &otherW, ValueType &otherH) const noexcept
Definition: juce_Rectangle.h:626
Type jmax(const Type a, const Type b)
Definition: juce_core.h:101
bool enlargeIfAdjacent(const Rectangle &other) noexcept
Definition: juce_Rectangle.h:679
Rectangle withSizeKeepingCentre(ValueType newWidth, ValueType newHeight) const noexcept
Definition: juce_Rectangle.h:228
void setPosition(ValueType newX, ValueType newY) noexcept
Definition: juce_Rectangle.h:147
Point< ValueType > getPosition() const noexcept
Definition: juce_Rectangle.h:141
png_const_structrp png_const_inforp int png_fixed_point * width
Definition: juce_PNGLoader.cpp:2339
Definition: juce_StringArray.h:39
bool intersects(const Line< ValueType > &line) const noexcept
Definition: juce_Rectangle.h:597
static Rectangle leftTopRightBottom(ValueType left, ValueType top, ValueType right, ValueType bottom) noexcept
Definition: juce_Rectangle.h:83
void setVerticalRange(Range< ValueType > range) noexcept
Definition: juce_Rectangle.h:197
Type jlimit(const Type lowerLimit, const Type upperLimit, const Type valueToConstrain) noexcept
Definition: juce_MathsFunctions.h:220
static Range withStartAndLength(const ValueType startValue, const ValueType length) noexcept
Definition: juce_Range.h:81
Rectangle expanded(ValueType delta) const noexcept
Definition: juce_Rectangle.h:438
Rectangle constrainedWithin(const Rectangle &areaToFitWithin) const noexcept
Definition: juce_Rectangle.h:738
float type
Definition: juce_MathsFunctions.h:607
void preallocateBytes(size_t numBytesNeeded)
Definition: juce_String.cpp:300
ValueType h
Definition: juce_Rectangle.h:915
Point< ValueType > getRelativePoint(double relativeX, double relativeY) const noexcept
Definition: juce_Rectangle.h:579
ValueType getY() const noexcept
Definition: juce_Rectangle.h:110
void setBottom(ValueType newBottom) noexcept
Definition: juce_Rectangle.h:271
Rectangle< int > getSmallestIntegerContainer() const noexcept
Definition: juce_Rectangle.h:779
void setWidth(ValueType newWidth) noexcept
Definition: juce_Rectangle.h:181
bool intersectRectangle(Rectangle< ValueType > &rectangleToClip) const noexcept
Definition: juce_Rectangle.h:649
Rectangle removeFromBottom(ValueType amountToRemove) noexcept
Definition: juce_Rectangle.h:533
Rectangle(const Rectangle &other) noexcept
Definition: juce_Rectangle.h:49
ValueType getCentreY() const noexcept
Definition: juce_Rectangle.h:128
Rectangle operator-(Point< ValueType > deltaPosition) const noexcept
Definition: juce_Rectangle.h:321
Definition: juce_AffineTransform.h:40
void reduce(ValueType deltaX, ValueType deltaY) noexcept
Definition: juce_Rectangle.h:448
Rectangle reduced(ValueType delta) const noexcept
Definition: juce_Rectangle.h:470
Rectangle getIntersection(const Rectangle &other) const noexcept
Definition: juce_Rectangle.h:609
bool juce_isfinite(NumericType) noexcept
Definition: juce_core.h:374
bool contains(Point< ValueType > point) const noexcept
Definition: juce_Rectangle.h:555
Rectangle removeFromTop(ValueType amountToRemove) noexcept
Definition: juce_Rectangle.h:484
Point< ValueType > getTopRight() const noexcept
Definition: juce_Rectangle.h:153
static int floorAsInt(int n) noexcept
Definition: juce_Rectangle.h:924
Rectangle operator*=(FloatType scaleFactor) noexcept
Definition: juce_Rectangle.h:352
void setPosition(Point< ValueType > newPos) noexcept
Definition: juce_Rectangle.h:144
void translate(ValueType deltaX, ValueType deltaY) noexcept
Definition: juce_Rectangle.h:293
Rectangle withTop(ValueType newTop) const noexcept
Definition: juce_Rectangle.h:253
~Rectangle() noexcept
Definition: juce_Rectangle.h:97
Rectangle reduced(ValueType deltaX, ValueType deltaY) const noexcept
Definition: juce_Rectangle.h:459
static bool intersectRectangles(ValueType &x1, ValueType &y1, ValueType &w1, ValueType &h1, const ValueType x2, const ValueType y2, const ValueType w2, const ValueType h2) noexcept
Definition: juce_Rectangle.h:846
Point< ValueType > getTopLeft() const noexcept
Definition: juce_Rectangle.h:150
#define JUCE_DEPRECATED_WITH_BODY(functionDef, body)
Definition: juce_PlatformDefs.h:320
static int floorAsInt(float n) noexcept
Definition: juce_Rectangle.h:925
Rectangle withTrimmedRight(ValueType amountToRemove) const noexcept
Definition: juce_Rectangle.h:283
static int ceilAsInt(float n) noexcept
Definition: juce_Rectangle.h:928
Point< ValueType > getConstrainedPoint(Point< ValueType > point) const noexcept
Definition: juce_Rectangle.h:568
JUCE_DEPRECATED_WITH_BODY(Rectangle transformed(const AffineTransform &t) const noexcept, { return transformedBy(t);}) private Point< ValueType > pos
Definition: juce_Rectangle.h:908
Definition: juce_StringRef.h:65
bool operator==(const Rectangle &other) const noexcept
Definition: juce_Rectangle.h:543
bool isEmpty() const noexcept
Definition: juce_Rectangle.h:101