valetudo-map-parser 0.1.9b70__tar.gz → 0.1.9b71__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.
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/PKG-INFO +1 -1
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/drawable.py +64 -48
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/pyproject.toml +1 -1
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/LICENSE +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/NOTICE.txt +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/README.md +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/__init__.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/__init__.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/async_utils.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/auto_crop.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/color_utils.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/colors.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/drawable_elements.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/enhanced_drawable.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/optimized_element_map.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/rand256_parser.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/shared.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/types.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/config/utils.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/hypfer_draw.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/hypfer_handler.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/hypfer_rooms_handler.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/map_data.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/py.typed +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/rand256_handler.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/reimg_draw.py +0 -0
- {valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/rooms_handler.py +0 -0
@@ -223,9 +223,7 @@ class Drawable:
|
|
223
223
|
|
224
224
|
@staticmethod
|
225
225
|
def point_inside(x: int, y: int, points: list[Tuple[int, int]]) -> bool:
|
226
|
-
"""
|
227
|
-
Check if a point (x, y) is inside a polygon defined by a list of points.
|
228
|
-
"""
|
226
|
+
"""Check if a point (x, y) is inside a polygon defined by a list of points."""
|
229
227
|
n = len(points)
|
230
228
|
inside = False
|
231
229
|
xinters = 0.0
|
@@ -242,67 +240,85 @@ class Drawable:
|
|
242
240
|
return inside
|
243
241
|
|
244
242
|
@staticmethod
|
243
|
+
def _bresenham_line_coords(x1: int, y1: int, x2: int, y2: int) -> Tuple[np.ndarray, np.ndarray]:
|
244
|
+
"""Return integer coordinates for a line using Bresenham's algorithm."""
|
245
|
+
dx = abs(x2 - x1)
|
246
|
+
dy = abs(y2 - y1)
|
247
|
+
sx = 1 if x1 < x2 else -1
|
248
|
+
sy = 1 if y1 < y2 else -1
|
249
|
+
err = dx - dy
|
250
|
+
|
251
|
+
xs, ys = [], []
|
252
|
+
while True:
|
253
|
+
xs.append(x1)
|
254
|
+
ys.append(y1)
|
255
|
+
if x1 == x2 and y1 == y2:
|
256
|
+
break
|
257
|
+
e2 = 2 * err
|
258
|
+
if e2 > -dy:
|
259
|
+
err -= dy
|
260
|
+
x1 += sx
|
261
|
+
if e2 < dx:
|
262
|
+
err += dx
|
263
|
+
y1 += sy
|
264
|
+
return np.array(xs, dtype=int), np.array(ys, dtype=int)
|
265
|
+
|
266
|
+
|
245
267
|
def _line(
|
246
|
-
layer:
|
268
|
+
layer: np.ndarray,
|
247
269
|
x1: int,
|
248
270
|
y1: int,
|
249
271
|
x2: int,
|
250
272
|
y2: int,
|
251
273
|
color: Color,
|
252
274
|
width: int = 3,
|
253
|
-
) ->
|
254
|
-
"""
|
255
|
-
|
256
|
-
|
275
|
+
) -> np.ndarray:
|
276
|
+
"""Draw a line on a NumPy array (layer) from point A to B using a fully vectorized approach.
|
277
|
+
|
257
278
|
Args:
|
258
|
-
layer: The numpy array to draw on
|
279
|
+
layer: The numpy array to draw on (H, W, C)
|
259
280
|
x1, y1: Start point coordinates
|
260
281
|
x2, y2: End point coordinates
|
261
|
-
color: Color to draw with
|
262
|
-
width: Width of the line
|
282
|
+
color: Color to draw with (tuple or array)
|
283
|
+
width: Width of the line in pixels
|
263
284
|
"""
|
264
|
-
# Ensure coordinates are integers
|
265
285
|
x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
|
266
|
-
|
267
|
-
|
286
|
+
h, w = layer.shape[:2]
|
287
|
+
|
268
288
|
blended_color = get_blended_color(x1, y1, x2, y2, layer, color)
|
269
|
-
|
270
|
-
#
|
271
|
-
|
272
|
-
|
273
|
-
# Draw a dot with the specified width
|
274
|
-
for i in range(-width // 2, (width + 1) // 2):
|
275
|
-
for j in range(-width // 2, (width + 1) // 2):
|
276
|
-
if 0 <= x1 + i < layer.shape[1] and 0 <= y1 + j < layer.shape[0]:
|
277
|
-
layer[y1 + j, x1 + i] = blended_color
|
278
|
-
return layer
|
279
|
-
|
280
|
-
# Create parametric points along the line
|
281
|
-
t = np.linspace(0, 1, length * 2) # Double the points for smoother lines
|
282
|
-
x_coords = np.round(x1 * (1 - t) + x2 * t).astype(int)
|
283
|
-
y_coords = np.round(y1 * (1 - t) + y2 * t).astype(int)
|
284
|
-
|
285
|
-
# Draw the line with the specified width
|
289
|
+
|
290
|
+
# Get core line coordinates
|
291
|
+
xs, ys = _bresenham_line_coords(x1, y1, x2, y2)
|
292
|
+
|
286
293
|
if width == 1:
|
287
|
-
#
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
294
|
+
# Clip to bounds in one go
|
295
|
+
mask = (xs >= 0) & (xs < w) & (ys >= 0) & (ys < h)
|
296
|
+
layer[ys[mask], xs[mask]] = blended_color
|
297
|
+
return layer
|
298
|
+
|
299
|
+
# Precompute circular mask for thickness
|
300
|
+
r = width // 2
|
301
|
+
yy, xx = np.ogrid[-r:r + 1, -r:r + 1]
|
302
|
+
circle_mask = (xx**2 + yy**2) <= r**2
|
303
|
+
dy_idx, dx_idx = np.nonzero(circle_mask) # offsets inside the circle
|
304
|
+
dy_idx -= r
|
305
|
+
dx_idx -= r
|
306
|
+
|
307
|
+
# Broadcast offsets to all line points
|
308
|
+
all_x = (xs[:, None] + dx_idx[None, :]).ravel()
|
309
|
+
all_y = (ys[:, None] + dy_idx[None, :]).ravel()
|
310
|
+
|
311
|
+
# Clip to image bounds
|
312
|
+
valid = (all_x >= 0) & (all_x < w) & (all_y >= 0) & (all_y < h)
|
313
|
+
all_x = all_x[valid]
|
314
|
+
all_y = all_y[valid]
|
315
|
+
|
316
|
+
# Draw all pixels in one go
|
317
|
+
layer[all_y, all_x] = blended_color
|
318
|
+
|
304
319
|
return layer
|
305
320
|
|
321
|
+
|
306
322
|
@staticmethod
|
307
323
|
async def draw_virtual_walls(
|
308
324
|
layer: NumpyArray, virtual_walls, color: Color
|
File without changes
|
File without changes
|
File without changes
|
{valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/__init__.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/hypfer_draw.py
RENAMED
File without changes
|
File without changes
|
File without changes
|
{valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/map_data.py
RENAMED
File without changes
|
{valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/py.typed
RENAMED
File without changes
|
File without changes
|
{valetudo_map_parser-0.1.9b70 → valetudo_map_parser-0.1.9b71}/SCR/valetudo_map_parser/reimg_draw.py
RENAMED
File without changes
|
File without changes
|