xtd - Reference Guide 0.2.0
rectangle_f.h
Go to the documentation of this file.
1 #pragma once
5 #include <cstdint>
6 #include <ostream>
7 #include <string>
8 #include <xtd/object.h>
9 #include <xtd/ustring.h>
10 #include "../drawing_export.h"
11 #include "point_f.h"
12 #include "size_f.h"
13 
15 namespace xtd {
17  namespace drawing {
19  class rectangle;
21 
34  class drawing_export_ rectangle_f : public xtd::object {
35  public:
37 
40  static const rectangle_f empty;
42 
44 
48  rectangle_f() noexcept = default;
54  rectangle_f(float x, float y, float width, float height) noexcept;
58  rectangle_f(const point_f& location, const size_f& size) noexcept;
60 
62  rectangle_f(const rectangle_f&) noexcept = default;
63  rectangle_f& operator =(const rectangle_f&) noexcept = default;
65 
67 
72  float bottom() const noexcept;
73 
77  float height() const noexcept;
81  void height(float height) noexcept;
82 
85  bool is_empty() const noexcept;
86 
89  float left() const noexcept;
90 
93  point_f location() const noexcept;
96  void location(const point_f& location);
97 
100  float right() const noexcept;
101 
104  size_f size() const noexcept;
107  void size(const size_f& size) noexcept;
108 
111  float top() const noexcept;
112 
116  float width() const noexcept;
120  void width(float width) noexcept;
121 
125  float x() const noexcept;
129  void x(float x) noexcept;
130 
134  float y() const noexcept;
138  void y(float y) noexcept;
140 
142 
147  void add(const drawing::size_f& sz) noexcept;
152  void add(float width, float height) noexcept;
159  static rectangle_f add(const rectangle_f& rect, float x, float y) noexcept;
165  static rectangle_f add(const rectangle_f& rect, const drawing::size_f& sz) noexcept;
166 
171  bool contains(const point_f& pt) const noexcept;
176  bool contains(const rectangle_f& rect) const noexcept;
182  bool contains(float x, float y) const noexcept;
183 
191  static rectangle_f from_ltrb(float left, float top, float right, float bottom) noexcept;
192 
196  void inflate(const drawing::size_f& sz) noexcept;
202  void inflate(float width, float height) noexcept;
209  static rectangle_f inflate(const rectangle_f& rect, const drawing::size_f& sz) noexcept;
215  static rectangle_f inflate(const rectangle_f& rect, float width, float height) noexcept;
216 
220  bool intersects_with(const rectangle_f& rect) const noexcept;
221 
226  static rectangle_f make_intersect(const rectangle_f& a, const rectangle_f& b) noexcept;
229  void make_intersect(const rectangle_f& rect) noexcept;
230 
235  static rectangle_f make_union(const rectangle_f& a, const rectangle_f& b) noexcept;
238  void make_union(const rectangle_f& rect) noexcept;
239 
243  void offset(const point_f& pos) noexcept;
247  void offset(float x, float y) noexcept;
253  static rectangle_f offset(const rectangle_f& rect, const point_f& pos) noexcept;
260  static rectangle_f offset(const rectangle_f& rect, float x, float y) noexcept;
261 
264  xtd::ustring to_string() const noexcept override;
266 
268 
273  bool operator ==(const rectangle_f& value) const noexcept;
277  bool operator !=(const rectangle_f& value) const noexcept;
279 
280  private:
281  float x_ = 0;
282  float y_ = 0;
283  float width_ = 0;
284  float height_ = 0;
285  };
286  }
287 }
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:30
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Stores a set of four floating-point numbers that represent the location and size of a rectangle...
Definition: rectangle_f.h:34
Contains xtd::drawing::point_f class.
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:51
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: date_time.h:1100
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition: point_f.h:34
Stores an ordered pair of floating-point, which specify a height and width.
Definition: size_f.h:29
static const rectangle_f empty
Represents a xtd::drawing::rectangle_F that has xtd::drawing::rectagle_f::x, xtd::drawing::rectangle_...
Definition: rectangle_f.h:40
Contains xtd::ustring class.
Contains xtd::object class.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:30
Contains xtd::drawing::size_f class.