Fixed ImDrawList::AddRect() which used to render a rectangle 1 px too large on each axis., fixed Image(), ImageButton() as well (#457)

This commit is contained in:
ocornut
2015-12-27 21:31:43 +01:00
parent 6dbdc69131
commit d212401624
3 changed files with 9 additions and 7 deletions

View File

@ -771,11 +771,12 @@ void ImDrawList::AddLine(const ImVec2& a, const ImVec2& b, ImU32 col, float thic
PathStroke(col, false, thickness);
}
// a: upper-left, b: lower-right. we don't render 1 px sized rectangles properly.
void ImDrawList::AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding, int rounding_corners)
{
if ((col >> 24) == 0)
return;
PathRect(a + ImVec2(0.5f,0.5f), b + ImVec2(0.5f,0.5f), rounding, rounding_corners);
PathRect(a + ImVec2(0.5f,0.5f), b - ImVec2(0.5f,0.5f), rounding, rounding_corners);
PathStroke(col, true);
}