-
RE: Rotations in new Transform featureI was hoping that you could shed some light on a problem I am having while playing wIth the 2D Orbits examples in demo.py and in the doc. A minimal scenario involves me just changing the circle shape to a square shape. I kinda simply replace Why? What am I misunderstanding about these transforms? How do I use square shapes as planets instead of circles shapes? ScreenshotCodeimport math
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title='Rotation', width=400, height=400)
dpg.setup_dearpygui()
with dpg.viewport_drawlist(front=True, tag="vpf"):
with dpg.draw_node(tag="origin"):
dpg.apply_transform("origin", dpg.create_translation_matrix((50, 300)))
dpg.draw_circle((0, 0), 5, fill=(255, 255, 255))
dpg.draw_text((10, 0), 'origin', size=16)
for rot in [0.0, 30.0,45.0,60.0,90.0]:
with dpg.draw_node():
dpg.apply_transform(dpg.last_item(),
dpg.create_rotation_matrix(math.pi * rot/180.0, [0,0,-1]) * dpg.create_translation_matrix((200,0)))
dpg.draw_rectangle((0, 0), (40, 40))
dpg.draw_circle((0, 0), 20)
dpg.draw_text((45, 45), rot, size=16)
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context() |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, we probably should have documented this better. The transforms are acting on the points you input. For rectangle, the transforms are applying to pmin and pmax. Which is what you are seeing. For what I believe you are trying to do, you should be using |
Beta Was this translation helpful? Give feedback.
-
Thanks , Now I need to understand how the transforms work on the different method signatures - but that's an exercise for another day! (Any updates to the docs will be appreciated.) Ciao |
Beta Was this translation helpful? Give feedback.
Hi, we probably should have documented this better.
The transforms are acting on the points you input. For rectangle, the transforms are applying to pmin and pmax. Which is what you are seeing.
For what I believe you are trying to do, you should be using
dpg.draw_quad(...)
. Quads require you to input all 4 points, which when transformed, will give the effect you are looking for.