pygkit 2.2.0__tar.gz → 2.3.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.
- {pygkit-2.2.0 → pygkit-2.3.0}/PKG-INFO +155 -6
- pygkit-2.3.0/README.md +184 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/pyproject.toml +4 -2
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/__init__.py +30 -0
- pygkit-2.3.0/src/pygkit/debug/__init__.py +22 -0
- pygkit-2.3.0/src/pygkit/debug/config.py +101 -0
- pygkit-2.3.0/src/pygkit/debug/core.py +945 -0
- pygkit-2.3.0/src/pygkit/debug/overlay.py +386 -0
- pygkit-2.3.0/src/pygkit/debug/sinks.py +273 -0
- pygkit-2.3.0/src/pygkit/debug/types.py +32 -0
- pygkit-2.3.0/src/pygkit/effects/__init__.py +12 -0
- pygkit-2.3.0/src/pygkit/effects/outline.py +475 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/lighting/__init__.py +16 -4
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/lighting/blend.py +10 -0
- pygkit-2.3.0/src/pygkit/lighting/group.py +133 -0
- pygkit-2.3.0/src/pygkit/lighting/lightmap.py +756 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/lighting/lights.py +363 -64
- pygkit-2.3.0/src/pygkit/lighting/occlusion.py +249 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/lighting/sprites.py +69 -1
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/utils/__init__.py +6 -0
- pygkit-2.3.0/src/pygkit/utils/diagnostics.py +71 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit.egg-info/PKG-INFO +155 -6
- pygkit-2.3.0/src/pygkit.egg-info/SOURCES.txt +93 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit.egg-info/requires.txt +5 -1
- pygkit-2.3.0/tests/test_debug.py +531 -0
- pygkit-2.3.0/tests/test_effects.py +276 -0
- pygkit-2.3.0/tests/test_lighting.py +1137 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_packaging.py +16 -1
- pygkit-2.2.0/README.md +0 -37
- pygkit-2.2.0/src/pygkit/lighting/lightmap.py +0 -170
- pygkit-2.2.0/src/pygkit/transitions/__init__.py +0 -18
- pygkit-2.2.0/src/pygkit.egg-info/SOURCES.txt +0 -151
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/__init__.py +0 -46
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/__pycache__/__init__.cpython-312.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/__pycache__/__init__.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/__init__.py +0 -6
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/__pycache__/__init__.cpython-312.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/__pycache__/__init__.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/__pycache__/soundmanager.cpython-312.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/__pycache__/soundmanager.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/audio/soundmanager.py +0 -89
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__init__.py +0 -103
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/__init__.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/base.cpython-312.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/base.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/compositors.cpython-312.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/compositors.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/generators.cpython-312.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/generators.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/__pycache__/transitions.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/base.py +0 -220
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/__init__.py +0 -32
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/__pycache__/__init__.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/__pycache__/color.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/__pycache__/lighting.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/__pycache__/masks.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/color.py +0 -237
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/lighting.py +0 -261
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/components/masks.py +0 -287
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/compositors.py +0 -142
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/generators.py +0 -318
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/effects/transitions.py +0 -194
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__init__.py +0 -93
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__pycache__/__init__.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__pycache__/assets.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__pycache__/core.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__pycache__/data.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/__pycache__/ui.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/assets.py +0 -338
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/core.py +0 -614
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/data.py +0 -273
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/inventory/ui.py +0 -775
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/protocols.py +0 -29
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/__pycache__/__init__.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/__pycache__/base.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/__pycache__/effects.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/__pycache__/fades.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/__pycache__/wipes.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/base.py +0 -97
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/effects.py +0 -156
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/fades.py +0 -196
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/transitions/wipes.py +0 -185
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__init__.py +0 -21
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/__init__.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/base.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/container.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/cooldown.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/dialog.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/__pycache__/progressbar.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/base.py +0 -126
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/container.py +0 -21
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/cooldown.py +0 -107
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/dialog.py +0 -540
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/ui/progressbar.py +0 -64
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/__init__.py +0 -19
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/__pycache__/__init__.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/__pycache__/interpolation.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/__pycache__/text.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/__pycache__/timer.cpython-313.pyc +0 -0
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/interpolation.py +0 -45
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/text.py +0 -147
- pygkit-2.2.0/src/pygkit.egg-info/pygkit/utils/timer.py +0 -35
- pygkit-2.2.0/tests/test_lighting.py +0 -376
- {pygkit-2.2.0 → pygkit-2.3.0}/LICENSE +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/setup.cfg +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/animation/__init__.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/animation/player.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/animation/sheet.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/audio/__init__.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/audio/soundmanager.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/inventory/__init__.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/inventory/assets.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/inventory/core.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/inventory/data.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/inventory/ui.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/parallax/__init__.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/parallax/background.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/parallax/camera.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/protocols.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/signals/__init__.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/signals/core.py +0 -0
- {pygkit-2.2.0/src/pygkit.egg-info → pygkit-2.3.0/src}/pygkit/transitions/__init__.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/transitions/base.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/transitions/effects.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/transitions/fades.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/transitions/wipes.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/__init__.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/anchors.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/base.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/button.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/container.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/cooldown.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/dialog.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/layout.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/menubar.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/panel.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/progressbar.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/ui/theming.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/utils/interpolation.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/utils/text.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit/utils/timer.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit.egg-info/dependency_links.txt +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit.egg-info/pygkit.egg-info/dependency_links.txt +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit.egg-info/pygkit.egg-info/pkg-info +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit.egg-info/pygkit.egg-info/requires.txt +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit.egg-info/pygkit.egg-info/sources.txt +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit.egg-info/pygkit.egg-info/top_level.txt +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/src/pygkit.egg-info/top_level.txt +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_anchors.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_animation.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_audio.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_background_images.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_box_model.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_button.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_container.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_cooldown.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_dialog.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_interpolation.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_inventory.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_layout.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_menubar.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_pack_spritesheet.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_panel.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_parallax.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_progressbar_image.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_signals.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_text.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_theming.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_timer.py +0 -0
- {pygkit-2.2.0 → pygkit-2.3.0}/tests/test_transitions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pygkit
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.0
|
|
4
4
|
Summary: General-purpose Pygame CE runtime kit: UI widgets, audio, timers, interpolation, and more.
|
|
5
5
|
Author: pygkit contributors
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
@@ -702,8 +702,10 @@ Provides-Extra: lighting
|
|
|
702
702
|
Provides-Extra: transitions
|
|
703
703
|
Provides-Extra: inventory
|
|
704
704
|
Provides-Extra: parallax
|
|
705
|
+
Provides-Extra: debug
|
|
706
|
+
Provides-Extra: effects
|
|
705
707
|
Provides-Extra: all
|
|
706
|
-
Requires-Dist: pygkit[animation,audio,inventory,lighting,parallax,transitions,ui]; extra == "all"
|
|
708
|
+
Requires-Dist: pygkit[animation,audio,debug,effects,inventory,lighting,parallax,transitions,ui]; extra == "all"
|
|
707
709
|
Dynamic: license-file
|
|
708
710
|
|
|
709
711
|
# pygkit
|
|
@@ -726,9 +728,156 @@ import pygkit
|
|
|
726
728
|
- **Audio**: SoundManager with channel pools, kind/key addressing, volume buses, fades
|
|
727
729
|
- **Lighting**: low-resolution light map pipeline (`LightMap`), point lights
|
|
728
730
|
with flicker, wind-reactive `DynamicLight` flames, and cone `Spotlight` —
|
|
729
|
-
|
|
731
|
+
rect occlusion, wall-surface reveal, persistent fog-of-war memory,
|
|
732
|
+
fades/wobble/light groups, full RGB/RGBA blend modes, and reusable
|
|
733
|
+
scratch surfaces
|
|
734
|
+
- **Effects**: cached sprite silhouette outlines with optional glow —
|
|
735
|
+
follows holes and disconnected parts, and works with or without the
|
|
736
|
+
light map
|
|
730
737
|
- **Transitions**: Screen transitions with fade, wipe, and custom effects
|
|
731
|
-
- **
|
|
738
|
+
- **Debug**: lazily loaded `Debug` session with coalesced logfmt/JSONL
|
|
739
|
+
logs, lazy HUD watches, and an immediate-mode overlay whose draw calls
|
|
740
|
+
are queued and flushed by one `debug.render(screen)` call before
|
|
741
|
+
`display.flip()`
|
|
742
|
+
- **Utils**: Timer, interpolation/easing functions, lazy debug values
|
|
743
|
+
|
|
744
|
+
## Debug overlay
|
|
745
|
+
|
|
746
|
+
```python
|
|
747
|
+
from pygkit import Debug
|
|
748
|
+
|
|
749
|
+
debug = Debug(file="debug.log", coalesce="session")
|
|
750
|
+
debug.set_camera(camera) # enables space="world"
|
|
751
|
+
debug.watch("player/pos", lambda: (hero.x, hero.y))
|
|
752
|
+
|
|
753
|
+
while running:
|
|
754
|
+
...
|
|
755
|
+
debug.rect(hero.hitbox, color="red", space="world")
|
|
756
|
+
debug.render(screen) # last call before display.flip()
|
|
757
|
+
pygame.display.flip()
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
Call `render` on the final presentation surface (after any scaling or
|
|
761
|
+
letterboxing), so the overlay is not scaled with the scene and stays on top.
|
|
762
|
+
Call `debug.handle_event(event)` in your event loop to enable F3/F4/F5.
|
|
763
|
+
`debug.log(...)`, `debug.event(...)`, `debug.watch(...)`, and the draw
|
|
764
|
+
helpers are cheap when disabled. Repeated entries are grouped with counts
|
|
765
|
+
in the file and in the on-screen log panel; events group by event name and
|
|
766
|
+
call site by default, and `key=` groups the same event across call sites.
|
|
767
|
+
`Debug` reads lazy values only when logging is enabled (or the HUD is
|
|
768
|
+
visible). Use `file_format="jsonl"` for one JSON object per line. Toggle
|
|
769
|
+
HUD, log panel, and shapes with F3/F4/F5.
|
|
770
|
+
|
|
771
|
+
## Lighting
|
|
772
|
+
|
|
773
|
+
```python
|
|
774
|
+
from pygkit.lighting import LightMap, PointLight, tile_rects
|
|
775
|
+
|
|
776
|
+
lightmap = LightMap((800, 600), scale=0.5, explored_dim=0.35)
|
|
777
|
+
lightmap.set_ambient((20, 25, 40), 0.15)
|
|
778
|
+
lightmap.set_occluders(tile_rects((32, 32), solid_cells))
|
|
779
|
+
|
|
780
|
+
torch = PointLight(radius=140, color=(255, 190, 120))
|
|
781
|
+
torch.set_flicker(frequency=8.0, amplitude=0.2, seed=1.0)
|
|
782
|
+
|
|
783
|
+
while running:
|
|
784
|
+
lightmap.clear()
|
|
785
|
+
torch.render(lightmap, player.x, player.y)
|
|
786
|
+
lightmap.reveal(player.x, player.y, 96)
|
|
787
|
+
lightmap.apply(scene)
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
`tile_rects` turns solid `(column, row)` cells into scene-space rectangles;
|
|
791
|
+
any collision system can pass its own `pygame.Rect` list to
|
|
792
|
+
`set_occluders` instead. Lights cast hard shadows by default; set
|
|
793
|
+
`light.cast_shadows = False` for moonlight or ambient-style lights, or
|
|
794
|
+
`lightmap.shadows = False` to disable all light shadows.
|
|
795
|
+
|
|
796
|
+
Walls touched by light are drawn on their visible face by default
|
|
797
|
+
(`wall_reveal=True`), while the space behind each wall stays shadowed.
|
|
798
|
+
Set `lightmap.wall_reveal = False` for the original fully dark wall
|
|
799
|
+
footprint, or pass `wall_reveal=False` to one `reveal()` call. Use
|
|
800
|
+
per-tile occluders (`tile_rects(..., merge=False)`) when a thick wall
|
|
801
|
+
should reveal only its front row instead of the whole merged block.
|
|
802
|
+
|
|
803
|
+
`explored_dim` enables persistent fog-of-war memory: areas stay dimly
|
|
804
|
+
visible after a light leaves, while unexplored areas stay dark. Current
|
|
805
|
+
lights are remembered separately from ambient, so ambient light does not
|
|
806
|
+
reveal the map. Call `lightmap.reset_explored()` when loading a new level.
|
|
807
|
+
For pitch-black unexplored areas, keep ambient at `0`.
|
|
808
|
+
|
|
809
|
+
`reveal()` adds a persistent clearance brush that is independent of
|
|
810
|
+
lights. Call it each frame for the player, or once for a discovered room.
|
|
811
|
+
Clearance is stored separately from light-derived memory, so the original
|
|
812
|
+
tiles show at the brush color instead of being dimmed by `explored_dim`
|
|
813
|
+
(white = full brightness; pass a darker color for a dimmer reveal).
|
|
814
|
+
Occluders block it by default (`walls=False` ignores them), and
|
|
815
|
+
`current=True` also adds it to the current light layer. Call
|
|
816
|
+
`lightmap.clear_clearance()` to forget reveals while keeping light memory.
|
|
817
|
+
|
|
818
|
+
For an interactive example, run `python examples/lighting_fog_demo.py`:
|
|
819
|
+
move the mouse to explore, `F` toggles clearance, `L` toggles the lantern,
|
|
820
|
+
and `X` resets explored memory.
|
|
821
|
+
|
|
822
|
+
For a wall-reveal comparison, run `python examples/lighting_walls_demo.py`:
|
|
823
|
+
move the mouse to guide the lantern and press `W` to switch between lit
|
|
824
|
+
wall faces and the fully dark wall footprint.
|
|
825
|
+
|
|
826
|
+
Lights also support smooth property changes and organic motion:
|
|
827
|
+
|
|
828
|
+
```python
|
|
829
|
+
torch.fade_to(0.0, duration=0.4)
|
|
830
|
+
torch.radius_to(220, duration=0.8)
|
|
831
|
+
torch.color_to((255, 120, 80), duration=0.6)
|
|
832
|
+
torch.set_wobble(amplitude=2.5, frequency=1.1)
|
|
833
|
+
torch.advance(dt) # drives flicker, wobble, and tweens
|
|
834
|
+
```
|
|
835
|
+
|
|
836
|
+
`LightGroup` pairs lights with static positions or position callables and
|
|
837
|
+
updates/renders them together:
|
|
838
|
+
|
|
839
|
+
```python
|
|
840
|
+
group = LightGroup()
|
|
841
|
+
group.add(torch, 120, 300)
|
|
842
|
+
group.add(player_light, lambda: (player.x, player.y))
|
|
843
|
+
group.update(dt)
|
|
844
|
+
group.render(lightmap)
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
## Sprite outlines
|
|
848
|
+
|
|
849
|
+
`SpriteOutline` builds a silhouette rim from the sprite's alpha mask and
|
|
850
|
+
caches it per sprite. Drawing a stable sprite costs one rim blit and,
|
|
851
|
+
optionally, one additive glow blit:
|
|
852
|
+
|
|
853
|
+
```python
|
|
854
|
+
from pygkit.effects import SpriteOutline
|
|
855
|
+
|
|
856
|
+
outline = SpriteOutline(
|
|
857
|
+
(120, 220, 255),
|
|
858
|
+
thickness=2,
|
|
859
|
+
glow=4,
|
|
860
|
+
glow_color=(50, 150, 255),
|
|
861
|
+
)
|
|
862
|
+
|
|
863
|
+
# Emissive: draw after the light map, so it stays readable in darkness.
|
|
864
|
+
lightmap.apply(scene)
|
|
865
|
+
outline.draw(scene, player_sprite, player.x, player.y)
|
|
866
|
+
|
|
867
|
+
# Lit: draw before the light map, so lighting dims it.
|
|
868
|
+
# outline.draw(scene, player_sprite, player.x, player.y)
|
|
869
|
+
# lightmap.apply(scene)
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
The rim includes holes and disconnected parts. Use `key=` when one surface
|
|
873
|
+
is reused for different animation frames, or call `clear_cache()` after
|
|
874
|
+
mutating a sprite in place. `outline_surface()` returns a one-shot padded
|
|
875
|
+
surface, and `outline_points()` wraps `Mask.outline()` for effects that
|
|
876
|
+
need a single contour point list.
|
|
877
|
+
|
|
878
|
+
For an interactive example, run `python examples/effects_outline_demo.py`:
|
|
879
|
+
move the mouse, `O` toggles outlines, `L` toggles the light map, and `E`
|
|
880
|
+
switches between emissive and lit outlines.
|
|
732
881
|
|
|
733
882
|
## Installation
|
|
734
883
|
|
|
@@ -739,7 +888,7 @@ pip install "pygkit[all]" # everything
|
|
|
739
888
|
```
|
|
740
889
|
|
|
741
890
|
Available extras: `ui`, `audio`, `animation`, `lighting`,
|
|
742
|
-
`transitions`, `inventory`, `parallax`, `
|
|
743
|
-
core only; subsystems load lazily on first use.
|
|
891
|
+
`transitions`, `inventory`, `parallax`, `debug`, `effects`, `all`.
|
|
892
|
+
`import pygkit` alone loads core only; subsystems load lazily on first use.
|
|
744
893
|
|
|
745
894
|
> Extra: lightning idea was extended version of [https://www.youtube.com/watch?v=LN7u20H7zK4](https://www.youtube.com/watch?v=LN7u20H7zK4) which was my first attempt of making lightning after learning blend modes.
|
pygkit-2.3.0/README.md
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# pygkit
|
|
2
|
+
|
|
3
|
+
General-purpose Pygame CE runtime kit: UI widgets, audio management, timers, interpolation, and utilities.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```python
|
|
8
|
+
import pygkit
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **UI**: Box-model widgets with plugin compositing — progress bars, cooldown overlays, containers, dialog system, buttons, menubar container, anchor/row/grid placement helpers
|
|
14
|
+
- **Events**: Menubar/Container route mouse events to nested layouts; hit-testing is active from the first rendered frame
|
|
15
|
+
- **Animation**: Multi-state `AnimationPlayer` where every state owns its own spritesheet — mixed image sizes and grids (e.g. `idle_spritesheet.png` vs `run_spritesheet.png`) in one player; pure image API, no JSON
|
|
16
|
+
- **Dialog**: Typewriter effect with customizable speeds, speaker names, and progress indicators
|
|
17
|
+
- **Inventory**: Grid-based item management with stacking, weight tracking, events, and serialization
|
|
18
|
+
- **Audio**: SoundManager with channel pools, kind/key addressing, volume buses, fades
|
|
19
|
+
- **Lighting**: low-resolution light map pipeline (`LightMap`), point lights
|
|
20
|
+
with flicker, wind-reactive `DynamicLight` flames, and cone `Spotlight` —
|
|
21
|
+
rect occlusion, wall-surface reveal, persistent fog-of-war memory,
|
|
22
|
+
fades/wobble/light groups, full RGB/RGBA blend modes, and reusable
|
|
23
|
+
scratch surfaces
|
|
24
|
+
- **Effects**: cached sprite silhouette outlines with optional glow —
|
|
25
|
+
follows holes and disconnected parts, and works with or without the
|
|
26
|
+
light map
|
|
27
|
+
- **Transitions**: Screen transitions with fade, wipe, and custom effects
|
|
28
|
+
- **Debug**: lazily loaded `Debug` session with coalesced logfmt/JSONL
|
|
29
|
+
logs, lazy HUD watches, and an immediate-mode overlay whose draw calls
|
|
30
|
+
are queued and flushed by one `debug.render(screen)` call before
|
|
31
|
+
`display.flip()`
|
|
32
|
+
- **Utils**: Timer, interpolation/easing functions, lazy debug values
|
|
33
|
+
|
|
34
|
+
## Debug overlay
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
from pygkit import Debug
|
|
38
|
+
|
|
39
|
+
debug = Debug(file="debug.log", coalesce="session")
|
|
40
|
+
debug.set_camera(camera) # enables space="world"
|
|
41
|
+
debug.watch("player/pos", lambda: (hero.x, hero.y))
|
|
42
|
+
|
|
43
|
+
while running:
|
|
44
|
+
...
|
|
45
|
+
debug.rect(hero.hitbox, color="red", space="world")
|
|
46
|
+
debug.render(screen) # last call before display.flip()
|
|
47
|
+
pygame.display.flip()
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Call `render` on the final presentation surface (after any scaling or
|
|
51
|
+
letterboxing), so the overlay is not scaled with the scene and stays on top.
|
|
52
|
+
Call `debug.handle_event(event)` in your event loop to enable F3/F4/F5.
|
|
53
|
+
`debug.log(...)`, `debug.event(...)`, `debug.watch(...)`, and the draw
|
|
54
|
+
helpers are cheap when disabled. Repeated entries are grouped with counts
|
|
55
|
+
in the file and in the on-screen log panel; events group by event name and
|
|
56
|
+
call site by default, and `key=` groups the same event across call sites.
|
|
57
|
+
`Debug` reads lazy values only when logging is enabled (or the HUD is
|
|
58
|
+
visible). Use `file_format="jsonl"` for one JSON object per line. Toggle
|
|
59
|
+
HUD, log panel, and shapes with F3/F4/F5.
|
|
60
|
+
|
|
61
|
+
## Lighting
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from pygkit.lighting import LightMap, PointLight, tile_rects
|
|
65
|
+
|
|
66
|
+
lightmap = LightMap((800, 600), scale=0.5, explored_dim=0.35)
|
|
67
|
+
lightmap.set_ambient((20, 25, 40), 0.15)
|
|
68
|
+
lightmap.set_occluders(tile_rects((32, 32), solid_cells))
|
|
69
|
+
|
|
70
|
+
torch = PointLight(radius=140, color=(255, 190, 120))
|
|
71
|
+
torch.set_flicker(frequency=8.0, amplitude=0.2, seed=1.0)
|
|
72
|
+
|
|
73
|
+
while running:
|
|
74
|
+
lightmap.clear()
|
|
75
|
+
torch.render(lightmap, player.x, player.y)
|
|
76
|
+
lightmap.reveal(player.x, player.y, 96)
|
|
77
|
+
lightmap.apply(scene)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`tile_rects` turns solid `(column, row)` cells into scene-space rectangles;
|
|
81
|
+
any collision system can pass its own `pygame.Rect` list to
|
|
82
|
+
`set_occluders` instead. Lights cast hard shadows by default; set
|
|
83
|
+
`light.cast_shadows = False` for moonlight or ambient-style lights, or
|
|
84
|
+
`lightmap.shadows = False` to disable all light shadows.
|
|
85
|
+
|
|
86
|
+
Walls touched by light are drawn on their visible face by default
|
|
87
|
+
(`wall_reveal=True`), while the space behind each wall stays shadowed.
|
|
88
|
+
Set `lightmap.wall_reveal = False` for the original fully dark wall
|
|
89
|
+
footprint, or pass `wall_reveal=False` to one `reveal()` call. Use
|
|
90
|
+
per-tile occluders (`tile_rects(..., merge=False)`) when a thick wall
|
|
91
|
+
should reveal only its front row instead of the whole merged block.
|
|
92
|
+
|
|
93
|
+
`explored_dim` enables persistent fog-of-war memory: areas stay dimly
|
|
94
|
+
visible after a light leaves, while unexplored areas stay dark. Current
|
|
95
|
+
lights are remembered separately from ambient, so ambient light does not
|
|
96
|
+
reveal the map. Call `lightmap.reset_explored()` when loading a new level.
|
|
97
|
+
For pitch-black unexplored areas, keep ambient at `0`.
|
|
98
|
+
|
|
99
|
+
`reveal()` adds a persistent clearance brush that is independent of
|
|
100
|
+
lights. Call it each frame for the player, or once for a discovered room.
|
|
101
|
+
Clearance is stored separately from light-derived memory, so the original
|
|
102
|
+
tiles show at the brush color instead of being dimmed by `explored_dim`
|
|
103
|
+
(white = full brightness; pass a darker color for a dimmer reveal).
|
|
104
|
+
Occluders block it by default (`walls=False` ignores them), and
|
|
105
|
+
`current=True` also adds it to the current light layer. Call
|
|
106
|
+
`lightmap.clear_clearance()` to forget reveals while keeping light memory.
|
|
107
|
+
|
|
108
|
+
For an interactive example, run `python examples/lighting_fog_demo.py`:
|
|
109
|
+
move the mouse to explore, `F` toggles clearance, `L` toggles the lantern,
|
|
110
|
+
and `X` resets explored memory.
|
|
111
|
+
|
|
112
|
+
For a wall-reveal comparison, run `python examples/lighting_walls_demo.py`:
|
|
113
|
+
move the mouse to guide the lantern and press `W` to switch between lit
|
|
114
|
+
wall faces and the fully dark wall footprint.
|
|
115
|
+
|
|
116
|
+
Lights also support smooth property changes and organic motion:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
torch.fade_to(0.0, duration=0.4)
|
|
120
|
+
torch.radius_to(220, duration=0.8)
|
|
121
|
+
torch.color_to((255, 120, 80), duration=0.6)
|
|
122
|
+
torch.set_wobble(amplitude=2.5, frequency=1.1)
|
|
123
|
+
torch.advance(dt) # drives flicker, wobble, and tweens
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
`LightGroup` pairs lights with static positions or position callables and
|
|
127
|
+
updates/renders them together:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
group = LightGroup()
|
|
131
|
+
group.add(torch, 120, 300)
|
|
132
|
+
group.add(player_light, lambda: (player.x, player.y))
|
|
133
|
+
group.update(dt)
|
|
134
|
+
group.render(lightmap)
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Sprite outlines
|
|
138
|
+
|
|
139
|
+
`SpriteOutline` builds a silhouette rim from the sprite's alpha mask and
|
|
140
|
+
caches it per sprite. Drawing a stable sprite costs one rim blit and,
|
|
141
|
+
optionally, one additive glow blit:
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from pygkit.effects import SpriteOutline
|
|
145
|
+
|
|
146
|
+
outline = SpriteOutline(
|
|
147
|
+
(120, 220, 255),
|
|
148
|
+
thickness=2,
|
|
149
|
+
glow=4,
|
|
150
|
+
glow_color=(50, 150, 255),
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
# Emissive: draw after the light map, so it stays readable in darkness.
|
|
154
|
+
lightmap.apply(scene)
|
|
155
|
+
outline.draw(scene, player_sprite, player.x, player.y)
|
|
156
|
+
|
|
157
|
+
# Lit: draw before the light map, so lighting dims it.
|
|
158
|
+
# outline.draw(scene, player_sprite, player.x, player.y)
|
|
159
|
+
# lightmap.apply(scene)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The rim includes holes and disconnected parts. Use `key=` when one surface
|
|
163
|
+
is reused for different animation frames, or call `clear_cache()` after
|
|
164
|
+
mutating a sprite in place. `outline_surface()` returns a one-shot padded
|
|
165
|
+
surface, and `outline_points()` wraps `Mask.outline()` for effects that
|
|
166
|
+
need a single contour point list.
|
|
167
|
+
|
|
168
|
+
For an interactive example, run `python examples/effects_outline_demo.py`:
|
|
169
|
+
move the mouse, `O` toggles outlines, `L` toggles the light map, and `E`
|
|
170
|
+
switches between emissive and lit outlines.
|
|
171
|
+
|
|
172
|
+
## Installation
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
pip install pygkit # core: signals, utils, protocols
|
|
176
|
+
pip install "pygkit[ui]" # widgets, dialog, cooldowns
|
|
177
|
+
pip install "pygkit[all]" # everything
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Available extras: `ui`, `audio`, `animation`, `lighting`,
|
|
181
|
+
`transitions`, `inventory`, `parallax`, `debug`, `effects`, `all`.
|
|
182
|
+
`import pygkit` alone loads core only; subsystems load lazily on first use.
|
|
183
|
+
|
|
184
|
+
> Extra: lightning idea was extended version of [https://www.youtube.com/watch?v=LN7u20H7zK4](https://www.youtube.com/watch?v=LN7u20H7zK4) which was my first attempt of making lightning after learning blend modes.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pygkit"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.3.0"
|
|
8
8
|
description = "General-purpose Pygame CE runtime kit: UI widgets, audio, timers, interpolation, and more."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -39,8 +39,10 @@ lighting = []
|
|
|
39
39
|
transitions = []
|
|
40
40
|
inventory = []
|
|
41
41
|
parallax = []
|
|
42
|
+
debug = []
|
|
43
|
+
effects = []
|
|
42
44
|
all = [
|
|
43
|
-
"pygkit[ui, audio, animation, lighting, transitions, inventory, parallax]",
|
|
45
|
+
"pygkit[ui, audio, animation, lighting, transitions, inventory, parallax, debug, effects]",
|
|
44
46
|
]
|
|
45
47
|
|
|
46
48
|
[project.urls]
|
|
@@ -16,16 +16,21 @@ from typing import Any
|
|
|
16
16
|
from .protocols import Clickable, Drawable, Renderable, UIElement, Updateable, Widget
|
|
17
17
|
from .signals import Signal, SignalBus, signal
|
|
18
18
|
from .utils import (
|
|
19
|
+
Lazy,
|
|
19
20
|
SimpleInterpolation,
|
|
20
21
|
Timer,
|
|
21
22
|
ease_in,
|
|
22
23
|
ease_in_out,
|
|
23
24
|
ease_out,
|
|
24
25
|
fit,
|
|
26
|
+
lazy,
|
|
25
27
|
lerp,
|
|
26
28
|
load_font,
|
|
27
29
|
outline,
|
|
28
30
|
render_multiline,
|
|
31
|
+
resolve,
|
|
32
|
+
safe_repr,
|
|
33
|
+
safe_str,
|
|
29
34
|
shadow,
|
|
30
35
|
smoothstep,
|
|
31
36
|
wrap,
|
|
@@ -46,6 +51,8 @@ _LAZY_ATTRS: dict[str, str] = {
|
|
|
46
51
|
"PointLight": "lighting",
|
|
47
52
|
"Spotlight": "lighting",
|
|
48
53
|
"DynamicLight": "lighting",
|
|
54
|
+
"LightGroup": "lighting",
|
|
55
|
+
"tile_rects": "lighting",
|
|
49
56
|
"glow_sprite": "lighting",
|
|
50
57
|
"spotlight_sprite": "lighting",
|
|
51
58
|
"dynamic_glow_sprite": "lighting",
|
|
@@ -61,7 +68,12 @@ _LAZY_ATTRS: dict[str, str] = {
|
|
|
61
68
|
"RGBA_MIN": "lighting",
|
|
62
69
|
"RGBA_MAX": "lighting",
|
|
63
70
|
"LIGHT_ADD": "lighting",
|
|
71
|
+
"LIGHT_REMEMBER": "lighting",
|
|
72
|
+
"FOG_DIM": "lighting",
|
|
64
73
|
"SCENE_MULT": "lighting",
|
|
74
|
+
"SpriteOutline": "effects",
|
|
75
|
+
"outline_surface": "effects",
|
|
76
|
+
"outline_points": "effects",
|
|
65
77
|
"TransitionRunner": "transitions",
|
|
66
78
|
"TransitionState": "transitions",
|
|
67
79
|
"FadeToBlack": "transitions",
|
|
@@ -120,6 +132,9 @@ _LAZY_ATTRS: dict[str, str] = {
|
|
|
120
132
|
"DragDropState": "inventory",
|
|
121
133
|
"InventoryWidget": "inventory",
|
|
122
134
|
"InventoryManager": "inventory",
|
|
135
|
+
"Debug": "debug",
|
|
136
|
+
"DebugConfig": "debug",
|
|
137
|
+
"DebugEntry": "debug",
|
|
123
138
|
}
|
|
124
139
|
|
|
125
140
|
__all__ = [
|
|
@@ -137,6 +152,8 @@ __all__ = [
|
|
|
137
152
|
"PointLight",
|
|
138
153
|
"Spotlight",
|
|
139
154
|
"DynamicLight",
|
|
155
|
+
"LightGroup",
|
|
156
|
+
"tile_rects",
|
|
140
157
|
"glow_sprite",
|
|
141
158
|
"spotlight_sprite",
|
|
142
159
|
"dynamic_glow_sprite",
|
|
@@ -152,7 +169,12 @@ __all__ = [
|
|
|
152
169
|
"RGBA_MIN",
|
|
153
170
|
"RGBA_MAX",
|
|
154
171
|
"LIGHT_ADD",
|
|
172
|
+
"LIGHT_REMEMBER",
|
|
173
|
+
"FOG_DIM",
|
|
155
174
|
"SCENE_MULT",
|
|
175
|
+
"SpriteOutline",
|
|
176
|
+
"outline_surface",
|
|
177
|
+
"outline_points",
|
|
156
178
|
"TransitionRunner",
|
|
157
179
|
"TransitionState",
|
|
158
180
|
"FadeToBlack",
|
|
@@ -211,6 +233,14 @@ __all__ = [
|
|
|
211
233
|
"DragDropState",
|
|
212
234
|
"InventoryWidget",
|
|
213
235
|
"InventoryManager",
|
|
236
|
+
"Debug",
|
|
237
|
+
"DebugConfig",
|
|
238
|
+
"DebugEntry",
|
|
239
|
+
"Lazy",
|
|
240
|
+
"lazy",
|
|
241
|
+
"resolve",
|
|
242
|
+
"safe_repr",
|
|
243
|
+
"safe_str",
|
|
214
244
|
"SimpleInterpolation",
|
|
215
245
|
"Timer",
|
|
216
246
|
"lerp",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""
|
|
2
|
+
pygkit debug - lazily loaded textual and visual debugging.
|
|
3
|
+
|
|
4
|
+
Queue visual primitives anywhere during the frame, then flush once::
|
|
5
|
+
|
|
6
|
+
from pygkit import Debug
|
|
7
|
+
|
|
8
|
+
debug = Debug(file="debug.log")
|
|
9
|
+
debug.watch("player/pos", lambda: hero.pos)
|
|
10
|
+
debug.rect(hero.hitbox, color="red", space="world")
|
|
11
|
+
|
|
12
|
+
while running:
|
|
13
|
+
...
|
|
14
|
+
debug.render(screen) # last call before display.flip()
|
|
15
|
+
pygame.display.flip()
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from .config import DebugConfig
|
|
19
|
+
from .core import Debug
|
|
20
|
+
from .types import DebugEntry
|
|
21
|
+
|
|
22
|
+
__all__ = ["Debug", "DebugConfig", "DebugEntry"]
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
LEVELS = {
|
|
7
|
+
"debug": 10,
|
|
8
|
+
"info": 20,
|
|
9
|
+
"warning": 30,
|
|
10
|
+
"error": 40,
|
|
11
|
+
"critical": 50,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
LEVEL_COLORS = {
|
|
15
|
+
"debug": (150, 156, 170),
|
|
16
|
+
"info": (210, 220, 235),
|
|
17
|
+
"warning": (245, 205, 110),
|
|
18
|
+
"error": (245, 120, 120),
|
|
19
|
+
"critical": (255, 90, 90),
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
_COALESCE_MODES = ("none", "session", "window")
|
|
23
|
+
_FILE_FORMATS = ("logfmt", "jsonl")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass(slots=True)
|
|
27
|
+
class DebugConfig:
|
|
28
|
+
"""Settings for a :class:`pygkit.debug.Debug` session."""
|
|
29
|
+
|
|
30
|
+
enabled: bool = True
|
|
31
|
+
level: str = "debug"
|
|
32
|
+
file: str | Path | None = None
|
|
33
|
+
file_format: str = "logfmt"
|
|
34
|
+
console: bool = False
|
|
35
|
+
capture: str | None = "pygkit"
|
|
36
|
+
coalesce: str = "session"
|
|
37
|
+
coalesce_window: float = 5.0
|
|
38
|
+
max_keys: int = 2048
|
|
39
|
+
flush_interval: float = 1.0
|
|
40
|
+
max_message_len: int = 2000
|
|
41
|
+
|
|
42
|
+
hud_visible: bool = True
|
|
43
|
+
hud_position: tuple[int, int] = (8, 8)
|
|
44
|
+
hud_font: str | None = None
|
|
45
|
+
hud_font_size: int = 16
|
|
46
|
+
hud_max_width: int = 520
|
|
47
|
+
title: str = "pygkit debug"
|
|
48
|
+
panel_alpha: int = 180
|
|
49
|
+
show_stats: bool = True
|
|
50
|
+
watch_max_len: int = 80
|
|
51
|
+
hotkeys: bool = True
|
|
52
|
+
|
|
53
|
+
log_visible: bool = False
|
|
54
|
+
log_tail: int = 8
|
|
55
|
+
log_max_entries: int = 200
|
|
56
|
+
|
|
57
|
+
show_shapes: bool = True
|
|
58
|
+
label_font_size: int = 14
|
|
59
|
+
max_primitives: int = 8192
|
|
60
|
+
|
|
61
|
+
def __post_init__(self) -> None:
|
|
62
|
+
self.level = str(self.level).lower()
|
|
63
|
+
if self.level not in LEVELS:
|
|
64
|
+
raise ValueError(f"level must be one of {tuple(LEVELS)}, got {self.level!r}")
|
|
65
|
+
if self.file is not None:
|
|
66
|
+
self.file = Path(self.file)
|
|
67
|
+
if self.file_format not in _FILE_FORMATS:
|
|
68
|
+
raise ValueError(
|
|
69
|
+
f"file_format must be one of {_FILE_FORMATS}, got {self.file_format!r}"
|
|
70
|
+
)
|
|
71
|
+
if self.coalesce not in _COALESCE_MODES:
|
|
72
|
+
raise ValueError(
|
|
73
|
+
f"coalesce must be one of {_COALESCE_MODES}, got {self.coalesce!r}"
|
|
74
|
+
)
|
|
75
|
+
if self.coalesce_window < 0:
|
|
76
|
+
raise ValueError("coalesce_window must be >= 0")
|
|
77
|
+
if self.max_keys < 1:
|
|
78
|
+
raise ValueError("max_keys must be >= 1")
|
|
79
|
+
if self.flush_interval < 0:
|
|
80
|
+
raise ValueError("flush_interval must be >= 0")
|
|
81
|
+
if self.max_message_len < 1:
|
|
82
|
+
raise ValueError("max_message_len must be >= 1")
|
|
83
|
+
if self.hud_font_size < 1:
|
|
84
|
+
raise ValueError("hud_font_size must be >= 1")
|
|
85
|
+
if self.label_font_size < 1:
|
|
86
|
+
raise ValueError("label_font_size must be >= 1")
|
|
87
|
+
if self.hud_max_width < 1:
|
|
88
|
+
raise ValueError("hud_max_width must be >= 1")
|
|
89
|
+
if self.log_tail < 0:
|
|
90
|
+
raise ValueError("log_tail must be >= 0")
|
|
91
|
+
if self.log_max_entries < 1:
|
|
92
|
+
raise ValueError("log_max_entries must be >= 1")
|
|
93
|
+
if self.max_primitives < 0:
|
|
94
|
+
raise ValueError("max_primitives must be >= 0")
|
|
95
|
+
if self.watch_max_len < 1:
|
|
96
|
+
raise ValueError("watch_max_len must be >= 1")
|
|
97
|
+
if not (0 <= self.panel_alpha <= 255):
|
|
98
|
+
raise ValueError("panel_alpha must be between 0 and 255")
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
__all__ = ["DebugConfig", "LEVELS", "LEVEL_COLORS"]
|