-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrawing.cpp
More file actions
45 lines (39 loc) · 1.61 KB
/
Copy pathdrawing.cpp
File metadata and controls
45 lines (39 loc) · 1.61 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
#include "include.h"
void DrawFilledRect(int x, int y, int w, int h, D3DCOLOR color)
{
D3DRECT rect = { x,y,x + w,y + h };
pDevice->Clear(1, &rect, D3DCLEAR_TARGET, color, 0, 0);
}
void DrawLine(int x1, int y1, int x2, int y2, int thickness, bool antialias, D3DCOLOR color) {
ID3DXLine* LineL;
D3DXCreateLine(pDevice, &LineL);
D3DXVECTOR2 lines[2] = {
D3DXVECTOR2(x1, y1),
D3DXVECTOR2(x2, y2)
};
LineL->SetWidth(thickness);
LineL->SetAntialias(antialias);
LineL->Draw(lines, 2, color);
LineL->Release();
}
void DrawBox(int x, int y, int w, int h, int thickness, bool antialias, D3DCOLOR color)
{
DrawLine(x, y, x + w, y, thickness, antialias, color);
DrawLine(x, y + h, x + w, y + h, thickness, antialias, color);
DrawLine(x, y, x, y + h, thickness, antialias, color);
DrawLine(x + w, y, x + w, y + h, thickness, antialias, color);
}
void CornerBox(int x, int y, int w, int h, int thickness, float cornered, bool antialias, D3DCOLOR color) {
// Left Top
DrawLine(x, y, x + (w * cornered), y, thickness, antialias, color);
DrawLine(x, y, x, y + (h * cornered), thickness, antialias, color);
// Left Bottom
DrawLine(x, y + h, x + (w * cornered), y + h, thickness, antialias, color);
DrawLine(x, y + h, x, (y + h) - (h * cornered), thickness, antialias, color);
// Right Top
DrawLine(x + w, y, (x + w) - (w * cornered), y, thickness, antialias, color);
DrawLine(x + w, y, x + w, y + (h * cornered), thickness, antialias, color);
// Right Bottom
DrawLine(x + w, y + h, (x + w) - (w * cornered), y + h, thickness, antialias, color);
DrawLine(x + w, y + h, x + w, (y + h) - (h * cornered), thickness, antialias, color);
}