MCPcopy Create free account
hub / github.com/NanmiCoder/MediaCrawler / get_track_simple

Function get_track_simple

tools/slider_util.py:145–175  ·  view source on GitHub ↗
(distance)

Source from the content-addressed store, hash-verified

143
144
145def get_track_simple(distance) -> List[int]:
146 # Some detection checks movement speed - constant speed will be detected, so use gradual acceleration
147 # distance is the total distance to move
148 # Movement track
149 track: List[int] = []
150 # Current displacement
151 current = 0
152 # Deceleration threshold
153 mid = distance * 4 / 5
154 # Time interval
155 t = 0.2
156 # Initial velocity
157 v = 1
158
159 while current < distance:
160 if current < mid:
161 # Acceleration = 4
162 a = 4
163 else:
164 # Acceleration = -3
165 a = -3
166 v0 = v
167 # Current velocity
168 v = v0 + a * t # type: ignore
169 # Movement distance
170 move = v0 * t + 1 / 2 * a * t * t
171 # Current displacement
172 current += move # type: ignore
173 # Add to track
174 track.append(round(move))
175 return track
176
177
178def get_tracks(distance: int, level: str = "easy") -> List[int]:

Callers 1

get_tracksFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected