zhmiscellany 5.7.2__py3-none-any.whl → 5.7.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -130,8 +130,8 @@ def move_mouse(x: int, y: int, relative=False):
130
130
  normalized_y = int(y * (65535 / SCREEN_HEIGHT))
131
131
  else:
132
132
  if calibrated:
133
- normalized_x = math.ceil(x * calibration_multiplier_x)
134
- normalized_y = math.ceil(y * calibration_multiplier_y)
133
+ normalized_x = x * calibration_multiplier_x
134
+ normalized_y = y * calibration_multiplier_y
135
135
  else:
136
136
  normalized_x = x
137
137
  normalized_y = y
zhmiscellany/macro.py CHANGED
@@ -43,35 +43,60 @@ def click_pixel(x=None, y=None, click_duration=None, right_click=False, middle_c
43
43
  keys_down = []
44
44
 
45
45
  if animation_time:
46
+ def ease_in_out_sine(t: float) -> float:
47
+ return 0.5 * (1 - math.cos(math.pi * t))
48
+
49
+ def generate_movement_offsets(total_dx: int, total_dy: int, n_steps: int, ease: bool = True) -> list[tuple[int, int]]:
50
+ if n_steps <= 0:
51
+ return []
52
+
53
+ offsets = []
54
+
55
+ current_actual_x = 0
56
+ current_actual_y = 0
57
+
58
+ for i in range(n_steps):
59
+ t = (i + 1) / n_steps
60
+
61
+ if ease:
62
+ fraction_of_total_movement = ease_in_out_sine(t)
63
+ else:
64
+ fraction_of_total_movement = t
65
+
66
+ target_x = round(total_dx * fraction_of_total_movement)
67
+ target_y = round(total_dy * fraction_of_total_movement)
68
+
69
+ dx = int(target_x - current_actual_x)
70
+ dy = int(target_y - current_actual_y)
71
+
72
+ offsets.append((dx, dy))
73
+
74
+ current_actual_x += dx
75
+ current_actual_y += dy
76
+
77
+ return offsets
78
+
46
79
  mxy = get_mouse_xy()
47
80
  start = mxy
48
- if not relative:
49
- end = (x, y)
50
- else:
51
- end = tuple(a + b for a, b in zip(start, (x,y)))
81
+ end = (x, y)
52
82
  num_points = animation_fps*animation_time # 60 fps animation
53
- num_points += 2 # don't need start and end points
83
+ if not relative:
84
+ num_points += 2 # don't need start and end points
54
85
  num_points = math.ceil(num_points)
55
86
  if animation_easing:
56
- animation_points = zhmiscellany.math.generate_eased_points(start, end, num_points)
87
+ if not relative:
88
+ animation_points = zhmiscellany.math.generate_eased_points(start, end, num_points)
89
+ else:
90
+ animation_points = generate_movement_offsets(end[0], end[1], num_points)
57
91
  else:
58
- animation_points = zhmiscellany.math.generate_linear_points(start, end, num_points)
59
-
60
- if relative:
61
- temp = []
62
- for i, point in enumerate(animation_points):
63
- if i == 0:
64
- temp.append(tuple(a - b for a, b in zip(animation_points[i], start)))
65
- continue
66
-
67
- relative_point = tuple(a - b for a, b in zip(animation_points[i], animation_points[i-1]))
68
-
69
- temp.append(relative_point)
70
- animation_points = temp
92
+ if not relative:
93
+ animation_points = zhmiscellany.math.generate_linear_points(start, end, num_points)
94
+ else:
95
+ animation_points = generate_movement_offsets(end[0], end[1], num_points, ease=False)
71
96
 
72
97
  # remove start and end
73
- animation_points.pop(0)
74
98
  if not relative:
99
+ animation_points.pop(0)
75
100
  animation_points.pop()
76
101
  for point in animation_points:
77
102
  click_pixel((round(point[0]), round(point[1])), act_start=False, act_end=False, click_end_duration=1/animation_fps, relative=relative)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: zhmiscellany
3
- Version: 5.7.2
3
+ Version: 5.7.4
4
4
  Summary: A collection of useful/interesting python libraries made by zh.
5
5
  Home-page: https://discord.gg/ThBBAuueVJ
6
6
  Author: zh
@@ -1,7 +1,7 @@
1
1
  zhmiscellany/__init__.py,sha256=Oh3gAJRWq2aUEgkolmQyiZOQ3iey5OC4NA2XaTHuVv4,1139
2
2
  zhmiscellany/_discord_supportfuncs.py,sha256=RotSpurqFtL5q6v_ST1e2Y_1qJMaHp1CDsF5i-gR4ec,6524
3
3
  zhmiscellany/_fileio_supportfuncs.py,sha256=OIboEBVahqbpG1wbtrhAjoFV-oPylFVmOENOByawaX0,365
4
- zhmiscellany/_misc_supportfuncs.py,sha256=UvD7aFofx-0XlLKS01j81K2afHGtt8usb9-UdNCQCa4,6730
4
+ zhmiscellany/_misc_supportfuncs.py,sha256=DLu1QIt7PUulqgeMwi7RVh1Nu4xcsQs2wz8WxHogGNk,6708
5
5
  zhmiscellany/_processing_supportfuncs.py,sha256=aZKWIfJW_lVaQs_EyGGBhmoMc6btA38X2hY6A3kTxN8,10341
6
6
  zhmiscellany/_py_resources.py,sha256=HqJs5aRLymLZ2J5Io8g6bY58pGWhN9b8vCktC2DW4KQ,229009
7
7
  zhmiscellany/_resource_files_lookup.py,sha256=hsgPW0dngokgqWrAVAv5rUo-eobzJPjvWHt4xrOG5l0,856
@@ -12,7 +12,7 @@ zhmiscellany/fileio.py,sha256=KmRnWWZJWBc5Or3_mKcRY2ehE_Fuk870iS-imtyERyg,18169
12
12
  zhmiscellany/gui.py,sha256=VgT5j5UIr-wWyL2P1qCHSNL7RrvZWDlm0TX00JGWmKo,7404
13
13
  zhmiscellany/image.py,sha256=qUjxiYpc2VVZp2vwr1vN36O2PVQ7YlMKzhegQ1u4c0M,8198
14
14
  zhmiscellany/list.py,sha256=S8Z85bLJEP9lk2JkGpzUcG6kpRB7a-NWDIHMPiF5bKo,1473
15
- zhmiscellany/macro.py,sha256=7oMnrIUfFNOxRKafv3mY5IKHVziZdsRT_cSmLmBjRPY,15517
15
+ zhmiscellany/macro.py,sha256=a1m4G8OFUM1EKsjzPpcZIPH3ldTq5_UiTHJ9KGl_y7o,16354
16
16
  zhmiscellany/math.py,sha256=btOQTe_GvqP0A7Zz84tmN_c8j1NGe_mKnhmAt40lhLU,2482
17
17
  zhmiscellany/misc.py,sha256=BsTbRWlXI5LZBG7Bl2MgLzHESyCMJnr_KNZAf2wY_H4,29689
18
18
  zhmiscellany/netio.py,sha256=GTamo5cJn4P6u8V_kgZ9kL8qeMUE7OQAmYkmj9Sp_GA,2236
@@ -21,7 +21,7 @@ zhmiscellany/pipes.py,sha256=PxO4aykFzC60xbTQuc66KzZYIxiW0KPebXZbncD2HcU,3795
21
21
  zhmiscellany/processing.py,sha256=srwlV8FZ--svF5e6rZZxhIs_6ZjOAwq2OcQEf6T2Le8,10410
22
22
  zhmiscellany/rust.py,sha256=znN6DYNoa_p-braTuDZKvUnXX8reWLFu_dG4fv2vLR0,442
23
23
  zhmiscellany/string.py,sha256=xyqE6V5YF2nieZDcg5ZrXTIrH2D9oDRbZ5vQGz8rPys,4787
24
- zhmiscellany-5.7.2.dist-info/METADATA,sha256=yXU8bT4A34FXS8P5wqm1XDmIKgQ1IJLvnCPYLOXcFUg,42153
25
- zhmiscellany-5.7.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
26
- zhmiscellany-5.7.2.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
27
- zhmiscellany-5.7.2.dist-info/RECORD,,
24
+ zhmiscellany-5.7.4.dist-info/METADATA,sha256=L8JT8SrpptwnuFnJxjiM5IG_w_C1DhDzntxVdQFjHcQ,42153
25
+ zhmiscellany-5.7.4.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
26
+ zhmiscellany-5.7.4.dist-info/top_level.txt,sha256=ioDtsrevCI52rTxZntMPljRIBsZs73tD0hI00HektiE,13
27
+ zhmiscellany-5.7.4.dist-info/RECORD,,