xtd - Reference Guide  0.1.1
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
point_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 
13 namespace xtd {
15  namespace drawing {
17  class size;
19 
26  class drawing_export_ point_f : public object {
27  public:
28  static const point_f empty;
29 
30  point_f() = default;
31  point_f(float x, float y) : x_(x), y_(y) {}
32 
34  point_f(const point_f&) = default;
35  point_f& operator=(const point_f&) = default;
37 
38  bool operator==(const point_f& value) const {return x_ == value.x_ && y_ == value.y_;}
39 
40  bool operator!=(const point_f& value) const {return !operator==(value);}
41 
42  bool is_empty() const {return *this == point_f::empty;}
43 
44  void offset(const point_f& pt) {offset(pt.x_, pt.y_);}
45 
46  void offset(float dx, float dy) {
47  x_ += dx;
48  y_ += dy;
49  }
50 
51  xtd::ustring to_string() const noexcept override {return "{x=" + std::to_string(x_) + ", y=" + std::to_string(y_) + "}";}
52 
53  float x() const {return x_;}
54 
55  void x(float x) {x_ = x;}
56 
57  float y() const {return y_;}
58 
59  void y(float y) {y_ = y;}
60 
62  friend std::ostream& operator<<(std::ostream& os, const xtd::drawing::point_f& point) noexcept {
63  return os << point.to_string();
64  }
66 
67  private:
68  float x_ = 0;
69  float y_ = 0;
70  };
71  }
72 }
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition: point_f.h:26
xtd::ustring to_string() const noexcept override
Returns a std::string that represents the current object.
Definition: point_f.h:51
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
size_t size
Represents a size of any object in bytes.
Definition: types.h:171
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
@ y
The Y key.
@ x
The X key.
@ point
Specifies a printer's point (1/72 inch) as the unit of measure.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Contains xtd::object class.
Contains xtd::ustring class.