valetudo-map-parser 0.1.9b43__tar.gz → 0.1.9b44__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/PKG-INFO +3 -1
  2. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/config/colors.py +60 -8
  3. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/config/drawable.py +4 -0
  4. valetudo_map_parser-0.1.9b44/SCR/valetudo_map_parser/config/drawable_elements.py +887 -0
  5. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/config/enhanced_drawable.py +4 -9
  6. valetudo_map_parser-0.1.9b44/SCR/valetudo_map_parser/config/optimized_element_map.py +363 -0
  7. valetudo_map_parser-0.1.9b44/SCR/valetudo_map_parser/config/room_outline.py +148 -0
  8. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/config/shared.py +1 -0
  9. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/config/utils.py +82 -65
  10. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/hypfer_draw.py +30 -32
  11. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/hypfer_handler.py +96 -63
  12. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/map_data.py +0 -9
  13. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/rand25_handler.py +170 -129
  14. valetudo_map_parser-0.1.9b44/SCR/valetudo_map_parser/utils/__init__.py +5 -0
  15. valetudo_map_parser-0.1.9b44/SCR/valetudo_map_parser/utils/color_utils.py +62 -0
  16. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/pyproject.toml +3 -1
  17. valetudo_map_parser-0.1.9b43/SCR/valetudo_map_parser/config/drawable_elements.py +0 -312
  18. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/LICENSE +0 -0
  19. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/NOTICE.txt +0 -0
  20. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/README.md +0 -0
  21. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/__init__.py +0 -0
  22. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/config/__init__.py +0 -0
  23. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/config/auto_crop.py +0 -0
  24. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/config/colors_man.py +0 -0
  25. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/config/rand25_parser.py +0 -0
  26. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/config/types.py +0 -0
  27. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/py.typed +0 -0
  28. {valetudo_map_parser-0.1.9b43 → valetudo_map_parser-0.1.9b44}/SCR/valetudo_map_parser/reimg_draw.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: valetudo-map-parser
3
- Version: 0.1.9b43
3
+ Version: 0.1.9b44
4
4
  Summary: A Python library to parse Valetudo map data returning a PIL Image object.
5
5
  License: Apache-2.0
6
6
  Author: Sandro Cantarella
@@ -12,6 +12,8 @@ Classifier: Programming Language :: Python :: 3.12
12
12
  Classifier: Programming Language :: Python :: 3.13
13
13
  Requires-Dist: Pillow (>=10.3.0)
14
14
  Requires-Dist: numpy (>=1.26.4)
15
+ Requires-Dist: scikit-image (>=0.22.0)
16
+ Requires-Dist: scipy (>=1.12.0)
15
17
  Project-URL: Bug Tracker, https://github.com/sca075/Python-package-valetudo-map-parser/issues
16
18
  Project-URL: Changelog, https://github.com/sca075/Python-package-valetudo-map-parser/releases
17
19
  Project-URL: Homepage, https://github.com/sca075/Python-package-valetudo-map-parser
@@ -2,14 +2,10 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- import logging
6
5
  from enum import StrEnum
7
6
  from typing import Dict, List, Tuple
8
7
 
9
-
10
- _LOGGER = logging.getLogger(__name__)
11
-
12
- Color = Tuple[int, int, int, int] # RGBA color definition
8
+ from .types import LOGGER, Color
13
9
 
14
10
 
15
11
  class SupportedColor(StrEnum):
@@ -38,7 +34,7 @@ class DefaultColors:
38
34
 
