10 #include "../drawing_export.h"
30 rectangle(int32_t
x, int32_t
y, int32_t width, int32_t height) : x_(
x), y_(
y), width_(width), height_(height) {}
36 operator rectangle_f()
const {
return rectangle_f(
static_cast<float>(x_),
static_cast<float>(y_),
static_cast<float>(width_),
static_cast<float>(height_));}
37 bool operator==(
const rectangle& value)
const {
return x_ == value.x_ && y_ == value.y_ && width_ == value.width_ && height_ == value.height_;}
38 bool operator!=(
const rectangle& value)
const {
return !operator==(value);}
41 int32_t bottom()
const {
return y_ + height_;}
43 int32_t height()
const {
return height_;}
44 void height(int32_t height) {height_ = height;}
46 bool is_empty()
const {
return *
this == rectangle::empty;}
48 int32_t left()
const {
return x_;}
49 void left(int32_t left) {x_ = left;}
51 point location()
const {
return {x_, y_};}
52 void location(
const point& location) {
57 int32_t right()
const {
return x_ + width_;}
65 int32_t top()
const {
return y_;}
66 void top(int32_t top) {y_ = top;}
68 int32_t
x()
const {
return x_;}
69 void x(int32_t
x) {x_ =
x;}
71 int32_t
y()
const {
return y_;}
72 void y(int32_t
y) {y_ =
y;}
74 int32_t width()
const {
return width_;}
75 void width(int32_t width) {width_ = width;}
77 static rectangle ceiling(
const rectangle_f& rect) {
return rectangle(
static_cast<int32_t
>(std::ceil(rect.x())),
static_cast<int32_t
>(std::ceil(rect.y())),
static_cast<int32_t
>(std::ceil(rect.width())),
static_cast<int32_t
>(std::ceil(rect.height())));}
79 bool contains(
const point& pt)
const {
return contains(pt.
x(), pt.
y());}
80 bool contains(
const rectangle& rect)
const {
return x_ <= rect.x_ && (rect.x_ + rect.width_) <= (x_ + width_) && y_ <= rect.y_ && (rect.y_ + rect.height_) <= (y_ + height_);}
81 bool contains(int32_t
x, int32_t
y)
const {
return x_ <=
x &&
x < x_ + width_ && y_ <=
y &&
y < y_ + height_;}
83 static rectangle from_ltrb(int32_t left, int32_t top, int32_t right, int32_t bottom) {
return rectangle(left, top, right - left, bottom - top);}
86 void inflate(
int width,
int height) {
93 result.inflate(width, height);
97 bool intersects_with(
const rectangle& rect)
const {
return (rect.x_ < x_ + width_) && (x_ < (rect.x_ + rect.width_)) && (rect.y_ < y_ + height_) && (y_ < rect.y_ + rect.height_);}
101 result.make_intersect(
b);
104 void make_intersect(
const rectangle& rect);
108 result.make_union(
b);
113 void offset(
const point& pt) {offset(pt.
x(), pt.
y());}
114 void offset(int32_t dx, int32_t dy) {
125 static rectangle round(
const rectangle_f& rect) {
return rectangle(
static_cast<int32_t
>(std::round(rect.x())),
static_cast<int32_t
>(std::round(rect.y())),
static_cast<int32_t
>(std::round(rect.width())),
static_cast<int32_t
>(std::round(rect.height())));}
127 static rectangle trunc(
const rectangle_f& rect) {
return rectangle(
static_cast<int32_t
>(std::trunc(rect.x())),
static_cast<int32_t
>(std::trunc(rect.y())),
static_cast<int32_t
>(std::trunc(rect.width())),
static_cast<int32_t
>(std::trunc(rect.height())));}
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:48
int32_t y() const
Gets the y-coordinate of this point.
Definition: point.h:205
int32_t x() const
Gets the x-coordinate of this point.
Definition: point.h:159
Stores a set of four floating-points that represent the location and size of a rectangle.
Definition: rectangle_f.h:28
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:25
xtd::ustring to_string() const noexcept override
Returns a std::string that represents the current object.
Definition: rectangle.h:129
Stores an ordered pair of integers, which specify a height and width.
Definition: size.h:25
int32_t width() const
Gets the horizontal component of this Size class.
Definition: size.h:67
int32_t height() const
Gets he vertical component of this Size Class.
Definition: size.h:57
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition: object.h:26
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:48
#define drawing_export_
Define shared library export.
Definition: drawing_export.h:13
std::string to_string(const value_t &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition: to_string.h:37
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::object class.
Contains xtd::drawing::point class.
Contains xtd::drawing::rectangle_f class.
Contains xtd::drawing::size class.
Contains xtd::ustring class.