xtd 0.2.0
Loading...
Searching...
No Matches
point.hpp
Go to the documentation of this file.
1
4#pragma once
5#include "../drawing_export.hpp"
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 class size;
20
54 class drawing_export_ point : public xtd::object, public xtd::iequatable<point> {
55 public:
57
60 static const point empty;
62
64
68 point() noexcept = default;
69
92 explicit point(int32 dw) noexcept;
93
116 point(int32 x, int32 y) noexcept;
117
139 explicit point(const size& sz) noexcept;
141
143 point(const point&) noexcept = default;
144 point& operator =(const point&) noexcept = default;
145 operator point_f() const noexcept;
147
149
153 bool is_empty() const noexcept;
154
176 int32 x() const noexcept;
177
199 void x(int32 x) noexcept;
200
222 int32 y() const noexcept;
223
245 void y(int32 y) noexcept;
247
249
251 using object::equals;
252 bool equals(const point& value) const noexcept override;
253
257 void offset(int32 dx, int32 dy) noexcept;
258
272 void offset(const point& p) noexcept;
273
276 xtd::string to_string() const noexcept override;
277
281 static point truncate(const point_f& value) noexcept;
283
285
301 static point add(const point& pt, const size& sz) noexcept;
306 static point add(const point& pt1, const point& pt2) noexcept;
307
311 static point ceiling(const point_f& value) noexcept;
312
316 static point round(const point_f& value) noexcept;
317
323 static point subtract(const point& pt, const size& sz) noexcept;
328 static point subtract(const point& pt1, const point& pt2) noexcept;
330
332
337 point operator +(const size& sz) const noexcept;
341 point operator +(const point& pt) const noexcept;
342
346 point& operator +=(const size& sz) noexcept;
350 point& operator +=(const point& pt) noexcept;
351
355 point operator -(const size& sz) const noexcept;
359 point operator -(const point& pt) const noexcept;
360
364 point& operator -=(const size& sz) noexcept;
368 point& operator -=(const point& pt) noexcept;
370
371 private:
372 int32 x_ = 0;
373 int32 y_ = 0;
374 };
375 }
376
377 template<>
378 inline drawing::point parse<drawing::point>(const std::string& str) {
379 auto values = xtd::string(str).replace("}", xtd::string::empty_string).replace(" y=", xtd::string::empty_string).replace("{x=", xtd::string::empty_string).split(',');
380 return {xtd::parse<int32>(values[0]), xtd::parse<int32>(values[1])};
381 }
382}
static const basic_string empty_string
Represents the empty basic_string.
Definition basic_string.hpp:124
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition point_f.hpp:35
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition point.hpp:54
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:60
point() noexcept=default
Initializes a new instance of the xtd::drawing::point class.
Stores an ordered pair of integers, which specify a height and width.
Definition size.hpp:31
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:42
#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
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::drawing::point_f class.