Skip to content
Snippets Groups Projects
Commit c7f1f3f6 authored by michael.divia's avatar michael.divia
Browse files

Forgot the function

parent d14be82c
No related branches found
No related tags found
No related merge requests found
...@@ -45,8 +45,7 @@ class color: ...@@ -45,8 +45,7 @@ class color:
def col(r, g, b): def col(r, g, b):
return (r, g, b) return (r, g, b)
class matrix: def color_convert(color):
def clear(color):
# Handle hex an 0 # Handle hex an 0
if isinstance(color, int): if isinstance(color, int):
...@@ -61,7 +60,35 @@ class matrix: ...@@ -61,7 +60,35 @@ class matrix:
else: else:
raise ValueError("Color must be an RGB tuple, a hex value, 0 or a valide color from the color class") raise ValueError("Color must be an RGB tuple, a hex value, 0 or a valide color from the color class")
return color
class matrix:
def clear(color):
# Convert the color
color = color_convert(color)
# Set the full screen to the color
for i in range(nb_line*nb_row): for i in range(nb_line*nb_row):
np[i] = color np[i] = color
# Apply the array
np.write() np.write()
def set_line(line, color):
# Check line
if line < 0 or line >= nb_line:
raise ValueError("Line is out of bound")
# Convert the color
color = color_convert(color)
# Set the line to the color
for i in range(line*nb_row, (line*nb_row)+nb_row):
np[i] = color
# Apply the array
np.write()
from hl3 import color from hl3 import *
from hl3 import matrix
matrix.clear(color.RED) matrix.clear(0)
matrix.set_line(5, color.RED)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment