diskpack 0.4.0__tar.gz → 0.5.0__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.
- {diskpack-0.4.0/src/diskpack.egg-info → diskpack-0.5.0}/PKG-INFO +1 -1
- {diskpack-0.4.0 → diskpack-0.5.0}/pyproject.toml +1 -1
- {diskpack-0.4.0 → diskpack-0.5.0}/src/diskpack/packer.py +23 -14
- {diskpack-0.4.0 → diskpack-0.5.0/src/diskpack.egg-info}/PKG-INFO +1 -1
- {diskpack-0.4.0 → diskpack-0.5.0}/LICENSE +0 -0
- {diskpack-0.4.0 → diskpack-0.5.0}/README.md +0 -0
- {diskpack-0.4.0 → diskpack-0.5.0}/setup.cfg +0 -0
- {diskpack-0.4.0 → diskpack-0.5.0}/src/diskpack/__init__.py +0 -0
- {diskpack-0.4.0 → diskpack-0.5.0}/src/diskpack.egg-info/SOURCES.txt +0 -0
- {diskpack-0.4.0 → diskpack-0.5.0}/src/diskpack.egg-info/dependency_links.txt +0 -0
- {diskpack-0.4.0 → diskpack-0.5.0}/src/diskpack.egg-info/requires.txt +0 -0
- {diskpack-0.4.0 → diskpack-0.5.0}/src/diskpack.egg-info/top_level.txt +0 -0
- {diskpack-0.4.0 → diskpack-0.5.0}/tests/tests.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "diskpack"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.5.0"
|
|
8
8
|
authors = [{ name="James Kelly", email="mrkellyjam@gmail.com" }]
|
|
9
9
|
description = "A high-performance vectorized circle packer with spatial hashing."
|
|
10
10
|
readme = "README.md"
|
|
@@ -20,6 +20,7 @@ class PackingConfig:
|
|
|
20
20
|
ray_cast_epsilon: float = 1e-10
|
|
21
21
|
sample_batch_size: int = 50
|
|
22
22
|
fixed_radius: Optional[float] = None
|
|
23
|
+
use_hex_grid: bool = True
|
|
23
24
|
verbose: bool = False
|
|
24
25
|
|
|
25
26
|
|
|
@@ -329,22 +330,11 @@ class CirclePacker:
|
|
|
329
330
|
|
|
330
331
|
return circles
|
|
331
332
|
|
|
332
|
-
def
|
|
333
|
+
def _pack_random(self) -> Iterator[Circle]:
|
|
333
334
|
"""
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
For fixed_radius mode, uses optimized hex grid placement.
|
|
337
|
-
For variable radius mode, uses random sampling with best-fit selection.
|
|
338
|
-
|
|
339
|
-
Yields:
|
|
340
|
-
Tuples of (x, y, radius) for each placed circle.
|
|
335
|
+
Pack circles using random sampling.
|
|
336
|
+
Used for variable radius mode or when organic placement is desired.
|
|
341
337
|
"""
|
|
342
|
-
# Use hex grid for fixed radius - much faster and denser
|
|
343
|
-
if self.config.fixed_radius is not None:
|
|
344
|
-
yield from self._pack_hex_grid()
|
|
345
|
-
return
|
|
346
|
-
|
|
347
|
-
# Variable radius mode - use random sampling
|
|
348
338
|
self.progress = PackingProgress(max_failed_attempts=self.config.max_failed_attempts)
|
|
349
339
|
|
|
350
340
|
while self.progress.failed_attempts < self.config.max_failed_attempts:
|
|
@@ -370,6 +360,25 @@ class CirclePacker:
|
|
|
370
360
|
if self.config.verbose:
|
|
371
361
|
print(f"Done! {self.progress}")
|
|
372
362
|
|
|
363
|
+
def generate(self) -> Iterator[Circle]:
|
|
364
|
+
"""
|
|
365
|
+
Generate circles until no more can be placed.
|
|
366
|
+
|
|
367
|
+
For fixed_radius mode with use_hex_grid=True (default), uses optimized hex grid.
|
|
368
|
+
For fixed_radius mode with use_hex_grid=False, uses random sampling for organic look.
|
|
369
|
+
For variable radius mode, uses random sampling with best-fit selection.
|
|
370
|
+
|
|
371
|
+
Yields:
|
|
372
|
+
Tuples of (x, y, radius) for each placed circle.
|
|
373
|
+
"""
|
|
374
|
+
# Use hex grid for fixed radius (unless disabled)
|
|
375
|
+
if self.config.fixed_radius is not None and self.config.use_hex_grid:
|
|
376
|
+
yield from self._pack_hex_grid()
|
|
377
|
+
return
|
|
378
|
+
|
|
379
|
+
# Random sampling mode (variable radius OR fixed radius with organic placement)
|
|
380
|
+
yield from self._pack_random()
|
|
381
|
+
|
|
373
382
|
def pack(self) -> List[Circle]:
|
|
374
383
|
"""Pack circles and return them as a list."""
|
|
375
384
|
return list(self.generate())
|
|
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
|