Euphoria
rect.cc
Go to the documentation of this file.
1 #include "base/rect.h"
2 
3 #include "base/random.h"
4 
5 
6 namespace eu
7 {
8 
10  : left(0)
11  , right(0)
12  , top(0)
13  , bottom(0)
14  {
15  }
16 
17 
18  Rectf::Rectf(float left_side, float right_side, float top_side, float bottom_side)
19  : left(left_side)
20  , right(right_side)
21  , top(top_side)
22  , bottom(bottom_side)
23  {
24  }
25 
26  Recti
27  Rectf::to_i() const
28  {
30  (
31  static_cast<int>(left),
32  static_cast<int>(right),
33  static_cast<int>(top),
34  static_cast<int>(bottom)
35  );
36  }
37 
38  [[nodiscard]] Rectf
39  Rectf::from_left_right_bottom_top(float left_side, float right_side, float bottom_side, float top_side)
40  {
41  ASSERTX(left_side <= right_side, left_side, right_side);
42  ASSERTX(top_side >= bottom_side, top_side, bottom_side);
43  return {left_side, right_side, top_side, bottom_side};
44  }
45 
46  [[nodiscard]] Rectf
47  Rectf::from_left_right_top_bottom(float left_side, float right_side, float top_side, float bottom_side)
48  {
49  ASSERTX(left_side <= right_side, left_side, right_side);
50  ASSERTX(top_side >= bottom_side, top_side, bottom_side);
51  return {left_side, right_side, top_side, bottom_side};
52  }
53 
54  [[nodiscard]] Rectf
56  (
57  const vec2f& pos,
58  const Scale2f& anchor,
59  float width,
60  float height
61  )
62  {
63  // todo(Gustav): change anchor type to some anchor type instead
64  const float left = pos.x - width * anchor.x;
65  const float bottom = pos.y - height * anchor.y;
67  (
68  left, left + width,
69  bottom, bottom + height
70  );
71  }
72 
73  [[nodiscard]] Rectf
74  Rectf::from_bottom_left_width_height(const vec2f& bl, float width, float height)
75  {
76  ASSERT(width >= 0);
77  ASSERT(height >= 0);
79  (
80  bl.x, bl.x + width,
81  bl.y + height, bl.y
82  );
83  }
84 
85  [[nodiscard]] Rectf
86  Rectf::from_top_left_width_height(const vec2f& topleft, float width, float height)
87  {
88  ASSERT(width >= 0);
89  ASSERT(height >= 0);
91  (
92  topleft.x, topleft.x + width,
93  topleft.y, topleft.y - height
94  );
95  }
96 
97  [[nodiscard]] Rectf
98  Rectf::from_width_height(float width, float height)
99  {
100  ASSERTX(width >= 0, width);
101  ASSERTX(height >= 0, height);
102  return from_left_right_bottom_top(0, width, 0, height);
103  }
104 
105  [[nodiscard]] Rectf
107  {
108  return from_width_height(s.width, s.height);
109  }
110 
111  [[nodiscard]] Rectf
112  Rectf::from_point(const vec2f& point)
113  {
114  return from_top_left_width_height(point, 0.0f, 0.0f);
115  }
116 
117  vec2f
119  {
120  return {left, bottom};
121  }
122 
123  Rectf
124  Rectf::center_inside_other(const Rectf& other) const
125  {
126  const auto lower_left = other.get_absolute_center_pos() - get_relative_center_pos_from_bottom_left();
128  (
129  vec2f {lower_left.x, lower_left.y + get_height()},
130  get_width(),
131  get_height()
132  );
133  }
134 
135  vec2f
137  {
138  return get_bottom_left() + v;
139  }
140 
141  float
143  {
144  return get_width() / 2;
145  }
146 
147  float
149  {
150  return get_height() / 2;
151  }
152 
153  vec2f
155  {
156  return
157  {
160  };
161  }
162 
163  float
165  {
167  }
168 
169  float
171  {
173  }
174 
175  vec2f
177  {
179  }
180 
181  bool
183  {
184  ASSERT(is_valid());
185  ASSERT(r.is_valid());
186 
187  return left < r.left
188  && right > r.right
189  && top > r.top
190  && bottom < r.bottom
191  ;
192  }
193 
194  bool
196  {
197  ASSERT(is_valid());
198  return contains_exclusive(p.x, p.y);
199  }
200 
201  bool
202  Rectf::contains_exclusive(float x, float y) const
203  {
204  ASSERT(is_valid());
205  return left < x
206  && x < right
207  && bottom < y
208  && y < top
209  ;
210  }
211 
212 
213  bool
215  {
216  return contains_inclusive(p.x, p.y);
217  }
218 
219 
220  bool
221  Rectf::contains_inclusive(float x, float y) const
222  {
223  ASSERT(is_valid());
224  return left <= x
225  && x <= right
226  && bottom <= y
227  && y <= top
228  ;
229  }
230 
231  Rectf
233  {
234  const auto s = get_size();
235  const auto ns = s * scale;
236  return inset_copy
237  (
238  (s.width - ns.width) / 2,
239  (s.height - ns.height) / 2
240  );
241  }
242 
243  void
244  Rectf::scale(float dx, float dy)
245  {
246  left *= dx;
247  right *= dx;
248  top *= dy;
249  bottom *= dy;
250  }
251 
252 
253  Rectf
254  Rectf::scale_copy(float dx, float dy) const
255  {
256  Rectf r = *this;
257  r.scale(dx, dy);
258  return r;
259  }
260 
261 
262  void
263  Rectf::inset(float dx, float dy)
264  {
265  left += dx;
266  right -= dx;
267  top -= dy;
268  bottom += dy;
269  }
270 
271 
272  void
273  Rectf::inset(float l, float r, float t, float b)
274  {
275  left += l;
276  right -= r;
277  top -= t;
278  bottom += b;
279  }
280 
281  Rectf
282  Rectf::inset_copy(float dx, float dy) const
283  {
284  Rectf ret = *this;
285  ret.inset(dx, dy);
286  return ret;
287  }
288 
289  Rectf
290  Rectf::inset_copy(float l, float r, float t, float b) const
291  {
292  Rectf ret = *this;
293  ret.inset(l, r, t, b);
294  return ret;
295  }
296 
297  void
298  Rectf::extend(float dx, float dy)
299  {
300  inset(-dx, -dy);
301  }
302 
303 
304  Rectf
305  Rectf::extend_copy(float dx, float dy) const
306  {
307  Rectf ret = *this;
308  ret.extend(dx, dy);
309  return ret;
310  }
311 
312 
313  Rectf
314  Rectf::extend_copy(float d) const
315  {
316  return extend_copy(d, d);
317  }
318 
319  void
321  {
322  left = min(left, o.left);
323  right = max(right, o.right);
324  top = max(top, o.top);
325  bottom = min(bottom, o.bottom);
326  }
327 
328 
329  [[nodiscard]] bool
331  {
332  return left >= right || top <= bottom;
333  }
334 
335 
336  [[nodiscard]] bool
338  {
339  return get_width() >= 0 && get_height() >= 0;
340  }
341 
342 
343  void
344  Rectf::translate(float dx, float dy)
345  {
346  left += dx;
347  right += dx;
348  top += dy;
349  bottom += dy;
350  }
351 
352 
353  void
354  Rectf::expand(float expand)
355  {
356  left -= expand;
357  right += expand;
358  top -= expand;
359  bottom += expand;
360  }
361 
362 
363  Rectf
364  Rectf::expand_copy(float expand) const
365  {
366  Rectf r = *this;
367  r.expand(expand);
368  return r;
369  }
370 
371  Rectf
372  Rectf::translate_copy(float dx, float dy) const
373  {
374  Rectf ret = *this;
375  ret.translate(dx, dy);
376  return ret;
377  }
378 
379  Rectf
380  Rectf::translate_copy(const vec2f& d) const
381  {
382  return translate_copy(d.x, d.y);
383  }
384 
385 
386  Rectf
387  Rectf::set_top_left_to_copy(float new_left, float new_top) const
388  {
390  (
391  vec2f{new_left, new_top},
392  get_width(),
393  get_height()
394  );
395  }
396 
397  Rectf
399  {
400  return set_top_left_to_copy(v.x, v.y);
401  }
402 
403  Rectf
404  Rectf::set_bottom_left_to_copy(float new_left, float new_bottom) const
405  {
407  (
408  vec2f{new_left, new_bottom + get_height()},
409  get_width(),
410  get_height()
411  );
412  }
413 
414 
415  Rectf
417  {
418  return set_bottom_left_to_copy(v.x, v.y);
419  }
420 
421 
422  void
424  {
425  left = right = top = bottom = 0;
426  }
427 
428 
429  float
431  {
432  return top - bottom;
433  }
434 
435  float
437  {
438  return right - left;
439  }
440 
441 
444  {
445  return {bottom, top};
446  }
447 
450  {
451  return {left, right};
452  }
453 
454  size2f
456  {
458  }
459 
460  [[nodiscard]] vec2f
462  {
463  return {left, top};
464  }
465 
466  [[nodiscard]] vec2f
468  {
469  return {right, top};
470  }
471 
472  [[nodiscard]] vec2f
474  {
475  return {right, bottom};
476  }
477 
478 
480 
481 
482 
483 
485  : left(0)
486  , right(0)
487  , top(0)
488  , bottom(0)
489  {
490  }
491 
492  Recti::Recti(int left_side, int right_side, int top_side, int bottom_side)
493  : left(left_side)
494  , right(right_side)
495  , top(top_side)
496  , bottom(bottom_side)
497  {
498  }
499 
500  Rectf
501  Recti::to_f() const
502  {
504  (
505  static_cast<float>(left),
506  static_cast<float>(right),
507  static_cast<float>(top),
508  static_cast<float>(bottom)
509  );
510  }
511 
512  [[nodiscard]] Recti
513  Recti::from_left_right_bottom_top(int left_side, int right_side, int bottom_side, int top_side)
514  {
515  ASSERTX(left_side <= right_side, left_side, right_side);
516  ASSERTX(top_side >= bottom_side, top_side, bottom_side);
517  return {left_side, right_side, top_side, bottom_side};
518  }
519 
520  [[nodiscard]] Recti
521  Recti::from_left_right_top_bottom(int left_side, int right_side, int top_side, int bottom_side)
522  {
523  ASSERTX(left_side <= right_side, left_side, right_side);
524  ASSERTX(top_side >= bottom_side, top_side, bottom_side);
525  return {left_side, right_side, top_side, bottom_side};
526  }
527 
528  [[nodiscard]] Recti
530  (
531  const vec2i& pos,
532  const Scale2f& anchor,
533  int width,
534  int height
535  )
536  {
537  // todo(Gustav): change anchor type to some anchor type instead
538  const int left = pos.x - static_cast<int>(static_cast<float>(width) * anchor.x);
539  const int bottom = pos.y - static_cast<int>(static_cast<float>(height) * anchor.y);
541  (
542  left, left + width,
543  bottom, bottom + height
544  );
545  }
546 
547  [[nodiscard]] Recti
548  Recti::from_bottom_left_width_height(const vec2i& bl, int width, int height)
549  {
550  ASSERT(width >= 0);
551  ASSERT(height >= 0);
553  (
554  bl.x, bl.x + width,
555  bl.y + height, bl.y
556  );
557  }
558 
559 
560  [[nodiscard]] Recti
561  Recti::from_top_left_width_height(const vec2i& topleft, int width, int height)
562  {
563  ASSERT(width >= 0);
564  ASSERT(height >= 0);
566  (
567  topleft.x, topleft.x + width,
568  topleft.y, topleft.y - height
569  );
570  }
571 
572  [[nodiscard]] Recti
573  Recti::from_width_height(int width, int height)
574  {
575  ASSERTX(width >= 0, width);
576  ASSERTX(height >= 0, height);
577  return from_left_right_bottom_top(0, width, 0, height);
578  }
579 
580  [[nodiscard]] Recti
582  {
583  return from_width_height(s.width, s.height);
584  }
585 
586  [[nodiscard]] Recti
587  Recti::from_point(const vec2i& point)
588  {
589  return from_top_left_width_height(point, 0, 0);
590  }
591 
592  vec2i
594  {
595  return {left, bottom};
596  }
597 
598 
599  Recti
600  Recti::center_inside_other(const Recti& other) const
601  {
602  const auto lower_left = other.get_absolute_center_pos() - get_relative_center_pos_from_bottom_left();
604  (
605  vec2i {lower_left.x, lower_left.y + get_height()},
606  get_width(),
607  get_height()
608  );
609  }
610 
611  vec2i
613  {
614  return get_bottom_left() + v;
615  }
616 
617  int
619  {
620  return get_width() / 2;
621  }
622 
623  int
625  {
626  return get_height() / 2;
627  }
628 
629  vec2i
631  {
632  return
633  {
636  };
637  }
638 
639  int
641  {
643  }
644 
645  int
647  {
649  }
650 
651  vec2i
653  {
655  }
656 
657  bool
659  {
660  ASSERT(is_valid());
661  ASSERT(r.is_valid());
662 
663  return left < r.left
664  && right > r.right
665  && top > r.top
666  && bottom < r.bottom
667  ;
668  }
669 
670  bool
672  {
673  ASSERT(is_valid());
674  return contains_exclusive(p.x, p.y);
675  }
676 
677  bool
678  Recti::contains_exclusive(int x, int y) const
679  {
680  ASSERT(is_valid());
681  return left < x
682  && x < right
683  && bottom < y
684  && y < top
685  ;
686  }
687 
688  bool
690  {
691  return contains_inclusive(p.x, p.y);
692  }
693 
694  bool
695  Recti::contains_inclusive(int x, int y) const
696  {
697  ASSERT(is_valid());
698  return left <= x
699  && x <= right
700  && bottom <= y
701  && y <= top
702  ;
703  }
704 
705  Recti
707  {
708  const auto s = get_size();
709  const auto ns = s * scale;
710  return inset_copy
711  (
712  (s.width - ns.width) / 2,
713  (s.height - ns.height) / 2
714  );
715  }
716 
717  void
718  Recti::scale(int dx, int dy)
719  {
720  left *= dx;
721  right *= dx;
722  top *= dy;
723  bottom *= dy;
724  }
725 
726  Recti
727  Recti::scale_copy(int dx, int dy) const
728  {
729  Recti r = *this;
730  r.scale(dx, dy);
731  return r;
732  }
733 
734  void
735  Recti::inset(int dx, int dy)
736  {
737  left += dx;
738  right -= dx;
739  top -= dy;
740  bottom += dy;
741  }
742 
743  void
744  Recti::inset(int l, int r, int t, int b)
745  {
746  left += l;
747  right -= r;
748  top -= t;
749  bottom += b;
750  }
751 
752  Recti
753  Recti::inset_copy(int dx, int dy) const
754  {
755  Recti ret = *this;
756  ret.inset(dx, dy);
757  return ret;
758  }
759 
760  Recti
761  Recti::inset_copy(int l, int r, int t, int b) const
762  {
763  Recti ret = *this;
764  ret.inset(l, r, t, b);
765  return ret;
766  }
767 
768  void
769  Recti::extend(int dx, int dy)
770  {
771  inset(-dx, -dy);
772  }
773 
774  Recti
775  Recti::extend_copy(int dx, int dy) const
776  {
777  Recti ret = *this;
778  ret.extend(dx, dy);
779  return ret;
780  }
781 
782  Recti
783  Recti::extend_copy(int d) const
784  {
785  return extend_copy(d, d);
786  }
787 
788  void
790  {
791  left = min(left, o.left);
792  right = max(right, o.right);
793  top = max(top, o.top);
794  bottom = min(bottom, o.bottom);
795  }
796 
797  [[nodiscard]] bool
799  {
800  return left >= right || top <= bottom;
801  }
802 
803  [[nodiscard]] bool
805  {
806  return get_width() >= 0 && get_height() >= 0;
807  }
808 
809  void
810  Recti::translate(int dx, int dy)
811  {
812  left += dx;
813  right += dx;
814  top += dy;
815  bottom += dy;
816  }
817 
818  void
819  Recti::expand(int expand)
820  {
821  left -= expand;
822  right += expand;
823  top -= expand;
824  bottom += expand;
825  }
826 
827  Recti
828  Recti::expand_copy(int expand) const
829  {
830  Recti r = *this;
831  r.expand(expand);
832  return r;
833  }
834 
835  Recti
836  Recti::translate_copy(int dx, int dy) const
837  {
838  Recti ret = *this;
839  ret.translate(dx, dy);
840  return ret;
841  }
842 
843  Recti
844  Recti::translate_copy(const vec2i& d) const
845  {
846  return translate_copy(d.x, d.y);
847  }
848 
849  Recti
850  Recti::set_top_left_to_copy(int new_left, int new_top) const
851  {
853  (
854  vec2i{new_left, new_top},
855  get_width(),
856  get_height()
857  );
858  }
859 
860  Recti
862  {
863  return set_top_left_to_copy(v.x, v.y);
864  }
865 
866  Recti
867  Recti::set_bottom_left_to_copy(int new_left, int new_bottom) const
868  {
870  (
871  vec2i{new_left, new_bottom + get_height()},
872  get_width(),
873  get_height()
874  );
875  }
876 
877  Recti
879  {
880  return set_bottom_left_to_copy(v.x, v.y);
881  }
882 
883  void
885  {
886  left = right = top = bottom = 0;
887  }
888 
889 
890  int
892  {
893  return top - bottom;
894  }
895 
896  int
898  {
899  return right - left;
900  }
901 
902 
903  Range<int>
905  {
906  return Range<int>{bottom, top};
907  }
908 
909  Range<int>
911  {
912  return Range<int>{left, right};
913  }
914 
915  size2i
917  {
919  }
920 
921  [[nodiscard]] vec2i
923  {
924  return {left, top};
925  }
926 
927  [[nodiscard]] vec2i
929  {
930  return {right, top};
931  }
932 
933  [[nodiscard]] vec2i
935  {
936  return {right, bottom};
937  }
938 
939 
941 
942 
943  [[nodiscard]] vec2f
944  to01(const Rectf& r, const vec2f& from)
945  {
946  const auto x = to01(make_range(r.left, r.right), from.x);
947  const auto y = to01(make_range(r.bottom, r.top), from.y);
948  return {x, y};
949  }
950 
951  [[nodiscard]] vec2f
952  from_01(const Rectf& r, const vec2f& from)
953  {
954  const auto x = from_01(make_range(r.left, r.right), from.x);
955  const auto y = from_01(make_range(r.bottom, r.top), from.y);
956  return {x, y};
957  }
958 
959  bool
960  is_within(const Rectf& r, const vec2f& p)
961  {
962  return
963  is_within(r.get_range_x(), p.x) &&
964  is_within(r.get_range_y(), p.y) ;
965  }
966 
967  std::string to_string(const Rectf& r)
968  {
969  return fmt::format("({}, {} / {} x {})", r.left, r.bottom, r.get_width(), r.get_height());
970  }
971 
972  [[nodiscard]] vec2f
973  to01(const Recti& r, const vec2i& from)
974  {
975  const auto x = to01<float>
976  (
977  make_range<float>(static_cast<float>(r.left), static_cast<float>(r.right)),
978  static_cast<float>(from.x)
979  );
980  const auto y = to01<float>
981  (
982  make_range<float>(static_cast<float>(r.bottom), static_cast<float>(r.top)),
983  static_cast<float>(from.y)
984  );
985  return {x, y};
986  }
987 
988  [[nodiscard]] vec2i
989  from_01(const Recti& r, const vec2f& from)
990  {
991  const auto x = from_01(make_range(r.left, r.right), from.x);
992  const auto y = from_01(make_range(r.bottom, r.top), from.y);
993  return {x, y};
994  }
995 
996  bool
997  is_within(const Recti& r, const vec2i& p)
998  {
999  return
1000  is_within(r.get_range_x(), p.x) &&
1001  is_within(r.get_range_y(), p.y) ;
1002  }
1003 
1004  bool
1005  operator==(const Recti& lhs, const Recti& rhs)
1006  {
1007  return lhs.left == rhs.left
1008  && lhs.right == rhs.right
1009  && lhs.top == rhs.top
1010  && lhs.bottom == rhs.bottom
1011  ;
1012  }
1013 
1014  std::string to_string(const Recti& r)
1015  {
1016  return fmt::format("({}, {} / {} x {})", r.left, r.bottom, r.get_width(), r.get_height());
1017  }
1018 
1019 
1020 
1021 
1022  vec2f
1023  get_random_point(Random* random, const Rectf& r)
1024  {
1025  const auto x = get_random_in_range(random, r.get_width());
1026  const auto y = get_random_in_range(random, r.get_height());
1027  return r.get_position_from_bottom_left(vec2f{x, y});
1028  }
1029 
1030 
1031  vec2i get_random_point(Random* random, const Recti& r)
1032  {
1033  const auto x = get_random_in_range(random, r.get_width());
1034  const auto y = get_random_in_range(random, r.get_height());
1035  return r.get_position_from_bottom_left(vec2i{x, y});
1036  }
1037 }
#define ASSERTX(x,...)
Definition: assert.h:48
#define ASSERT(x)
Definition: assert.h:29
Definition: assert.h:90
bool operator==(const Lrud< T > &lhs, const Lrud< T > &rhs)
Definition: lrud.h:75
float to01(const Range< T > &range, T value)
Definition: range.h:84
Range< T > make_range(T min, T max)
Definition: range.h:39
T get_random_in_range(Random *rand, const Range< T > &range)
Definition: random.h:50
std::string to_string(const Aabb &a)
Definition: aabb.cc:110
float from_01(const Range< float > &range, float value)
Definition: range.cc:13
size2f min(const size2f lhs, const size2f rhs)
Definition: size2.cc:140
bool is_within(const Range< T > &range, T value)
Definition: range.h:108
size2f max(const size2f lhs, const size2f rhs)
Definition: size2.cc:149
vec3f get_random_point(Random *rand, const Aabb &a)
Definition: aabb.cc:116
WEL512 Random Number Generator.
Definition: random.h:21
Definition: rect.h:27
void inset(float dx, float dy)
Definition: rect.cc:263
vec2f get_relative_center_pos_from_bottom_left() const
Definition: rect.cc:154
bool contains_inclusive(const vec2f &p) const
Definition: rect.cc:214
float get_relative_center_x_from_bottom_left() const
Definition: rect.cc:142
static Rectf from_position_anchor_width_and_height(const vec2f &pos, const Scale2f &anchor, float width, float height)
Definition: rect.cc:56
static Rectf from_point(const vec2f &point)
Definition: rect.cc:112
float get_width() const
Definition: rect.cc:436
size2f get_size() const
Definition: rect.cc:455
Rectf set_bottom_left_to_copy(float new_left, float new_bottom) const
Definition: rect.cc:404
Rectf translate_copy(float dx, float dy) const
Definition: rect.cc:372
float top
Definition: rect.h:30
bool contains_exclusive(const Rectf &r) const
Definition: rect.cc:182
static Rectf from_bottom_left_width_height(const vec2f &bl, float width, float height)
Definition: rect.cc:74
Range< float > get_range_y() const
Definition: rect.cc:443
bool is_valid() const
Definition: rect.cc:337
Range< float > get_range_x() const
Definition: rect.cc:449
Rectf get_scaled_around_center_copy(float scale) const
Definition: rect.cc:232
float right
Definition: rect.h:29
float get_height() const
Definition: rect.cc:430
static Rectf from_left_right_top_bottom(float left_side, float right_side, float top_side, float bottom_side)
Definition: rect.cc:47
vec2f get_top_left() const
Definition: rect.cc:461
static Rectf from_left_right_bottom_top(float left_side, float right_side, float bottom_side, float top_side)
Definition: rect.cc:39
Rectf()
Definition: rect.cc:9
Rectf center_inside_other(const Rectf &other) const
Definition: rect.cc:124
float get_relative_center_y_from_bottom_left() const
Definition: rect.cc:148
Rectf expand_copy(float expand) const
Definition: rect.cc:364
Recti to_i() const
Definition: rect.cc:27
static Rectf from_top_left_width_height(const vec2f &topleft, float width, float height)
Definition: rect.cc:86
float get_absolute_center_y() const
Definition: rect.cc:170
Rectf inset_copy(float dx, float dy) const
Definition: rect.cc:282
vec2f get_top_right() const
Definition: rect.cc:467
void translate(float dx, float dy)
Definition: rect.cc:344
vec2f get_bottom_left() const
Definition: rect.cc:118
vec2f get_absolute_center_pos() const
Definition: rect.cc:176
vec2f get_bottom_right() const
Definition: rect.cc:473
static Rectf from_width_height(float width, float height)
Definition: rect.cc:98
void scale(float dx, float dy)
Definition: rect.cc:244
void extend(float dx, float dy)
Definition: rect.cc:298
void include(const Rectf &o)
Definition: rect.cc:320
float get_absolute_center_x() const
Definition: rect.cc:164
Rectf extend_copy(float dx, float dy) const
Definition: rect.cc:305
bool is_empty() const
Definition: rect.cc:330
float left
Definition: rect.h:28
void expand(float expand)
Definition: rect.cc:354
void set_empty()
Definition: rect.cc:423
vec2f get_position_from_bottom_left(const vec2f &v) const
Definition: rect.cc:136
float bottom
Definition: rect.h:31
Rectf set_top_left_to_copy(float new_left, float new_top) const
Definition: rect.cc:387
Rectf scale_copy(float dx, float dy) const
Definition: rect.cc:254
Recti inset_copy(int dx, int dy) const
Definition: rect.cc:753
int left
Definition: rect.h:126
vec2i get_absolute_center_pos() const
Definition: rect.cc:652
bool contains_inclusive(const vec2i &p) const
Definition: rect.cc:689
void extend(int dx, int dy)
Definition: rect.cc:769
vec2i get_bottom_right() const
Definition: rect.cc:934
vec2i get_relative_center_pos_from_bottom_left() const
Definition: rect.cc:630
Recti extend_copy(int dx, int dy) const
Definition: rect.cc:775
static Recti from_position_anchor_width_and_height(const vec2i &pos, const Scale2f &anchor, int width, int height)
Definition: rect.cc:530
void translate(int dx, int dy)
Definition: rect.cc:810
Range< int > get_range_x() const
Definition: rect.cc:910
static Recti from_width_height(int width, int height)
Definition: rect.cc:573
Recti()
Definition: rect.cc:484
void inset(int dx, int dy)
Definition: rect.cc:735
static Recti from_left_right_bottom_top(int left_side, int right_side, int bottom_side, int top_side)
Definition: rect.cc:513
void set_empty()
Definition: rect.cc:884
vec2i get_position_from_bottom_left(const vec2i &v) const
Definition: rect.cc:612
int top
Definition: rect.h:128
Recti expand_copy(int expand) const
Definition: rect.cc:828
static Recti from_point(const vec2i &point)
Definition: rect.cc:587
void scale(int dx, int dy)
Definition: rect.cc:718
Recti center_inside_other(const Recti &other) const
Definition: rect.cc:600
int get_relative_center_y_from_bottom_left() const
Definition: rect.cc:624
void include(const Recti &o)
Definition: rect.cc:789
Rectf to_f() const
Definition: rect.cc:501
Recti get_scaled_around_center_copy(int scale) const
Definition: rect.cc:706
int get_absolute_center_x() const
Definition: rect.cc:640
vec2i get_top_right() const
Definition: rect.cc:928
int get_absolute_center_y() const
Definition: rect.cc:646
int bottom
Definition: rect.h:129
int get_relative_center_x_from_bottom_left() const
Definition: rect.cc:618
bool is_valid() const
Definition: rect.cc:804
bool contains_exclusive(const Recti &r) const
Definition: rect.cc:658
void expand(int expand)
Definition: rect.cc:819
Recti translate_copy(int dx, int dy) const
Definition: rect.cc:836
Range< int > get_range_y() const
Definition: rect.cc:904
vec2i get_bottom_left() const
Definition: rect.cc:593
Recti set_top_left_to_copy(int new_left, int new_top) const
Definition: rect.cc:850
size2i get_size() const
Definition: rect.cc:916
Recti set_bottom_left_to_copy(int new_left, int new_bottom) const
Definition: rect.cc:867
vec2i get_top_left() const
Definition: rect.cc:922
Recti scale_copy(int dx, int dy) const
Definition: rect.cc:727
int get_height() const
Definition: rect.cc:891
bool is_empty() const
Definition: rect.cc:798
int right
Definition: rect.h:127
static Recti from_bottom_left_width_height(const vec2i &bl, int width, int height)
Definition: rect.cc:548
static Recti from_left_right_top_bottom(int left_side, int right_side, int top_side, int bottom_side)
Definition: rect.cc:521
int get_width() const
Definition: rect.cc:897
static Recti from_top_left_width_height(const vec2i &topleft, int width, int height)
Definition: rect.cc:561
float x
Definition: vec2.h:138
float y
Definition: vec2.h:139
static size2f create_from_width_height(float w, float h)
Definition: size2.cc:15
static size2i create_from_width_height(int w, int h)
Definition: size2.cc:211
Definition: vec2.h:33
float x
Definition: vec2.h:34
float y
Definition: vec2.h:35
Definition: vec2.h:72
int y
Definition: vec2.h:74
int x
Definition: vec2.h:73