valetudo-map-parser 0.1.9b71__py3-none-any.whl → 0.1.9b73__py3-none-any.whl
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/config/drawable.py +35 -52
- {valetudo_map_parser-0.1.9b71.dist-info → valetudo_map_parser-0.1.9b73.dist-info}/METADATA +1 -1
- {valetudo_map_parser-0.1.9b71.dist-info → valetudo_map_parser-0.1.9b73.dist-info}/RECORD +6 -6
- {valetudo_map_parser-0.1.9b71.dist-info → valetudo_map_parser-0.1.9b73.dist-info}/LICENSE +0 -0
- {valetudo_map_parser-0.1.9b71.dist-info → valetudo_map_parser-0.1.9b73.dist-info}/NOTICE.txt +0 -0
- {valetudo_map_parser-0.1.9b71.dist-info → valetudo_map_parser-0.1.9b73.dist-info}/WHEEL +0 -0
@@ -223,7 +223,9 @@ class Drawable:
|
|
223
223
|
|
224
224
|
@staticmethod
|
225
225
|
def point_inside(x: int, y: int, points: list[Tuple[int, int]]) -> bool:
|
226
|
-
"""
|
226
|
+
"""
|
227
|
+
Check if a point (x, y) is inside a polygon defined by a list of points.
|
228
|
+
"""
|
227
229
|
n = len(points)
|
228
230
|
inside = False
|
229
231
|
xinters = 0.0
|
@@ -239,31 +241,7 @@ class Drawable:
|
|
239
241
|
p1x, p1y = p2x, p2y
|
240
242
|
return inside
|
241
243
|
|
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
|
-
|
244
|
+
@staticmethod
|
267
245
|
def _line(
|
268
246
|
layer: np.ndarray,
|
269
247
|
x1: int,
|
@@ -273,7 +251,8 @@ class Drawable:
|
|
273
251
|
color: Color,
|
274
252
|
width: int = 3,
|
275
253
|
) -> np.ndarray:
|
276
|
-
"""
|
254
|
+
"""
|
255
|
+
Draw a line on a NumPy array (layer) from point A to B using Bresenham's algorithm.
|
277
256
|
|
278
257
|
Args:
|
279
258
|
layer: The numpy array to draw on (H, W, C)
|
@@ -283,42 +262,46 @@ class Drawable:
|
|
283
262
|
width: Width of the line in pixels
|
284
263
|
"""
|
285
264
|
x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2)
|
286
|
-
h, w = layer.shape[:2]
|
287
265
|
|
288
266
|
blended_color = get_blended_color(x1, y1, x2, y2, layer, color)
|
289
267
|
|
290
|
-
|
291
|
-
|
268
|
+
dx = abs(x2 - x1)
|
269
|
+
dy = abs(y2 - y1)
|
270
|
+
sx = 1 if x1 < x2 else -1
|
271
|
+
sy = 1 if y1 < y2 else -1
|
272
|
+
err = dx - dy
|
292
273
|
|
293
|
-
|
294
|
-
|
295
|
-
mask = (xs >= 0) & (xs < w) & (ys >= 0) & (ys < h)
|
296
|
-
layer[ys[mask], xs[mask]] = blended_color
|
297
|
-
return layer
|
274
|
+
half_w = width // 2
|
275
|
+
h, w = layer.shape[:2]
|
298
276
|
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
277
|
+
while True:
|
278
|
+
# Draw a filled circle for thickness
|
279
|
+
yy, xx = np.ogrid[-half_w:half_w + 1, -half_w:half_w + 1]
|
280
|
+
mask = xx**2 + yy**2 <= half_w**2
|
281
|
+
y_min = max(0, y1 - half_w)
|
282
|
+
y_max = min(h, y1 + half_w + 1)
|
283
|
+
x_min = max(0, x1 - half_w)
|
284
|
+
x_max = min(w, x1 + half_w + 1)
|
306
285
|
|
307
|
-
|
308
|
-
|
309
|
-
|
286
|
+
submask = mask[
|
287
|
+
(y_min - (y1 - half_w)):(y_max - (y1 - half_w)),
|
288
|
+
(x_min - (x1 - half_w)):(x_max - (x1 - half_w))
|
289
|
+
]
|
290
|
+
layer[y_min:y_max, x_min:x_max][submask] = blended_color
|
310
291
|
|
311
|
-
|
312
|
-
|
313
|
-
all_x = all_x[valid]
|
314
|
-
all_y = all_y[valid]
|
292
|
+
if x1 == x2 and y1 == y2:
|
293
|
+
break
|
315
294
|
|
316
|
-
|
317
|
-
|
295
|
+
e2 = 2 * err
|
296
|
+
if e2 > -dy:
|
297
|
+
err -= dy
|
298
|
+
x1 += sx
|
299
|
+
if e2 < dx:
|
300
|
+
err += dx
|
301
|
+
y1 += sy
|
318
302
|
|
319
303
|
return layer
|
320
304
|
|
321
|
-
|
322
305
|
@staticmethod
|
323
306
|
async def draw_virtual_walls(
|
324
307
|
layer: NumpyArray, virtual_walls, color: Color
|
@@ -4,7 +4,7 @@ valetudo_map_parser/config/async_utils.py,sha256=e1j9uTtg4dhPVWvB2_XgqaH4aeSjRAP
|
|
4
4
|
valetudo_map_parser/config/auto_crop.py,sha256=Aes7vfv4z8ihYvGaH5Nryj6Y9mHDerZLIeyvePjf9aQ,19259
|
5
5
|
valetudo_map_parser/config/color_utils.py,sha256=nXD6WeNmdFdoMxPDW-JFpjnxJSaZR1jX-ouNfrx6zvE,4502
|
6
6
|
valetudo_map_parser/config/colors.py,sha256=DG-oPQoN5gsnwDbEsuFr8a0hRCxmbFHObWa4_5pr-70,29910
|
7
|
-
valetudo_map_parser/config/drawable.py,sha256=
|
7
|
+
valetudo_map_parser/config/drawable.py,sha256=s_4jC0XF-vF8JZf_kTJzaioLFxw7n23g9YoJW_fDWHo,33560
|
8
8
|
valetudo_map_parser/config/drawable_elements.py,sha256=o-5oiXmfqPwNQLzKIhkEcZD_A47rIU9E0CqKgWipxgc,11516
|
9
9
|
valetudo_map_parser/config/enhanced_drawable.py,sha256=QlGxlUMVgECUXPtFwIslyjubWxQuhIixsRymWV3lEvk,12586
|
10
10
|
valetudo_map_parser/config/optimized_element_map.py,sha256=52BCnkvVv9bre52LeVIfT8nhnEIpc0TuWTv1xcNu0Rk,15744
|
@@ -20,8 +20,8 @@ valetudo_map_parser/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
20
20
|
valetudo_map_parser/rand256_handler.py,sha256=daaSQ5ktMUYMnYxJkjS75UdBchpXVZ58HIomwHBFivs,27651
|
21
21
|
valetudo_map_parser/reimg_draw.py,sha256=1q8LkNTPHEA9Tsapc_JnVw51kpPYNhaBU-KmHkefCQY,12507
|
22
22
|
valetudo_map_parser/rooms_handler.py,sha256=ovqQtAjauAqwUNPR0aX27P2zhheQmqfaFhDE3_AwYWk,17821
|
23
|
-
valetudo_map_parser-0.1.
|
24
|
-
valetudo_map_parser-0.1.
|
25
|
-
valetudo_map_parser-0.1.
|
26
|
-
valetudo_map_parser-0.1.
|
27
|
-
valetudo_map_parser-0.1.
|
23
|
+
valetudo_map_parser-0.1.9b73.dist-info/LICENSE,sha256=Lh-qBbuRV0-jiCIBhfV7NgdwFxQFOXH3BKOzK865hRs,10480
|
24
|
+
valetudo_map_parser-0.1.9b73.dist-info/METADATA,sha256=u6LNZEad3UEMHa-J8EUtBTjaz0V2FbVQbZj-9D8P1MA,3353
|
25
|
+
valetudo_map_parser-0.1.9b73.dist-info/NOTICE.txt,sha256=5lTOuWiU9aiEnJ2go8sc7lTJ7ntMBx0g0GFnNrswCY4,2533
|
26
|
+
valetudo_map_parser-0.1.9b73.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
27
|
+
valetudo_map_parser-0.1.9b73.dist-info/RECORD,,
|
File without changes
|
{valetudo_map_parser-0.1.9b71.dist-info → valetudo_map_parser-0.1.9b73.dist-info}/NOTICE.txt
RENAMED
File without changes
|
File without changes
|