xtd 0.2.0
matrix.h
Go to the documentation of this file.
1 #pragma once
5 #include "../../drawing_export.h"
6 #include "../point.h"
7 #include "../point_f.h"
8 #include "../rectangle.h"
9 #include "../rectangle_f.h"
10 #include "drawing2d.h"
11 #include "matrix_order.h"
12 #include <xtd/iequatable>
13 #include <xtd/object>
14 #include <xtd/ustring>
15 #include <cstdint>
16 #include <ostream>
17 
19 namespace xtd {
21  namespace drawing {
23  class graphics;
25 
27  namespace drawing_2d {
74  class drawing_export_ matrix final : public object, public xtd::iequatable<matrix> {
75  struct data;
76 
77  public:
79 
81  matrix();
89  matrix(float m11, float m12, float m21, float m22, float dx, float dy);
94  matrix(const xtd::drawing::rectangle& rect, const std::vector<xtd::drawing::point>& plgpts);
99  matrix(const xtd::drawing::rectangle_f& rect, const std::vector<xtd::drawing::point_f>& plgpts);
101 
104  matrix& operator =(const xtd::drawing::drawing_2d::matrix& value);
105  ~matrix();
107 
109 
114  std::vector<float> elements() const;
115 
118  intptr handle() const noexcept;
119 
122  bool is_identity() const;
123 
126  bool is_invertible() const;
127 
130  float offset_x() const;
131 
134  float offset_y() const;
136 
138 
140  bool equals(const xtd::drawing::drawing_2d::matrix& value) const noexcept override;
141 
143  void invert();
144 
152 
155  void reset();
156 
159  void rotate(float angle);
163  void rotate(float angle, xtd::drawing::drawing_2d::matrix_order order);
164 
168  void rotate_at(float angle, const xtd::drawing::point_f& point);
173  void rotate_at(float angle, const xtd::drawing::point_f& point, xtd::drawing::drawing_2d::matrix_order order);
174 
178  void scale(float scale_x, float scale_y);
183  void scale(float scale_x, float scale_y, xtd::drawing::drawing_2d::matrix_order order);
184 
189  void shear(float scale_x, float scale_y);
195  void shear(float scale_x, float scale_y, xtd::drawing::drawing_2d::matrix_order order);
196 
199  void transform_points(std::vector<xtd::drawing::point>& points);
202  void transform_points(std::vector<xtd::drawing::point_f>& points);
203 
206  void transform_vectors(std::vector<xtd::drawing::point>& points);
209  void transform_vectors(std::vector<xtd::drawing::point_f>& points);
210 
214  void translate(float offset_x, float offset_y);
219  void translate(float offset_x, float offset_y, xtd::drawing::drawing_2d::matrix_order order);
220 
223  void vector_transform_points(std::vector<xtd::drawing::point>& points);
224 
225  xtd::ustring to_string() const noexcept override;
227 
228  private:
229  void init_from_rect_3points(const xtd::drawing::rectangle_f& rect, const xtd::drawing::point_f pt1, const xtd::drawing::point_f pt2, const xtd::drawing::point_f pt3);
230  friend class xtd::drawing::graphics;
231  explicit matrix(intptr handle);
232 
233  std::shared_ptr<data> data_;
234  };
235  }
236  }
237 }
Encapsulates a 3-by-3 affine matrix that represents a geometric transform. This class cannot be inher...
Definition: matrix.h:74
intmax_t intptr
Represent a pointer or a handle.
Definition: types.h:151
Represents an ordered pair of integer x- and y-coordinates that defines a point in a two-dimensional ...
Definition: point.h:54
The xtd namespace contains all fundamental classes to access Hardware, Os, System, and more.
Definition: system_report.h:17
Contains xtd::drawing::drawing_2d/::matrix_order enum class.
Stores a set of four floating-point numbers that represent the location and size of a rectangle...
Definition: rectangle_f.h:34
matrix_order
Specifies the order for matrix transform operations.
Definition: matrix_order.h:21
Represents text as a sequence of UTF-8 code units.
Definition: ustring.h:46
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:1063
Represents an ordered pair of floating-point x- and y-coordinates that defines a point in a two-dimen...
Definition: point_f.h:35
intptr handle() const noexcept
Gets the handle device context that the graphics is bound to.
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition: iequatable.h:18
Stores a set of four integers that represent the location and size of a rectangle.
Definition: rectangle.h:44
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes...
Definition: object.h:32
The Multiply key.
Contains xtd::drawing::drawing_2d/::matrix class.
Defines an object used to draw lines and curves. This class cannot be inherited.
Definition: graphics.h:70