INNER CODE UNIT · Python
_color
ljvmiranda921/sprites-as-a-service · backend/sprites/sprites.py:109
def _color(seeds: Tuple[int, int, int] = None) -> str:
"""Returns a random hex code"""
hex_values = []
for i in range(3):
if seeds:
random.seed(seeds[i])
h = random.randint(0, 255)
hex_values.append(h)
return "#{:02X}{:02X}{:02X}".format(*hex_values)
def _add_outline(mat: np.ndarray) -> np.ndarray:
"""Create an outline given a sprite image
It traverses the matrix and looks for the body of the sprite, as
represented by 0 values. Once it founds one, it looks around its neighbors
and change all background values (represented as 1) into an outline.