From 862d459598cfde4c6fc547105adff8f57f328a50 Mon Sep 17 00:00:00 2001 From: Alexandre B A Villares <3694604+villares@users.noreply.github.com> Date: Mon, 2 Dec 2024 00:29:06 -0300 Subject: [PATCH] Create window_x_issue.py --- 2024/sketch_2024_12_01/window_x_issue.py | 30 ++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 2024/sketch_2024_12_01/window_x_issue.py diff --git a/2024/sketch_2024_12_01/window_x_issue.py b/2024/sketch_2024_12_01/window_x_issue.py new file mode 100644 index 00000000..5ece16b8 --- /dev/null +++ b/2024/sketch_2024_12_01/window_x_issue.py @@ -0,0 +1,30 @@ +import py5 + +def setup(): + global surface, f + py5.size(500, 500) + surface = py5.get_surface() + f = surface.get_native().getFrame() + +def draw(): + py5.circle(py5.width / 2, py5.height / 2, py5.width) + py5.window_x = py5.mouse_x + +def mouse_pressed(): + global drag + drag = True + +def mouse_dragged(): + if drag: + dx = int((py5.mouse_x - py5.pmouse_x) * 0.90) + dy = int((py5.mouse_y - py5.pmouse_y) * 0.90) + #I should be able to use py5.window_x and _y but it didn't work + #py5.window_move(py5.window_x + dx, py5.window_y + dy) + py5.window_move(f.location().x + dx, f.location().y + dy) + print(f.location().x, f.location().y, py5.window_x, py5.window_y) + +def mouse_released(): + global drag + drag = False + +py5.run_sketch(block=False) \ No newline at end of file