diff --git a/imgui.h b/imgui.h index 1d2728461..e1bc834da 100644 --- a/imgui.h +++ b/imgui.h @@ -3451,7 +3451,7 @@ enum ImDrawFlags_ // Stroke position relative to the shape outline ImDrawFlags_StrokeInside = 1 << 16, // Draw stroke inside of the shape outline (default for closed shapes and AddLineH, AddLineV functions) ImDrawFlags_StrokeCenter = 2 << 16, // Draw stroke at the center of the shape outline - ImDrawFlags_StrokeCenterPixelAligned = 3 << 16, // Draw stroke at the center of the shape outline, so that half thickness (rounded down) will be outside, and rest inside the shape outline. + ImDrawFlags_StrokeCenterAligned = 3 << 16, // Draw stroke at the center of the shape outline, so that half thickness (rounded down) will be outside, and rest inside the shape outline. ImDrawFlags_StrokeOutside = 4 << 16, // Draw stroke outside of the shape outline ImDrawFlags_StrokeLegacy = 5 << 16, // Use legacy positioning + enable MiterOnly and NoAAEnds flags. ImDrawFlags_StrokeMask_ = 0x07 << 16, diff --git a/imgui_demo.cpp b/imgui_demo.cpp index cc79bbc44..e340b1a56 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -10436,7 +10436,7 @@ static void ShowExampleAppCustomRendering(bool* p_open) ImGui::RadioButton("Default", &flags, ImDrawFlags_None); ImGui::SameLine(); ImGui::RadioButton("Inside", &flags, ImDrawFlags_StrokeInside); ImGui::SameLine(); ImGui::RadioButton("Center", &flags, ImDrawFlags_StrokeCenter); ImGui::SameLine(); - ImGui::RadioButton("CenterPixelAligned", &flags, ImDrawFlags_StrokeCenterPixelAligned); ImGui::SameLine(); + ImGui::RadioButton("CenterAligned", &flags, ImDrawFlags_StrokeCenterAligned); ImGui::SameLine(); ImGui::RadioButton("Outside", &flags, ImDrawFlags_StrokeOutside); ImGui::SameLine(); ImGui::RadioButton("Legacy", &flags, ImDrawFlags_StrokeLegacy); ImGui::CheckboxFlags("MiterOnly", &flags, ImDrawFlags_MiterOnly); ImGui::SameLine(); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index fc1e97a1c..7b832f73c 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -819,12 +819,12 @@ void ImDrawList::PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, c } -static float CalculateCenterPixelAlignedOffset(float thickness, float _FringeScale) +static float CalculateCenterAlignedOffset(float thickness, float _FringeScale) { // Old jumpy one. // return IM_TRUNC(thickness * 0.5f / _FringeScale) * _FringeScale; - // Calculate outside offset for stroke position CenterPixelAligned + // Calculate outside offset for stroke position CenterAligned // so that one side the of the line is always at pixel boundary. // On integer thickness both sides of the line are on pixel boundary. const float screen_thickness = thickness / _FringeScale; @@ -877,8 +877,8 @@ void ImDrawList::_AddPolyline(const ImVec2* points, ImVec2* normals, float* sqr_ float thickness0 = (thickness + fringe) * 0.5f; // Center (or legacy) if (stroke_pos == ImDrawFlags_StrokeOutside) thickness0 = thickness + fringe * 0.5f; - else if (stroke_pos == ImDrawFlags_StrokeCenterPixelAligned) - thickness0 = CalculateCenterPixelAlignedOffset(thickness, _FringeScale) + fringe * 0.5f; + else if (stroke_pos == ImDrawFlags_StrokeCenterAligned) + thickness0 = CalculateCenterAlignedOffset(thickness, _FringeScale) + fringe * 0.5f; else if (stroke_pos == ImDrawFlags_StrokeInside) thickness0 = fringe * 0.5f; float thickness1 = (thickness + fringe) - thickness0; @@ -2137,8 +2137,8 @@ void ImDrawList::AddLineH(float min_x, float max_x, float y, ImU32 col, float th float top_y = y; // Inside if (stroke_pos == ImDrawFlags_StrokeCenter) top_y -= thickness * 0.5f; - else if (stroke_pos == ImDrawFlags_StrokeCenterPixelAligned) - top_y -= CalculateCenterPixelAlignedOffset(thickness, _FringeScale); + else if (stroke_pos == ImDrawFlags_StrokeCenterAligned) + top_y -= CalculateCenterAlignedOffset(thickness, _FringeScale); else if (stroke_pos == ImDrawFlags_StrokeOutside) top_y -= thickness; @@ -2176,8 +2176,8 @@ void ImDrawList::AddLineV(float x, float min_y, float max_y, ImU32 col, float th float left_x = x; // Inside if (stroke_pos == ImDrawFlags_StrokeCenter) left_x -= thickness * 0.5f; - else if (stroke_pos == ImDrawFlags_StrokeCenterPixelAligned) - left_x -= CalculateCenterPixelAlignedOffset(thickness, _FringeScale); + else if (stroke_pos == ImDrawFlags_StrokeCenterAligned) + left_x -= CalculateCenterAlignedOffset(thickness, _FringeScale); else if (stroke_pos == ImDrawFlags_StrokeOutside) left_x -= thickness; @@ -2460,8 +2460,8 @@ void ImDrawList::AddRect(const ImVec2& p_min, const ImVec2& p_max, ImU32 col, fl float offset = 0.0f; // Inside if (stroke_pos == ImDrawFlags_StrokeCenter) offset = thickness * 0.5f; - else if (stroke_pos == ImDrawFlags_StrokeCenterPixelAligned) - offset = CalculateCenterPixelAlignedOffset(thickness, _FringeScale); + else if (stroke_pos == ImDrawFlags_StrokeCenterAligned) + offset = CalculateCenterAlignedOffset(thickness, _FringeScale); else if (stroke_pos == ImDrawFlags_StrokeOutside) offset = thickness; outer_min.x -= offset; @@ -2737,8 +2737,8 @@ void ImDrawList::AddCircle(const ImVec2& center, float radius, ImU32 col, int nu float outer_radius = radius; if (stroke_pos == ImDrawFlags_StrokeCenter) outer_radius = radius + thickness * 0.5f; - else if (stroke_pos == ImDrawFlags_StrokeCenterPixelAligned) - outer_radius = radius + CalculateCenterPixelAlignedOffset(thickness, _FringeScale); + else if (stroke_pos == ImDrawFlags_StrokeCenterAligned) + outer_radius = radius + CalculateCenterAlignedOffset(thickness, _FringeScale); else if (stroke_pos == ImDrawFlags_StrokeInside) outer_radius = radius; else if (stroke_pos == ImDrawFlags_StrokeOutside) @@ -2822,8 +2822,8 @@ void ImDrawList::AddNgon(const ImVec2& center, float radius, ImU32 col, int num_ float outer_radius = radius; if (stroke_pos == ImDrawFlags_StrokeCenter) outer_radius = radius + miter_thickness * 0.5f; - else if (stroke_pos == ImDrawFlags_StrokeCenterPixelAligned) - outer_radius = radius + CalculateCenterPixelAlignedOffset(miter_thickness, _FringeScale); + else if (stroke_pos == ImDrawFlags_StrokeCenterAligned) + outer_radius = radius + CalculateCenterAlignedOffset(miter_thickness, _FringeScale); else if (stroke_pos == ImDrawFlags_StrokeInside) outer_radius = radius; else if (stroke_pos == ImDrawFlags_StrokeOutside)