-
-
Notifications
You must be signed in to change notification settings - Fork 703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does it support polygon frames #2453
Comments
It's not clear what you mean or what help you might need. Would you please provide a detailed description of your issue? |
bandicam.2024-12-25.17-07-50-252.mp4
|
Well, that's something you have to do on your own 😂. If you need some ideas on how this can be implemented, here's an example I recently made for a question asked on Discord. from math import sin
import dearpygui.dearpygui as dpg
dpg.create_context()
dpg.create_viewport(title=f"Test - {dpg.get_dearpygui_version()}", width=700, height=750)
def on_point_dragged(drag_point, app_data, idx):
new_x, new_y = dpg.get_value(drag_point)
xs, ys, *_ = dpg.get_value("line-series")
# Uncomment this if you need X to be clamped between the neighbour points
# if idx > 0 and new_x < xs[idx - 1]:
# new_x = xs[idx - 1]
# dpg.set_value(drag_point, (new_x, new_y))
# elif idx < len(xs) - 1 and new_x > xs[idx + 1]:
# new_x = xs[idx + 1]
# dpg.set_value(drag_point, (new_x, new_y))
xs[idx] = new_x
ys[idx] = new_y
dpg.set_value("line-series", (xs, ys))
with dpg.window() as wnd:
dpg.set_primary_window(dpg.last_item(), True)
x_data = [x/3 for x in range(0, 30)]
y_data = [sin(x) for x in x_data]
with dpg.theme() as marker_theme:
with dpg.theme_component():
dpg.add_theme_style(dpg.mvPlotStyleVar_Marker, dpg.mvPlotMarker_Circle, category=dpg.mvThemeCat_Plots)
with dpg.plot(width=-1, height=-1, tag="plot"):
x_axis = dpg.add_plot_axis(dpg.mvXAxis, label="x")
with dpg.plot_axis(dpg.mvYAxis, label="y", no_label=True) as y_axis:
dpg.add_line_series(x_data, y_data, label="Line series", tag="line-series")
dpg.bind_item_theme(dpg.last_item(), marker_theme)
for i, (x, y) in enumerate(zip(x_data, y_data)):
dpg.add_drag_point(label="", default_value=(x, y), callback=on_point_dragged, user_data=i, color=(0, 0, 0, 0))
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context() |
wow As long as there is code reference Thank you very much for your help |
Hello, I found this issue after modifying your code based on it from math import sin
import dearpygui.dearpygui as dpg
import math
dpg.create_context()
dpg.create_viewport(title=f"Test - {dpg.get_dearpygui_version()}", width=700, height=750)
def on_point_dragged(drag_point, app_data, idx):
new_x, new_y = dpg.get_value(drag_point)
xs, ys, *_ = dpg.get_value("line-series")
# Uncomment this if you need X to be clamped between the neighbour points
# if idx > 0 and new_x < xs[idx - 1]:
# new_x = xs[idx - 1]
# dpg.set_value(drag_point, (new_x, new_y))
# elif idx < len(xs) - 1 and new_x > xs[idx + 1]:
# new_x = xs[idx + 1]
# dpg.set_value(drag_point, (new_x, new_y))
xs[idx] = new_x
ys[idx] = new_y
dpg.set_value("line-series", (xs, ys))
with dpg.window() as wnd:
dpg.set_primary_window(dpg.last_item(), True)
num_points = 10
radius = 5
theta = [2 * math.pi * i / num_points for i in range(num_points)]
x_data = [radius * math.cos(t) for t in theta]
y_data = [radius * math.sin(t) for t in theta]
with dpg.plot(width=-1, height=-1, tag="plot"):
x_axis = dpg.add_plot_axis(dpg.mvXAxis, label="x")
with dpg.plot_axis(dpg.mvYAxis, label="y") as y_axis:
dpg.add_line_series(x_data, y_data, label="Circle", tag="line-series",shaded=True)
for i, (x, y) in enumerate(zip(x_data, y_data)):
dpg.add_drag_point(label="", default_value=(x, y), callback=on_point_dragged, user_data=i, color=(0, 0, 0, 0))
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context() |
I believe you can use |
Well.. turns out that #2045 ruins the idea of using |
Another option is dpg.add_area_series(x_data, y_data, tag="line-series", fill=(255, 255, 255, 255)) Works just fine. |
polygon
The text was updated successfully, but these errors were encountered: