|
32 | 32 | SHOW_TOUCHES = os.getenv("SHOW_TOUCHES") == "1" |
33 | 33 | STRICT_MODE = os.getenv("STRICT_MODE") == "1" |
34 | 34 | SCALE = float(os.getenv("SCALE", "1.0")) |
| 35 | +GRID_SIZE = int(os.getenv("GRID", "0")) |
35 | 36 | PROFILE_RENDER = int(os.getenv("PROFILE_RENDER", "0")) |
36 | 37 | PROFILE_STATS = int(os.getenv("PROFILE_STATS", "100")) # Number of functions to show in profile output |
37 | 38 |
|
@@ -213,6 +214,7 @@ def __init__(self, width: int, height: int): |
213 | 214 | self._mouse_history: deque[MousePosWithTime] = deque(maxlen=MOUSE_THREAD_RATE) |
214 | 215 | self._show_touches = SHOW_TOUCHES |
215 | 216 | self._show_fps = SHOW_FPS |
| 217 | + self._grid_size = GRID_SIZE |
216 | 218 | self._profile_render_frames = PROFILE_RENDER |
217 | 219 | self._render_profiler = None |
218 | 220 | self._render_profile_start_time = None |
@@ -457,6 +459,9 @@ def render(self): |
457 | 459 | if self._show_touches: |
458 | 460 | self._draw_touch_points() |
459 | 461 |
|
| 462 | + if self._grid_size > 0: |
| 463 | + self._draw_grid() |
| 464 | + |
460 | 465 | rl.end_drawing() |
461 | 466 | self._monitor_fps() |
462 | 467 | self._frame += 1 |
@@ -605,6 +610,19 @@ def _draw_touch_points(self): |
605 | 610 | color = rl.Color(min(int(255 * (1.5 - perc)), 255), int(min(255 * (perc + 0.5), 255)), 50, 255) |
606 | 611 | rl.draw_circle(int(mouse_pos.x), int(mouse_pos.y), 5, color) |
607 | 612 |
|
| 613 | + def _draw_grid(self): |
| 614 | + grid_color = rl.Color(60, 60, 60, 255) |
| 615 | + # Draw vertical lines |
| 616 | + x = 0 |
| 617 | + while x <= self._scaled_width: |
| 618 | + rl.draw_line(x, 0, x, self._scaled_height, grid_color) |
| 619 | + x += self._grid_size |
| 620 | + # Draw horizontal lines |
| 621 | + y = 0 |
| 622 | + while y <= self._scaled_height: |
| 623 | + rl.draw_line(0, y, self._scaled_width, y, grid_color) |
| 624 | + y += self._grid_size |
| 625 | + |
608 | 626 | def _output_render_profile(self): |
609 | 627 | import io |
610 | 628 | import pstats |
|
0 commit comments