-
Notifications
You must be signed in to change notification settings - Fork 11
/
Drawing.h
65 lines (52 loc) · 1.59 KB
/
Drawing.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
//
// Created by Rev on 29/05/2021.
//
#ifndef ImGuiAndroid_Drawing
#define ImGuiAndroid_Drawing
#include "../ImGui/imgui_internal.h"
namespace Drawing
{
void DrawLine(ImVec2 start, ImVec2 end, ImVec4 color)
{
auto background = ImGui::GetBackgroundDrawList();
if(background)
{
background->AddLine(start, end, ImColor(color.x, color.y, color.z, color.w));
}
}
void DrawBox(Rect rect, ImVec4 color)
{
ImVec2 v1(rect.x, rect.y);
ImVec2 v2(rect.x + rect.width, rect.y);
ImVec2 v3(rect.x + rect.width, rect.y + rect.height);
ImVec2 v4(rect.x, rect.y + rect.height);
DrawLine(v1, v2, color);
DrawLine(v2, v3, color);
DrawLine(v3, v4, color);
DrawLine(v4, v1, color);
}
void DrawCircle(float X, float Y, float radius, bool filled, ImVec4 color)
{
auto background = ImGui::GetBackgroundDrawList();
if(background)
{
if(filled)
{
background->AddCircleFilled(ImVec2(X, Y), radius, ImColor(color.x, color.y, color.z, color.w));
}
else
{
background->AddCircle(ImVec2(X, Y), radius, ImColor(color.x, color.y, color.z, color.w));
}
}
}
void DrawText2(float fontSize, ImVec2 position, ImVec4 color, const char *text)
{
auto background = ImGui::GetBackgroundDrawList();
if(background)
{
background->AddText(NULL, fontSize, position, ImColor(color.x, color.y, color.z, color.w), text);
}
}
}
#endif