xtd 0.2.0
point.hpp
Go to the documentation of this file.
1
4#pragma once
6#include "point_f.hpp"
7#include <xtd/iequatable>
8#include <xtd/object>
9#include <xtd/string>
10#include <cstdint>
11#include <ostream>
12
14namespace xtd {
16 namespace drawing {
18 struct size;
20
56
59 static const point empty;
61
63
67 point() noexcept = default;
68
91 explicit point(int32 dw) noexcept;
92
115 point(int32 x, int32 y) noexcept;
116
138 explicit point(const size& sz) noexcept;
140
142 point(const point&) noexcept = default;
143 point& operator =(const point&) noexcept = default;
144 operator point_f() const noexcept;
146
148
152 bool is_empty() const noexcept;
153
175 int32 x = 0;
176
198 int32 y = 0;
200
202
207 bool equals(const xtd::object& obj) const noexcept override;
211 bool equals(const point& other) const noexcept override;
212
215 xtd::size get_hash_code() const noexcept override;
216
220 void offset(int32 dx, int32 dy) noexcept;
221
235 void offset(const point& p) noexcept;
236
239 xtd::string to_string() const noexcept override;
240
244 static point truncate(const point_f& value) noexcept;
246
248
264 static point add(const point& pt, const size& sz) noexcept;
269 static point add(const point& pt1, const point& pt2) noexcept;
270
274 static point ceiling(const point_f& value) noexcept;
275
279 static point round(const point_f& value) noexcept;
280
286 static point subtract(const point& pt, const size& sz) noexcept;
291 static point subtract(const point& pt1, const point& pt2) noexcept;
293
295
300 point operator +(const size& sz) const noexcept;
304 point operator +(const point& pt) const noexcept;
305
309 point& operator +=(const size& sz) noexcept;
313 point& operator +=(const point& pt) noexcept;
314
318 point operator -(const size& sz) const noexcept;
322 point operator -(const point& pt) const noexcept;
323
327 point& operator -=(const size& sz) noexcept;
331 point& operator -=(const point& pt) noexcept;
333 };
334 }
335
336 template<>
337 inline drawing::point parse<drawing::point>(const std::string& str) {
338 auto values = xtd::string(str).replace("}", xtd::string::empty_string).replace(" y=", xtd::string::empty_string).replace("{x=", xtd::string::empty_string).split(',');
339 return {xtd::parse<int32>(values[0]), xtd::parse<int32>(values[1])};
340 }
341}
basic_string replace(value_type old_char, value_type new_char) const noexcept
Replaces all occurrences of a specified char_t in this basic_string with another specified char_t.
Definition basic_string.hpp:1607
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
Contains drawing_export_ keyword.
#define drawing_export_
Define shared library export.
Definition drawing_export.hpp:13
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
value_t parse(const std::string &str)
Convert a string into a type.
Definition parse.hpp:34
@ other
The operating system is other.
Definition platform_id.hpp:58
@ p
The P key.
Definition console_key.hpp:118
The xtd::drawing namespace provides access to GDI+ basic graphics functionality. More advanced functi...
Definition actions_system_images.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::drawing::point_f class.
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition point_f.hpp:35
static point truncate(const point_f &value) noexcept
Converts the specified xtd::drawing::point_f to a point by truncating the values of the xtd::drawing:...
static point ceiling(const point_f &value) noexcept
Converts the specified xtd::drawing::point_f to a point by rounding the values of the xtd::drawing::p...
static point round(const point_f &value) noexcept
Converts the specified xtd::drawing::point_f to a point object by rounding the xtd::drawing::point_f ...
int32 y
Gets or sets the y-coordinate of this xtd::drawing::point.
Definition point.hpp:198
xtd::string to_string() const noexcept override
Converts this point to a human-readable string.
void offset(int32 dx, int32 dy) noexcept
Translates this xtd::drawing::point by the specified amount.
static point add(const point &pt, const size &sz) noexcept
Adds the specified xtd::drawing::size to the specified xtd::drawing::point.
static point subtract(const point &pt, const size &sz) noexcept
Returns the result of subtracting specified xtd::drawing::size from the specified xtd::drawing::point...
static const point empty
Represents a xtd::drawing::point that has xtd::drawing::point::x and xtd::drawing::point::y values se...
Definition point.hpp:59
bool is_empty() const noexcept
Gets a value indicating whether this xtd::drawing::point is empty.
point() noexcept=default
Initializes a new instance of the xtd::drawing::point class.
xtd::size get_hash_code() const noexcept override
Serves as a hash function for a particular type.
bool equals(const xtd::object &obj) const noexcept override
Determines whether the specified object is equal to the current object.
int32 x
Gets or sets the x-coordinate of this xtd::drawing::point.
Definition point.hpp:175
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:31