ui(raylib): constant spinner rotation speed

Previously, the spinner rotation would start slow and ramp up as the
reported FPS increased. With this change the spinner speed remains
constant, and the implementation is simpler.
pull/35037/head
Cameron Clough 6 days ago
parent 618b7ccf23
commit 250d1e7425
  1. 8
      system/ui/spinner.py

@ -9,7 +9,7 @@ from openpilot.system.ui.lib.application import gui_app
# Constants # Constants
PROGRESS_BAR_WIDTH = 1000 PROGRESS_BAR_WIDTH = 1000
PROGRESS_BAR_HEIGHT = 20 PROGRESS_BAR_HEIGHT = 20
ROTATION_TIME_SECONDS = 1.0 # Time for one full circle DEGREES_PER_SECOND = 360.0 # one full rotation per second
MARGIN = 200 MARGIN = 200
TEXTURE_SIZE = 360 TEXTURE_SIZE = 360
FONT_SIZE = 80 FONT_SIZE = 80
@ -43,10 +43,8 @@ class Spinner:
spinner_origin = rl.Vector2(TEXTURE_SIZE / 2.0, TEXTURE_SIZE / 2.0) spinner_origin = rl.Vector2(TEXTURE_SIZE / 2.0, TEXTURE_SIZE / 2.0)
comma_position = rl.Vector2(center.x - TEXTURE_SIZE / 2.0, center.y - TEXTURE_SIZE / 2.0) comma_position = rl.Vector2(center.x - TEXTURE_SIZE / 2.0, center.y - TEXTURE_SIZE / 2.0)
fps = rl.get_fps() delta_time = rl.get_frame_time()
if fps > 0: self._rotation = (self._rotation + DEGREES_PER_SECOND * delta_time) % 360.0
degrees_per_frame = 360.0 / (ROTATION_TIME_SECONDS * fps)
self._rotation = (self._rotation + degrees_per_frame) % 360.0
# Draw rotating spinner and static comma logo # Draw rotating spinner and static comma logo
rl.draw_texture_pro(self._spinner_texture, rl.Rectangle(0, 0, TEXTURE_SIZE, TEXTURE_SIZE), rl.draw_texture_pro(self._spinner_texture, rl.Rectangle(0, 0, TEXTURE_SIZE, TEXTURE_SIZE),

Loading…
Cancel
Save