pthom / imgui_bundle

Dear ImGui Bundle: an extensive set of Ready-to-use widgets and libraries, based on ImGui. Start your first app in 5 lines of code, or less. Whether you prefer Python or C++, this pack has your back!
https://pthom.github.io/imgui_bundle/
MIT License
590 stars 62 forks source link

missing draw-list concave fill #213

Closed Rewasvat closed 1 month ago

Rewasvat commented 1 month ago

I have to do some custom rendering, and had to draw a concave polygon.

Checking your Imgui Manual in the custom rendering example, it shows its possible.

However I'm using in python, and the path_fill_concave/add_concave_poly_filled that exist (with their proper names) in C++ don't exist in the python bindings.

Is there any way I can do this with the python bindings? Or was there some reason to not bind the concave functions?

I know I can split the poly into several convex ones and draw those, but it would be much simpler if I could just draw the concave poly directly.

pthom commented 1 month ago

Hello! I just added bindings for add_concave_poly_filled in this commit: https://github.com/pthom/imgui_bundle/commit/e5375f22fc722a86af9e3f17fbcc9607d18c0bb4

Wheels are being built and should be available here in a few hours: https://github.com/pthom/imgui_bundle/actions/runs/9172317864

Example usage:

from imgui_bundle import imgui, hello_imgui, ImVec2, ImVec4

def gui():
    imgui.text("Hello, world!")
    imgui.get_window_draw_list().add_concave_poly_filled(
        [
            ImVec2(0, 0),
            ImVec2(100, 0),
            ImVec2(200, 100),
            ImVec2(300, 0),
            ImVec2(400, 0),
            ImVec2(400, 100),
            ImVec2(300, 200),
            ImVec2(400, 300),
            ImVec2(400, 400),
            ImVec2(300, 400),
            ImVec2(200, 300),
            ImVec2(100, 400),
            ImVec2(0, 400),
            ImVec2(0, 300),
            ImVec2(100, 200),
            ImVec2(0, 100),
        ],
        imgui.color_convert_float4_to_u32(ImVec4(0, 1, 0, 1)),
    )

def main():
    hello_imgui.run(gui)

if __name__ == "__main__":
    main()
image
Rewasvat commented 1 month ago

That was fast, thanks!

Seeing the commit diff I thought path_fill_concave wasn't binded, but I finally got around downloading the new wheel you built and path_fill_concave is there.

Tested it out here and it's working. Thanks again =)

pthom commented 1 month ago

Thanks for keeping me informed.