DearPyGui icon indicating copy to clipboard operation
DearPyGui copied to clipboard

dpg.draw_text cannot rotate by applying a rotation matrix.

Open DokaebiYe opened this issue 1 year ago • 7 comments

Version: 1.10.1 Operating System: Windows 11

My Issue/Question

The text drew by dpg.draw_text cannot be rotate.

To Reproduce

Steps to reproduce the behavior: 1.add a draw_node 2.use draw_text in draw node 3.apply the draw node a rotation matrix 4.only the text draw won't rotate,but other draws( lines, rects, circles, etc) is normal.

Expected behavior

the text draw should normally be rotate after applying the transform matrix to it's parent(draw_node)

Screenshots/Video

image

Standalone, minimal, complete and verifiable example

import dearpygui.dearpygui as dpg,math

dpg.create_context()
dpg.create_viewport()
dpg.setup_dearpygui()

with dpg.window(label="tutorial", width=550, height=550):
    with dpg.drawlist(width=500, height=500):
        with dpg.draw_node(tag="root node"):
            dpg.draw_text([0,0],text='test Text', color=[255, 255, 255], size=20)


dpg.apply_transform("root node", dpg.create_rotation_matrix(math.pi*0.5, [0,0,-1]))

dpg.show_viewport()
while dpg.is_dearpygui_running():
    dpg.render_dearpygui_frame()

dpg.destroy_context()

DokaebiYe avatar Feb 20 '24 08:02 DokaebiYe

Depending on the use case, you might want for text to actually keep its orientation regardless of rotation :joy: (e.g. text labels). So there should probably be an option to control that.

With regards to implementation, the following discussion looks interesting: https://github.com/ocornut/imgui/issues/1286

v-ein avatar Feb 20 '24 08:02 v-ein

Yes, it's looks nice. so will next dpg version add this option? it's crucial for making widgets like selection wheel

DokaebiYe avatar Feb 20 '24 09:02 DokaebiYe

Honestly, I wouldn't count on it. DPG is in maintenance mode and no new features are expected. You (or anyone else for that matter) could implement it on your own, and open a pull request to merge into DPG.

DPG developers are now working on another library named Pilot Light: https://github.com/hoffstadt/pilotlight

This one is supposed to solve many (architectural) issues DPG has, but it will be a different library and a different API. With their main focus on Pilot Light, resources for DPG are limited.

v-ein avatar Feb 20 '24 11:02 v-ein

Since I couldn't find this information anywhere, it seems rotation matrices also don't work for draw_image?

ndahn avatar Jun 29 '24 18:06 ndahn

If you want to rotate the image itself, you need draw_image_quad, but it doesn't really work: #2121. There's a pull request that's expected to fix that issue, but it's been postponed until #2275 gets merged (probably for a month, maybe longer).

v-ein avatar Jun 29 '24 19:06 v-ein

And, yes, draw_image contents doesn't get rotated.

v-ein avatar Jun 29 '24 19:06 v-ein

Thanks, I wasn't aware of that function yet! Will rotate the pixel buffer until the fix is merged.

ndahn avatar Jun 30 '24 11:06 ndahn