Skip to content

Commit

Permalink
import gfxdraw
Browse files Browse the repository at this point in the history
  • Loading branch information
QuanyiLi committed Sep 18, 2023
1 parent aa1a2f6 commit b572cac
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions metadrive/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,4 +411,5 @@ def get_color(type, pygame=False):

if pygame:
ret *= 255
ret.astype(np.int32)
return ret
2 changes: 1 addition & 1 deletion metadrive/engine/core/manual_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from metadrive.utils import import_pygame

pygame = import_pygame()
pygame, gfxdraw = import_pygame()


class Controller:
Expand Down
4 changes: 2 additions & 2 deletions metadrive/obs/top_down_obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
VehicleGraphics, LaneGraphics
from metadrive.utils import import_pygame

pygame = import_pygame()
pygame, gfxdraw = import_pygame()


class TopDownObservation(ObservationBase):
Expand All @@ -38,7 +38,7 @@ def __init__(self, vehicle_config, clip_rgb: bool, onscreen, resolution=None, ma
# self.obs_shape = (64, 64)
self.obs_shape = self.resolution

self.pygame = import_pygame()
self.pygame, _ = import_pygame()

self.onscreen = onscreen
main_window_position = (0, 0)
Expand Down
2 changes: 1 addition & 1 deletion metadrive/obs/top_down_obs_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from metadrive.type import MetaDriveType

PositionType = Union[Tuple[float, float], np.ndarray]
pygame = import_pygame()
pygame, gfxdraw = import_pygame()
COLOR_BLACK = pygame.Color("black")


Expand Down
2 changes: 1 addition & 1 deletion metadrive/obs/top_down_obs_multi_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
ObservationWindowMultiChannel
from metadrive.utils import import_pygame, clip

pygame = import_pygame()
pygame, gfxdraw = import_pygame()
COLOR_WHITE = pygame.Color("white")


Expand Down
2 changes: 1 addition & 1 deletion metadrive/obs/top_down_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from metadrive.utils.utils import import_pygame
from metadrive.utils.utils import is_map_related_instance

pygame = import_pygame()
pygame, gfxdraw = import_pygame()

color_white = (255, 255, 255)
history_object = namedtuple("history_object", "name position heading_theta WIDTH LENGTH color done type")
Expand Down
2 changes: 1 addition & 1 deletion metadrive/utils/draw_top_down_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from metadrive.obs.top_down_renderer import draw_top_down_map as native_draw
from metadrive.utils.utils import import_pygame

pygame = import_pygame()
pygame, gfxdraw = import_pygame()


def draw_top_down_map(map, resolution: Iterable = (512, 512)) -> Optional[Union[np.ndarray, pygame.Surface]]:
Expand Down
3 changes: 2 additions & 1 deletion metadrive/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
def import_pygame():
os.environ['PYGAME_HIDE_SUPPORT_PROMPT'] = "hide"
import pygame
return pygame
from pygame import gfxdraw
return pygame, gfxdraw


def get_time_str():
Expand Down

0 comments on commit b572cac

Please sign in to comment.