39
35
  COLORS_RGB: Dict[str, Tuple[int, int, int]] = {
40
36
  SupportedColor.CHARGER: (255, 128, 0),
41
- SupportedColor.PATH: (238, 247, 255),
37
+ SupportedColor.PATH: (50, 150, 255), # More vibrant blue for better visibility
42
38
  SupportedColor.PREDICTED_PATH: (93, 109, 126),
43
39
  SupportedColor.WALLS: (255, 255, 0),
44
40
  SupportedColor.ROBOT: (255, 255, 204),
@@ -77,6 +73,11 @@ class DefaultColors:
77
73
  DEFAULT_ALPHA: Dict[str, float] = {
78
74
  f"alpha_{key}": 255.0 for key in COLORS_RGB.keys()
79
75
  }
76
+ # Override specific alpha values
77
+ DEFAULT_ALPHA.update({
78
+ "alpha_color_path": 200.0, # Make path slightly transparent but still very visible
79
+ "alpha_color_wall": 150.0, # Keep walls semi-transparent
80
+ })
80
81
  DEFAULT_ALPHA.update({f"alpha_room_{i}": 255.0 for i in range(16)})
81
82
 
82
83
  @classmethod
@@ -142,6 +143,57 @@ class ColorsManagment:
142
143
  """
143
144
  return (*rgb, int(alpha)) if rgb else (0, 0, 0, int(alpha))
144
145
 
146
+ @staticmethod
147
+ def blend_colors(background: Color, foreground: Color) -> Color:
148
+ """
149
+ Blend foreground color with background color based on alpha values.
150
+
151
+ This is used when drawing elements that overlap on the map.
152
+ The alpha channel determines how much of the foreground color is visible.
153
+
154
+ :param background: Background RGBA color (r,g,b,a)
155
+ :param foreground: Foreground RGBA color (r,g,b,a) to blend on top
156
+ :return: Blended RGBA color
157
+ """
158
+ # Extract components
159
+ bg_r, bg_g, bg_b, bg_a = background
160
+ fg_r, fg_g, fg_b, fg_a = foreground
161
+
162
+ # If foreground is fully opaque, just return it
163
+ if fg_a == 255:
164
+ return foreground
165
+
166
+ # If foreground is fully transparent, return background
167
+ if fg_a == 0:
168
+ return background
169
+
170
+ # Calculate alpha blending
171
+ # Convert alpha from [0-255] to [0-1] for calculations
172
+ fg_alpha = fg_a / 255.0
173
+ bg_alpha = bg_a / 255.0
174
+
175
+ # Calculate resulting alpha
176
+ out_alpha = fg_alpha + bg_alpha * (1 - fg_alpha)
177
+
178
+ # Avoid division by zero
179
+ if out_alpha < 0.0001:
180
+ return (0, 0, 0, 0) # Fully transparent result
181
+
182
+ # Calculate blended RGB components
183
+ out_r = int((fg_r * fg_alpha + bg_r * bg_alpha * (1 - fg_alpha)) / out_alpha)
184
+ out_g = int((fg_g * fg_alpha + bg_g * bg_alpha * (1 - fg_alpha)) / out_alpha)
185
+ out_b = int((fg_b * fg_alpha + bg_b * bg_alpha * (1 - fg_alpha)) / out_alpha)
186
+
187
+ # Convert alpha back to [0-255] range
188
+ out_a = int(out_alpha * 255)
189
+
190
+ # Ensure values are in valid range
191
+ out_r = max(0, min(255, out_r))
192
+ out_g = max(0, min(255, out_g))
193
+ out_b = max(0, min(255, out_b))
194
+
195
+ return (out_r, out_g, out_b, out_a)
196
+
145
197
  def get_user_colors(self) -> List[Color]:
146
198
  """Return the list of RGBA colors for user-defined map elements."""
147
199
  return self.user_colors
@@ -163,7 +215,7 @@ class ColorsManagment:
163
215
  try:
164
216
  return self.rooms_colors[room_index]
165
217
  except (IndexError, KeyError):
166
- _LOGGER.warning("Room index %s not found, using default.", room_index)
218
+ LOGGER.warning("Room index %s not found, using default.", room_index)
167
219
  r, g, b = DefaultColors.DEFAULT_ROOM_COLORS[f"color_room_{room_index}"]
168
220
  a = DefaultColors.DEFAULT_ALPHA[f"alpha_room_{room_index}"]
169
221
  return r, g, b, int(a)
@@ -173,7 +225,7 @@ class ColorsManagment:
173
225
  index = list(SupportedColor).index(supported_color)
174
226
  return self.user_colors[index]
175
227
  except (IndexError, KeyError, ValueError):
176
- _LOGGER.warning(
228
+ LOGGER.warning(
177
229
  "Color for %s not found. Returning default.", supported_color
178
230
  )
179
231
  return DefaultColors.get_rgba(supported_color, 255) # Transparent fallback
@@ -220,12 +220,16 @@ class Drawable:
220
220
  """
221
221
  Join the coordinates creating a continuous line (path).
222
222
  """
223
+ import logging
224
+ _LOGGER = logging.getLogger(__name__)
225
+ _LOGGER.debug("Drawing lines with %d coordinates, width %d, color %s", len(coords), width, color)
223
226
  for coord in coords:
224
227
  x0, y0 = coord[0]
225
228
  try:
226
229
  x1, y1 = coord[1]
227
230
  except IndexError:
228
231
  x1, y1 = x0, y0
232
+ _LOGGER.debug("Drawing line from (%d, %d) to (%d, %d)", x0, y0, x1, y1)
229
233
  dx = abs(x1 - x0)
230
234
  dy = abs(y1 - y0)
231
235
  sx = 1 if x0 < x1 else -1