Is it me or the generated coordinates is too smooth and unnatural. even the time is too smooth, unlike what I see on readme demonstration. can somebody tell me if I doing things correctly?
import tkinter as tk
import sys
import os
import pytweening
# --- Setup ---
repo_path = os.path.join(os.path.dirname(__file__), 'HumanCursor')
if repo_path not in sys.path:
sys.path.append(repo_path)
try:
from humancursor.utilities.human_curve_generator import HumanizeMouseTrajectory
except ImportError as e:
print(f"Error importing HumanizeMouseTrajectory: {e}")
HumanizeMouseTrajectory = None
# --- Parameters ---
START_POS = (100, 100)
END_POS = (900, 200)
WINDOW_WIDTH = 1000
WINDOW_HEIGHT = 400
WINDOW_SIZE = f"{WINDOW_WIDTH}x{WINDOW_HEIGHT}"
DOT_RADIUS = 2
ANIMATION_DELAY_MS = 15 # ms per point
# --- Path Generation ---
if HumanizeMouseTrajectory:
try:
# Manually specify parameters to force a noticeable curve
curve_generator = HumanizeMouseTrajectory(
START_POS,
END_POS,
# More knots and larger boundaries create a more complex curve
knots_count=4,
offset_boundary_x=150,
offset_boundary_y=200,
target_points=150, # Increase the number of points for a smoother look
tween=pytweening.easeInOutQuad
)
generated_points = curve_generator.points
except Exception as e:
print(f"An error occurred during path generation: {e}")
generated_points = []
else:
generated_points = []
# --- GUI Visualization ---
def visualize_path():
root = tk.Tk()
root.title("HumanCursor Path Visualization")
root.geometry(WINDOW_SIZE)
canvas = tk.Canvas(root, bg="white")
canvas.pack(fill=tk.BOTH, expand=True)
canvas.create_oval(START_POS[0] - 5, START_POS[1] - 5, START_POS[0] + 5, START_POS[1] + 5, fill='green', outline='green')
canvas.create_text(START_POS[0], START_POS[1] - 15, text="Start")
canvas.create_oval(END_POS[0] - 5, END_POS[1] - 5, END_POS[0] + 5, END_POS[1] + 5, fill='red', outline='red')
canvas.create_text(END_POS[0], END_POS[1] - 15, text="End")
def draw_point(index):
if index >= len(generated_points):
print("Animation finished.")
return
point = generated_points[index]
x, y = point
canvas.create_oval(x - DOT_RADIUS, y - DOT_RADIUS, x + DOT_RADIUS, y + DOT_RADIUS, fill='black', outline='black')
canvas.after(ANIMATION_DELAY_MS, draw_point, index + 1)
if len(generated_points) > 0:
print(f"Generated {len(generated_points)} points. Starting animation...")
draw_point(0)
else:
canvas.create_text(500, 200, text="Could not generate path.", font=("Arial", 16), fill="red")
root.mainloop()
if __name__ == "__main__":
visualize_path()
Is it me or the generated coordinates is too smooth and unnatural. even the time is too smooth, unlike what I see on readme demonstration. can somebody tell me if I doing things correctly?