mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-28 09:30:56 +01:00
ImDrawList: added AddRectFilledMultiColor() helper + minor optimisation.
This commit is contained in:
parent
7a0004eb86
commit
6520b6c458
23
imgui.cpp
23
imgui.cpp
@ -9202,10 +9202,10 @@ void ImDrawList::AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float roun
|
||||
if (r == 0.0f || rounding_corners == 0)
|
||||
{
|
||||
PrimReserve(4*6);
|
||||
PrimLine(ImVec2(a.x,a.y), ImVec2(b.x,a.y), col);
|
||||
PrimLine(ImVec2(b.x,a.y), ImVec2(b.x,b.y), col);
|
||||
PrimLine(ImVec2(b.x,b.y), ImVec2(a.x,b.y), col);
|
||||
PrimLine(ImVec2(a.x,b.y), ImVec2(a.x,a.y), col);
|
||||
PrimLine(a, ImVec2(b.x,a.y), col);
|
||||
PrimLine(ImVec2(b.x,a.y), b, col);
|
||||
PrimLine(b, ImVec2(a.x,b.y), col);
|
||||
PrimLine(ImVec2(a.x,b.y), a, col);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -9257,6 +9257,21 @@ void ImDrawList::AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, floa
|
||||
}
|
||||
}
|
||||
|
||||
void ImDrawList::AddRectFilledMultiColor(const ImVec2& a, const ImVec2& b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left)
|
||||
{
|
||||
if (((col_upr_left | col_upr_right | col_bot_right | col_bot_left) >> 24) == 0)
|
||||
return;
|
||||
|
||||
const ImVec2 uv = GImGui->FontTexUvWhitePixel;
|
||||
PrimReserve(6);
|
||||
PrimVtx(a, uv, col_upr_left);
|
||||
PrimVtx(ImVec2(b.x,a.y), uv, col_upr_right);
|
||||
PrimVtx(ImVec2(b.x,b.y), uv, col_bot_right);
|
||||
PrimVtx(a, uv, col_upr_left);
|
||||
PrimVtx(b, uv, col_bot_right);
|
||||
PrimVtx(ImVec2(a.x,b.y), uv, col_bot_left);
|
||||
}
|
||||
|
||||
void ImDrawList::AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col)
|
||||
{
|
||||
if ((col >> 24) == 0)
|
||||
|
1
imgui.h
1
imgui.h
@ -1044,6 +1044,7 @@ struct ImDrawList
|
||||
IMGUI_API void AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thickness = 1.0f);
|
||||
IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F);
|
||||
IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F);
|
||||
IMGUI_API void AddRectFilledMultiColor(const ImVec2& a, const ImVec2& b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left);
|
||||
IMGUI_API void AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col);
|
||||
IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
|
||||
IMGUI_API void AddCircleFilled(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12);
|
||||
|
Loading…
Reference in New Issue
Block a user