Add colored backgrounds to feedback and camera alert overlays
This commit is contained in:
32
matrix.py
32
matrix.py
@@ -206,36 +206,38 @@ class Matrix64Display(SampleBase):
|
||||
"""Draw flashing camera alert overlay."""
|
||||
time_font, data_font, small_font = fonts
|
||||
|
||||
# Dark red background
|
||||
bg_color = graphics.Color(40, 0, 0)
|
||||
for y in range(20, 48):
|
||||
graphics.DrawLine(canvas, 0, y, 63, y, bg_color)
|
||||
|
||||
# Flashing red border
|
||||
flash = int(time.time() * 4) % 2
|
||||
if flash:
|
||||
border_color = graphics.Color(255, 0, 0)
|
||||
for i in range(2):
|
||||
graphics.DrawLine(canvas, i, 0, i, 63, border_color)
|
||||
graphics.DrawLine(canvas, 63-i, 0, 63-i, 63, border_color)
|
||||
graphics.DrawLine(canvas, 0, i, 63, i, border_color)
|
||||
graphics.DrawLine(canvas, 0, 63-i, 63, 63-i, border_color)
|
||||
border_color = graphics.Color(255, 0, 0) if flash else graphics.Color(100, 0, 0)
|
||||
graphics.DrawLine(canvas, 0, 20, 63, 20, border_color)
|
||||
graphics.DrawLine(canvas, 0, 47, 63, 47, border_color)
|
||||
|
||||
# Alert text
|
||||
alert_color = graphics.Color(255, 50, 50)
|
||||
graphics.DrawText(canvas, data_font, 8, 32, alert_color, "ALERTA")
|
||||
graphics.DrawText(canvas, small_font, 6, 42, alert_color, "Camara")
|
||||
# Alert text (centered)
|
||||
alert_color = graphics.Color(255, 80, 80)
|
||||
graphics.DrawText(canvas, data_font, 12, 32, alert_color, "ALERTA")
|
||||
graphics.DrawText(canvas, small_font, 10, 42, alert_color, "Camara ext")
|
||||
|
||||
def draw_feedback(self, canvas, fonts, colors):
|
||||
time_font, data_font, small_font = fonts
|
||||
time_color, humidity_color, hdd_color, label_color, line_color = colors
|
||||
|
||||
# Black background
|
||||
# Dark blue background
|
||||
bg_color = graphics.Color(0, 20, 40)
|
||||
for y in range(22, 46):
|
||||
graphics.DrawLine(canvas, 0, y, 63, y, graphics.Color(0, 0, 0))
|
||||
graphics.DrawLine(canvas, 0, y, 63, y, bg_color)
|
||||
|
||||
# Border lines
|
||||
border_color = graphics.Color(60, 60, 60)
|
||||
border_color = graphics.Color(30, 90, 150)
|
||||
graphics.DrawLine(canvas, 0, 22, 63, 22, border_color)
|
||||
graphics.DrawLine(canvas, 0, 45, 63, 45, border_color)
|
||||
|
||||
# Message
|
||||
msg_color = graphics.Color(0, 255, 100)
|
||||
msg_color = graphics.Color(100, 255, 150)
|
||||
msg_len = len(self.feedback_message) * 7
|
||||
x = (64 - msg_len) // 2
|
||||
graphics.DrawText(canvas, time_font, x, 38, msg_color, self.feedback_message)
|
||||
|
||||
Reference in New Issue
Block a user