tilemap-parser 3.1.5__tar.gz → 3.1.7__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 (31) hide show
  1. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/PKG-INFO +1 -1
  2. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/pyproject.toml +1 -1
  3. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/parser/animation.py +4 -1
  4. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/runtime/animation_player.py +22 -0
  5. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser.egg-info/PKG-INFO +1 -1
  6. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/LICENSE +0 -0
  7. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/README.md +0 -0
  8. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/setup.cfg +0 -0
  9. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/__init__.py +0 -0
  10. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/parser/__init__.py +0 -0
  11. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/parser/collision.py +0 -0
  12. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/parser/collision_loader.py +0 -0
  13. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/parser/map_parse.py +0 -0
  14. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/runtime/__init__.py +0 -0
  15. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/runtime/collision_cache.py +0 -0
  16. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/runtime/map_loader.py +0 -0
  17. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/runtime/object_collision.py +0 -0
  18. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/runtime/renderer.py +0 -0
  19. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/runtime/tile_collision.py +0 -0
  20. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/utils/__init__.py +0 -0
  21. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser/utils/geometry.py +0 -0
  22. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser.egg-info/SOURCES.txt +0 -0
  23. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser.egg-info/dependency_links.txt +0 -0
  24. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser.egg-info/requires.txt +0 -0
  25. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/src/tilemap_parser.egg-info/top_level.txt +0 -0
  26. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/tests/test_collision.py +0 -0
  27. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/tests/test_geometry.py +0 -0
  28. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/tests/test_map_loader.py +0 -0
  29. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/tests/test_object_collision.py +0 -0
  30. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/tests/test_render_scale.py +0 -0
  31. {tilemap_parser-3.1.5 → tilemap_parser-3.1.7}/tests/test_tile_collision.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tilemap-parser
3
- Version: 3.1.5
3
+ Version: 3.1.7
4
4
  Summary: Standalone parser/loader for tilemap-editor JSON maps, sprite animations, and collision detection runtime.
5
5
  Author: tilemap parser contributors
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tilemap-parser"
7
- version = "3.1.5"
7
+ version = "3.1.7"
8
8
  description = "Standalone parser/loader for tilemap-editor JSON maps, sprite animations, and collision detection runtime."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -98,6 +98,7 @@ class AnimationLibrary:
98
98
  spritesheet_path: Optional[str] = None
99
99
  tile_size: Tuple[int, int] = (32, 32)
100
100
  grid_offset: Tuple[int, int] = (0, 0)
101
+ trim_transparent: bool = False
101
102
 
102
103
  def get(self, name: str) -> Optional[AnimationClip]:
103
104
  return self.animations.get(name)
@@ -168,7 +169,9 @@ def parse_animation_dict(data: Dict[str, Any]) -> AnimationLibrary:
168
169
  k = str(key)
169
170
  animations[k] = _parse_animation(k, _req_dict(value, f"animations[{k!r}]"), f"animations[{k!r}]")
170
171
 
171
- return AnimationLibrary(animations=animations, spritesheet_path=spritesheet_path, tile_size=(tw, th), grid_offset=(gox, goy))
172
+ trim_transparent = bool(root.get("trim_transparent", False))
173
+
174
+ return AnimationLibrary(animations=animations, spritesheet_path=spritesheet_path, tile_size=(tw, th), grid_offset=(gox, goy), trim_transparent=trim_transparent)
172
175
 
173
176
 
174
177
  def parse_animation_json(text: str) -> AnimationLibrary:
@@ -68,6 +68,24 @@ class SpriteAnimationSet:
68
68
  grid_offset_y=library.grid_offset[1],
69
69
  )
70
70
 
71
+ def get_content_bounds(self, clip_name: str) -> Optional[Rect]:
72
+ clip = self.library.get(clip_name)
73
+ if clip is None or not clip.frames:
74
+ return None
75
+ union: Optional[Rect] = None
76
+ for frame in clip.frames:
77
+ surf = self.get_image(frame.variant_id, copy_surface=False)
78
+ if surf is None:
79
+ continue
80
+ rect = surf.get_bounding_rect()
81
+ if rect.width == 0 or rect.height == 0:
82
+ continue
83
+ if union is None:
84
+ union = rect.copy()
85
+ else:
86
+ union.union_ip(rect)
87
+ return union
88
+
71
89
  def get_image(self, variant_id: int, *, copy_surface: bool = True) -> Optional[Surface]:
72
90
  tw, th = self.library.tile_size
73
91
  if tw <= 0 or th <= 0:
@@ -83,6 +101,10 @@ class SpriteAnimationSet:
83
101
  if not self.surface.get_rect().contains(src):
84
102
  return None
85
103
  cel = self.surface.subsurface(src)
104
+ if self.library.trim_transparent:
105
+ brect = cel.get_bounding_rect()
106
+ if brect:
107
+ cel = cel.subsurface(brect)
86
108
  return cel.copy() if copy_surface else cel
87
109
 
88
110
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tilemap-parser
3
- Version: 3.1.5
3
+ Version: 3.1.7
4
4
  Summary: Standalone parser/loader for tilemap-editor JSON maps, sprite animations, and collision detection runtime.
5
5
  Author: tilemap parser contributors
6
6
  License: GNU GENERAL PUBLIC LICENSE
File without changes
File without changes
File without changes