-
Notifications
You must be signed in to change notification settings - Fork 2
/
commonMacroFunction.h
73 lines (63 loc) · 1.79 KB
/
commonMacroFunction.h
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
#pragma once
//=============================================================
// ## commonMacroFunction ##
//=============================================================
//POINT
inline POINT PointMake(int x, int y)
{
POINT pt = { x, y };
return pt;
}
//선 그리기
inline void LineMake(HDC hdc, int startX, int startY, int endX, int endY)
{
MoveToEx(hdc, startX, startY, NULL);
LineTo(hdc, endX, endY);
}
//RECT 만들기
//RECT rc = { 128, 59, 228, 159 };
//RECT rc = RectMake(128, 59, 100, 100)
inline RECT RectMake(int x, int y, int width, int height)
{
RECT rc = { x, y, x + width, y + height };
return rc;
}
//RECT 중심좌표로 만들기
inline RECT RectMakeCenter(int x, int y, int width, int height)
{
RECT rc = { x - width / 2, y - height / 2, x + width / 2, y + height / 2 };
return rc;
}
//Rectangle 함수 이용해서 사각형 그리기
inline void RectangleMake(HDC hdc, int x, int y, int width, int height)
{
Rectangle(hdc, x, y, x + width, y + height);
}
//Ellipse 함수 이용해서 타원 그리기
inline void EllipseMake(HDC hdc, int x, int y, int width, int height)
{
Ellipse(hdc, x, y, x + width, y + height);
}
//Ellipse 함수 이용해서 타원 중심좌표에 그리기
inline void EllipseMakeCenter(HDC hdc, int x, int y, int width, int height)
{
Ellipse(hdc, x - width / 2, y - height / 2, x + width / 2, y + height / 2);
}
//편하쥬?
inline void Rectangle(HDC hdc, RECT rc)
{
Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
}
//프레임렉트 함수 오버로딩(비어있는 렉트 만들기)
inline void FrameRect(HDC hdc, RECT rc, COLORREF color)
{
HBRUSH brush = CreateSolidBrush(color);
FrameRect(hdc, &rc, brush);
DeleteObject(brush);
}
//텍스트 출력 편하게 사용하자
inline void textOut(HDC hdc, int x, int y, const char* text, COLORREF color = RGB(255, 0, 0))
{
SetTextColor(hdc, color);
TextOut(hdc, x, y, text, strlen(text));
}