Explorar o código

+random colours also support returning rgb

tBKwtWS hai 1 mes
pai
achega
601aae1fc9
Modificáronse 1 ficheiros con 4 adicións e 2 borrados
  1. 4 2
      karel_asset.py

+ 4 - 2
karel_asset.py

@@ -10,7 +10,7 @@ logging.basicConfig(level=logging.INFO) # Set loglevel to INFO or higher to prev
 """
 Helper functions
 """
-# Return some hex colour
+# Return some colour
 """
 Waiting for Stanford to fix a bug in the environment
 CIP bug: https://codeinplace.stanford.edu/cip6/report?post=ac7c4ffd-1f90-475a-b4ee-2e5b73c5348f
@@ -24,9 +24,11 @@ def get_random_colour():
 colour = colors.rgb2hex((get_random_colour()))
 background = colors.rgb2hex((get_random_colour()))
 """
-def generate_random_colour():
+def generate_random_colour(sort:str="hex"):
     # Generate random RGB values
     rgb_values = [random.randrange(256), random.randrange(256), random.randrange(256)]
+    if sort.lower() == "rgb":
+        return rgb_values
 
     # Convert to HEX values
     hex_colours = [hex(value)[2:] for value in rgb_values]  # Strip the '0x' prefix