acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
shift.h
1#pragma once
2
3
4
5// Δ greek delta
6
7
8template < prototype_number NUMBER >
9class shift_type
10{
11public:
12
13 using UNIT_TYPE = NUMBER;
14
15 NUMBER Δx;
16 NUMBER Δy;
17
18
19 shift_type() noexcept { this->Δx = (UNIT_TYPE)0; this->Δy = (UNIT_TYPE)0; }
20 shift_type(no_initialize_t) noexcept { }
21 shift_type(nullptr_t) noexcept { this->Δx = (UNIT_TYPE)0; this->Δy = (UNIT_TYPE)0; }
22 template < prototype_number X, prototype_number Y >
23 shift_type(X x, Y y) noexcept { this->Δx = (UNIT_TYPE) x; this->Δy = (UNIT_TYPE) y; }
24 template < prototype_sequence2 SEQUENCE >
25 shift_type(const SEQUENCE & s) { this->Δx = (UNIT_TYPE)s.x; this->Δy = (UNIT_TYPE)s.y; }
26 // template < prototype_size SIZE >
27 // shift_type(const SIZE & size) { this->Δx = (UNIT_TYPE)size.cx; this->Δy = (UNIT_TYPE)size.cy; }
28
29
30 shift_type operator -() const { return { -this->Δx, -this->Δy }; }
31
32
33 shift_type operator +(const shift_type & shift) const { return { this->Δx + shift.Δx, this->Δy + shift.Δy }; }
34 shift_type operator -(const shift_type & shift) const { return { this->Δx - shift.Δx, this->Δy - shift.Δy }; }
35
36
37 template < prototype_sequence2 SEQUENCE >
38 inline SEQUENCE & operator()(SEQUENCE & s) const noexcept
40 {
41
42 s.x = (::std::decay_t<decltype(s.x)>)(s.x + this->Δx);
43
44 s.y = (::std::decay_t<decltype(s.y)>)(s.y + this->Δy);
45
46 return s;
47
48 }
49
50
51 // template < prototype_size SIZE >
52 // inline SIZE & operator()(SIZE & size) const noexcept
53 // {
54 //
55 // size.cx = (::std::decay_t<decltype(size.cx)>)(size.cx + this->Δx);
56 //
57 // size.cy = (::std::decay_t<decltype(size.cy)>)(size.cy + this->Δy);
58 //
59 // return size;
60 //
61 // }
62
63
64 template < prototype_rectangle RECTANGLE >
65 inline RECTANGLE & operator()(RECTANGLE & rectangle) const noexcept
66 {
67
68 rectangle.left = (::std::decay_t<decltype(rectangle.left)>)(rectangle.left + this->Δx);
69
70 rectangle.top = (::std::decay_t<decltype(rectangle.top)>)(rectangle.top + this->Δy);
71
72 rectangle.right = (::std::decay_t<decltype(rectangle.right)>)(rectangle.right + this->Δx);
73
74 rectangle.bottom = (::std::decay_t<decltype(rectangle.bottom)>)(rectangle.bottom + this->Δy);
75
76 return rectangle;
77
78 }
79
80
81 template < prototype_point POINT >
82 inline POINT get(const POINT & point) const noexcept { return { (decltype(point.x))(point.x + this->Δx), (decltype(point.y))(point.y + this->Δy) }; }
83
84 template < prototype_size SIZE >
85 inline SIZE get(const SIZE & size) const noexcept { return { (decltype(size.cx))(size.cx + this->Δx), (decltype(size.cy))(size.cy + this->Δy) }; }
86
87 template < prototype_rectangle RECTANGLE >
88 inline RECTANGLE get(const RECTANGLE & rectangle) const noexcept { return { (decltype(rectangle.left))(rectangle.left + this->Δx), (decltype(rectangle.top))(rectangle.top + this->Δy), (decltype(rectangle.right))(rectangle.right + this->Δx), (decltype(rectangle.bottom))(rectangle.bottom + this->Δy) }; }
89
90
91};
92
93
94using shift_int = shift_type < ::i32 >;
95
96
97
Definition _aaa_other_initial_concepts.h:77
Definition _tags.h:5