Skip to content

Conversation

@JaskRendix
Copy link
Contributor

@JaskRendix JaskRendix commented Feb 28, 2025

This pull request introduces a range of improvements:

  • improved smart_convert logic: adds a new preserve_alpha_flag parameter to optionally retain per-pixel alpha formatting, even when no transparency is detected, replaces manual pixel counting with the shared helper function has_transparency() for cleaner and more consistent transparency detection, introduces count_colorkey_pixels() to estimate colorkey coverage, deciding more intelligently when to apply RLEACCEL, and strengthens fallback behavior when mask operations fail
  • adds preserve_alpha_flag flag allows external tools or workflows to retain original surface format when alpha is present but not visibly used
  • adds complete type hints throughout the module, including accurate annotations for callables
  • switches all string formatting to f-strings for cleaner syntax and better readability
  • adds new unit tests for nuanced transparency cases, colorkey matching behavior, performance benchmarks, and zero-sized surfaces, all tests pass before and after the changes, ensuring consistency and reliability
  • refactors tileset and layer name lookups to use safer and more Pythonic patterns, with better error messages for unexpected types
  • optimizes the simplify() function for more efficient geometry handling
  • adds a protective check to ensure tiles are square before attempting diagonal flips, preventing misaligned transformations
  • standardizes error messages across utility functions for improved clarity

@JaskRendix JaskRendix force-pushed the util-pygame branch 3 times, most recently from 40117e6 to c484353 Compare February 28, 2025 15:40
@JaskRendix JaskRendix force-pushed the util-pygame branch 5 times, most recently from 7e3c972 to 89756ba Compare July 24, 2025 06:52
@JaskRendix JaskRendix changed the title util pygame Improve pytmx Pygame Loader, Unit Test and Cleaner Typing Jul 24, 2025
@pnearing
Copy link

I've forked the project and uploaded to pypi as pytmx-ng, I'd love to have your code in there, can you open a pull request here: https://github.com/pnearing/pytmx-ng ? Thanks, and I hope this helps you. (this goes for your other pull requests too)

@JaskRendix JaskRendix closed this Oct 5, 2025
@JaskRendix JaskRendix deleted the util-pygame branch October 15, 2025 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants