From d2f28098d6ebb169a7c9a0fb1e55685cc7d305a7 Mon Sep 17 00:00:00 2001 From: Marco Franke Date: Mon, 16 Dec 2024 07:57:07 +0000 Subject: [PATCH] feat: added longitudinal color closed #150 --- custom_components/spoolman/sensor.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/custom_components/spoolman/sensor.py b/custom_components/spoolman/sensor.py index 42b6747..86ae55d 100644 --- a/custom_components/spoolman/sensor.py +++ b/custom_components/spoolman/sensor.py @@ -98,13 +98,12 @@ def _generate_entity_picture(spool_data, image_dir): (i * step, 0), ((i + 1) * step - 1, image_size[1]) ], fill=f"#{color}") - else: - # Alternate style: radial (circular gradient) + elif multi_color_direction == "longitudinal": + step = image_size[1] // len(colors) for i, color in enumerate(colors): - radius = image_size[0] // (2 * len(colors)) * (i + 1) - draw.ellipse([ - (image_size[0] // 2 - radius, image_size[1] // 2 - radius), - (image_size[0] // 2 + radius, image_size[1] // 2 + radius) + draw.rectangle([ + (0, i * step), + (image_size[0], (i + 1) * step - 1) ], fill=f"#{color}") else: # Single color fallback