-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfloatRect.cpp
More file actions
97 lines (87 loc) · 3.31 KB
/
floatRect.cpp
File metadata and controls
97 lines (87 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "stdafx.h"
#include "floatRect.h"
/**************************************************************************************************
## floatRect::floatRect ##
**************************************************************************************************/
floatRect::floatRect()
:left(0.f), top(0.f), right(0.f), bottom(0.f) {}
floatRect::floatRect(const float& left, const float& top, const float& right, const float& bottom)
: left(left), top(top), right(right), bottom(bottom) {}
floatRect::floatRect(const int& left, const int& top, const int& right, const int& bottom)
: left((float)left), top((float)top), right((float)right), bottom((float)bottom) {}
floatRect::floatRect(const Vector2& pos, const Vector2& size, const pivot& pivot)
{
*this = RectMakePivot(pos, size, pivot);
}
floatRect::floatRect(const RECT& rc)
:left((float)rc.left), top((float)rc.top), right((float)rc.right), bottom((float)rc.bottom) {}
/**************************************************************************************************
## floatRect::getRect ##
@@ return RECT : LONG형 RECT로 변환 후 반환
**************************************************************************************************/
const RECT floatRect::getRect()
{
return { (LONG)left,(LONG)top,(LONG)right,(LONG)bottom };
}
float floatRect::GetWidth()
{
return right - left;
}
float floatRect::GetHeight()
{
return bottom - top;
}
/**************************************************************************************************
## floatRect::getCenter ##
@@ return Vector2 : 중심 좌표
**************************************************************************************************/
Vector2 floatRect::getCenter()
{
return Vector2(left + (right - left) / 2.f, top + (bottom - top) / 2.f);
}
Vector2 floatRect::GetBottom()
{
return Vector2(left + (right - left) / 2.f, bottom);
}
Vector2 floatRect::getSize()
{
return Vector2((right - left), (bottom - top));
}
/**************************************************************************************************
## floatRect::update ##
@@ Vector2 pos : 좌표
@@ Vector2 size : 사이즈
@@ Pivot pivot : 피봇
floatRect 정보 갱신
**************************************************************************************************/
void floatRect::update(const Vector2& pos, const Vector2& size, const pivot& pivot)
{
*this = ::RectMakePivot(pos, size, pivot);
}
void floatRect::set(const Vector2 & pos, const pivot& pivot)
{
*this = ::RectMakePivot(pos, Vector2(right - left, bottom - top), pivot);
}
/**************************************************************************************************
## floatRect::Move ##
@@ Vector2 moveValue : 이동방향 * 이동량
**************************************************************************************************/
void floatRect::Move(const Vector2& moveValue)
{
left += moveValue.x;
right += moveValue.x;
top += moveValue.y;
bottom += moveValue.y;
}
/**************************************************************************************************
## floatRect::operator = ##
@@ RECT rc : RECT
***************************************************************************************************/
const floatRect& ::floatRect::operator=(const RECT& rc)
{
this->left = (float)rc.left;
this->right = (float)rc.right;
this->top = (float)rc.top;
this->bottom = (float)rc.bottom;
return *this;
}