MCPcopy Create free account
hub / github.com/MrDrElliot/LuminaEngine / DrawSpinner

Function DrawSpinner

Engine/Editor/Source/UI/SlowTaskModal.cpp:25–46  ·  view source on GitHub ↗

A rotating three-quarter arc, animated off ImGui::GetTime().

Source from the content-addressed store, hash-verified

23
24 // A rotating three-quarter arc, animated off ImGui::GetTime().
25 void DrawSpinner(float Radius, float Thickness, ImU32 Color)
26 {
27 const ImVec2 TopLeft = ImGui::GetCursorScreenPos();
28 const ImVec2 Center = ImVec2(TopLeft.x + Radius, TopLeft.y + Radius);
29
30 ImDrawList* DrawList = ImGui::GetWindowDrawList();
31 constexpr int Segments = 32;
32 const float Time = static_cast<float>(ImGui::GetTime());
33 const float Start = Time * 5.0f;
34 const float ArcSpan = IM_PI * 1.5f;
35
36 DrawList->PathClear();
37 for (int i = 0; i <= Segments; ++i)
38 {
39 const float Angle = Start + (static_cast<float>(i) / Segments) * ArcSpan;
40 DrawList->PathLineTo(ImVec2(Center.x + std::cos(Angle) * Radius,
41 Center.y + std::sin(Angle) * Radius));
42 }
43 DrawList->PathStroke(Color, Thickness, ImDrawFlags_None);
44
45 ImGui::Dummy(ImVec2(Radius * 2.0f, Radius * 2.0f));
46 }
47
48 void DrawTask(const FSlowTaskProgress& Task)
49 {

Callers 1

DrawTaskFunction · 0.85

Calls 5

PathClearMethod · 0.80
PathLineToMethod · 0.80
PathStrokeMethod · 0.80
ImVec2Function · 0.50
GetTimeFunction · 0.50

Tested by

no test coverage detected