MCPcopy Create free account
hub / github.com/RenderKit/embree / RenderRectFilledRangeH

Method RenderRectFilledRangeH

tutorials/common/imgui/imgui_draw.cpp:3827–3885  ·  view source on GitHub ↗

FIXME: Cleanup and move code to ImDrawList.

Source from the content-addressed store, hash-verified

3825
3826// FIXME: Cleanup and move code to ImDrawList.
3827void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding)
3828{
3829 if (x_end_norm == x_start_norm)
3830 return;
3831 if (x_start_norm > x_end_norm)
3832 ImSwap(x_start_norm, x_end_norm);
3833
3834 ImVec2 p0 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_start_norm), rect.Min.y);
3835 ImVec2 p1 = ImVec2(ImLerp(rect.Min.x, rect.Max.x, x_end_norm), rect.Max.y);
3836 if (rounding == 0.0f)
3837 {
3838 draw_list->AddRectFilled(p0, p1, col, 0.0f);
3839 return;
3840 }
3841
3842 rounding = ImClamp(ImMin((rect.Max.x - rect.Min.x) * 0.5f, (rect.Max.y - rect.Min.y) * 0.5f) - 1.0f, 0.0f, rounding);
3843 const float inv_rounding = 1.0f / rounding;
3844 const float arc0_b = ImAcos01(1.0f - (p0.x - rect.Min.x) * inv_rounding);
3845 const float arc0_e = ImAcos01(1.0f - (p1.x - rect.Min.x) * inv_rounding);
3846 const float half_pi = IM_PI * 0.5f; // We will == compare to this because we know this is the exact value ImAcos01 can return.
3847 const float x0 = ImMax(p0.x, rect.Min.x + rounding);
3848 if (arc0_b == arc0_e)
3849 {
3850 draw_list->PathLineTo(ImVec2(x0, p1.y));
3851 draw_list->PathLineTo(ImVec2(x0, p0.y));
3852 }
3853 else if (arc0_b == 0.0f && arc0_e == half_pi)
3854 {
3855 draw_list->PathArcToFast(ImVec2(x0, p1.y - rounding), rounding, 3, 6); // BL
3856 draw_list->PathArcToFast(ImVec2(x0, p0.y + rounding), rounding, 6, 9); // TR
3857 }
3858 else
3859 {
3860 draw_list->PathArcTo(ImVec2(x0, p1.y - rounding), rounding, IM_PI - arc0_e, IM_PI - arc0_b, 3); // BL
3861 draw_list->PathArcTo(ImVec2(x0, p0.y + rounding), rounding, IM_PI + arc0_b, IM_PI + arc0_e, 3); // TR
3862 }
3863 if (p1.x > rect.Min.x + rounding)
3864 {
3865 const float arc1_b = ImAcos01(1.0f - (rect.Max.x - p1.x) * inv_rounding);
3866 const float arc1_e = ImAcos01(1.0f - (rect.Max.x - p0.x) * inv_rounding);
3867 const float x1 = ImMin(p1.x, rect.Max.x - rounding);
3868 if (arc1_b == arc1_e)
3869 {
3870 draw_list->PathLineTo(ImVec2(x1, p0.y));
3871 draw_list->PathLineTo(ImVec2(x1, p1.y));
3872 }
3873 else if (arc1_b == 0.0f && arc1_e == half_pi)
3874 {
3875 draw_list->PathArcToFast(ImVec2(x1, p0.y + rounding), rounding, 9, 12); // TR
3876 draw_list->PathArcToFast(ImVec2(x1, p1.y - rounding), rounding, 0, 3); // BR
3877 }
3878 else
3879 {
3880 draw_list->PathArcTo(ImVec2(x1, p0.y + rounding), rounding, -arc1_e, -arc1_b, 3); // TR
3881 draw_list->PathArcTo(ImVec2(x1, p1.y - rounding), rounding, +arc1_b, +arc1_e, 3); // BR
3882 }
3883 }
3884 draw_list->PathFillConvex(col);

Callers

nothing calls this directly

Calls 12

ImSwapFunction · 0.85
ImVec2Function · 0.85
ImLerpFunction · 0.85
ImClampFunction · 0.85
ImMinFunction · 0.85
ImAcos01Function · 0.85
ImMaxFunction · 0.85
AddRectFilledMethod · 0.80
PathLineToMethod · 0.80
PathArcToFastMethod · 0.80
PathArcToMethod · 0.80
PathFillConvexMethod · 0.80

Tested by

no test coverage detected