motionkit2d 1.0.1__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 (86) hide show
  1. motionkit2d-1.0.1/MANIFEST.in +19 -0
  2. motionkit2d-1.0.1/PKG-INFO +111 -0
  3. motionkit2d-1.0.1/README.md +94 -0
  4. motionkit2d-1.0.1/benchmarks/v1.json +35 -0
  5. motionkit2d-1.0.1/docs/guide.md +101 -0
  6. motionkit2d-1.0.1/docs/index.md +12 -0
  7. motionkit2d-1.0.1/docs/publishing.md +26 -0
  8. motionkit2d-1.0.1/docs/verification.md +31 -0
  9. motionkit2d-1.0.1/examples/classroom.py +108 -0
  10. motionkit2d-1.0.1/examples/director.py +16 -0
  11. motionkit2d-1.0.1/examples/episode.json +39 -0
  12. motionkit2d-1.0.1/examples/gpu_showcase.py +38 -0
  13. motionkit2d-1.0.1/examples/loi_hoi_tham.py +54 -0
  14. motionkit2d-1.0.1/examples/make_demo_audio.py +19 -0
  15. motionkit2d-1.0.1/examples/roadmap.py +16 -0
  16. motionkit2d-1.0.1/examples/vao_lop.py +4 -0
  17. motionkit2d-1.0.1/examples/vao_lop_doc.py +6 -0
  18. motionkit2d-1.0.1/pyproject.toml +30 -0
  19. motionkit2d-1.0.1/setup.cfg +7 -0
  20. motionkit2d-1.0.1/src/motionkit2d/__init__.py +49 -0
  21. motionkit2d-1.0.1/src/motionkit2d/__main__.py +115 -0
  22. motionkit2d-1.0.1/src/motionkit2d/acceleration.py +121 -0
  23. motionkit2d-1.0.1/src/motionkit2d/assets.py +319 -0
  24. motionkit2d-1.0.1/src/motionkit2d/audio.py +87 -0
  25. motionkit2d-1.0.1/src/motionkit2d/audio_analysis.py +55 -0
  26. motionkit2d-1.0.1/src/motionkit2d/camera.py +56 -0
  27. motionkit2d-1.0.1/src/motionkit2d/catalog.py +79 -0
  28. motionkit2d-1.0.1/src/motionkit2d/characters/__init__.py +4 -0
  29. motionkit2d-1.0.1/src/motionkit2d/characters/actions.py +125 -0
  30. motionkit2d-1.0.1/src/motionkit2d/characters/builder.py +15 -0
  31. motionkit2d-1.0.1/src/motionkit2d/characters/expressions.py +81 -0
  32. motionkit2d-1.0.1/src/motionkit2d/compiler.py +162 -0
  33. motionkit2d-1.0.1/src/motionkit2d/composition.py +50 -0
  34. motionkit2d-1.0.1/src/motionkit2d/constraints.py +91 -0
  35. motionkit2d-1.0.1/src/motionkit2d/cues.py +15 -0
  36. motionkit2d-1.0.1/src/motionkit2d/draw.py +416 -0
  37. motionkit2d-1.0.1/src/motionkit2d/dynamics.py +109 -0
  38. motionkit2d-1.0.1/src/motionkit2d/effects.py +131 -0
  39. motionkit2d-1.0.1/src/motionkit2d/environments.py +86 -0
  40. motionkit2d-1.0.1/src/motionkit2d/export.py +235 -0
  41. motionkit2d-1.0.1/src/motionkit2d/fonts/LICENSE.txt +130 -0
  42. motionkit2d-1.0.1/src/motionkit2d/fonts/LiberationSans-Regular.ttf +0 -0
  43. motionkit2d-1.0.1/src/motionkit2d/fonts/LiberationSerif-Bold.ttf +0 -0
  44. motionkit2d-1.0.1/src/motionkit2d/fonts/LiberationSerif-Regular.ttf +0 -0
  45. motionkit2d-1.0.1/src/motionkit2d/gpu.py +512 -0
  46. motionkit2d-1.0.1/src/motionkit2d/layout.py +89 -0
  47. motionkit2d-1.0.1/src/motionkit2d/manifest.py +96 -0
  48. motionkit2d-1.0.1/src/motionkit2d/mixer.py +92 -0
  49. motionkit2d-1.0.1/src/motionkit2d/preset_library.py +41 -0
  50. motionkit2d-1.0.1/src/motionkit2d/presets.py +33 -0
  51. motionkit2d-1.0.1/src/motionkit2d/props.py +126 -0
  52. motionkit2d-1.0.1/src/motionkit2d/qc.py +78 -0
  53. motionkit2d-1.0.1/src/motionkit2d/quality.py +122 -0
  54. motionkit2d-1.0.1/src/motionkit2d/rig.py +325 -0
  55. motionkit2d-1.0.1/src/motionkit2d/scene_graph.py +154 -0
  56. motionkit2d-1.0.1/src/motionkit2d/timeline.py +174 -0
  57. motionkit2d-1.0.1/src/motionkit2d/transitions.py +51 -0
  58. motionkit2d-1.0.1/src/motionkit2d/typography.py +118 -0
  59. motionkit2d-1.0.1/src/motionkit2d/visual_effects.py +104 -0
  60. motionkit2d-1.0.1/src/motionkit2d.egg-info/PKG-INFO +111 -0
  61. motionkit2d-1.0.1/src/motionkit2d.egg-info/SOURCES.txt +85 -0
  62. motionkit2d-1.0.1/src/motionkit2d.egg-info/dependency_links.txt +1 -0
  63. motionkit2d-1.0.1/src/motionkit2d.egg-info/entry_points.txt +2 -0
  64. motionkit2d-1.0.1/src/motionkit2d.egg-info/requires.txt +8 -0
  65. motionkit2d-1.0.1/src/motionkit2d.egg-info/top_level.txt +1 -0
  66. motionkit2d-1.0.1/tests/test_director.py +341 -0
  67. motionkit2d-1.0.1/tests/test_motionkit.py +75 -0
  68. motionkit2d-1.0.1/tests/test_roadmap.py +132 -0
  69. motionkit2d-1.0.1/tests/test_v02.py +225 -0
  70. motionkit2d-1.0.1/tests/test_v03.py +134 -0
  71. motionkit2d-1.0.1/tools/acceptance.py +62 -0
  72. motionkit2d-1.0.1/tools/acceptance_v04.py +46 -0
  73. motionkit2d-1.0.1/tools/acceptance_v1.py +34 -0
  74. motionkit2d-1.0.1/tools/benchmark_v03.py +43 -0
  75. motionkit2d-1.0.1/tools/benchmark_v1.py +34 -0
  76. motionkit2d-1.0.1/tools/check_distribution.py +50 -0
  77. motionkit2d-1.0.1/tools/diagnose_playback.ps1 +40 -0
  78. motionkit2d-1.0.1/tools/package_release.py +30 -0
  79. motionkit2d-1.0.1/tools/release_milestone.py +33 -0
  80. motionkit2d-1.0.1/verification/v1.0.0/acceptance.json +119 -0
  81. motionkit2d-1.0.1/verification/v1.0.0/benchmark.json +35 -0
  82. motionkit2d-1.0.1/verification/v1.0.0/manifest.json +15 -0
  83. motionkit2d-1.0.1/verification/v1.0.0/tests-installed.txt +67 -0
  84. motionkit2d-1.0.1/verification/v1.0.0/tests-source.txt +67 -0
  85. motionkit2d-1.0.1/verification/v1.0.1/manifest.json +8 -0
  86. motionkit2d-1.0.1/verification/v1.0.1/tests-installed.txt +67 -0
@@ -0,0 +1,19 @@
1
+ include README.md pyproject.toml setup.cfg MANIFEST.in
2
+ recursive-include docs *.md
3
+ recursive-include verification *.md *.txt *.json
4
+ recursive-include examples *.py *.json
5
+ recursive-include tools *.py *.ps1
6
+ recursive-include tests *.py
7
+ recursive-include benchmarks *.json
8
+ recursive-include src/motionkit2d *.py *.ttf LICENSE.txt
9
+ prune .git
10
+ prune .github
11
+ prune .venv-accept
12
+ prune .venv-v04
13
+ prune build
14
+ prune dist
15
+ prune projects
16
+ prune template
17
+ prune audio
18
+ prune output
19
+ global-exclude __pycache__ *.py[cod] .env .env.*
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.4
2
+ Name: motionkit2d
3
+ Version: 1.0.1
4
+ Summary: Deterministic 2D motion graphics from Python scenes
5
+ Project-URL: Repository, https://github.com/dangminhtai/motionkit2d
6
+ Project-URL: Documentation, https://github.com/dangminhtai/motionkit2d/blob/main/docs/index.md
7
+ Project-URL: Issues, https://github.com/dangminhtai/motionkit2d/issues
8
+ Project-URL: Verification, https://github.com/dangminhtai/motionkit2d/blob/main/docs/verification.md
9
+ Requires-Python: >=3.10
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: Pillow<14,>=10.4
12
+ Requires-Dist: numpy<3,>=1.26
13
+ Provides-Extra: gpu
14
+ Requires-Dist: moderngl<6,>=5.12; extra == "gpu"
15
+ Provides-Extra: quality
16
+ Requires-Dist: fonttools<5,>=4; extra == "quality"
17
+
18
+ # MotionKit2D
19
+
20
+ Python tools for procedural 2D animation: characters, scene graphs, cameras,
21
+ anchored props, animated text, audio mixing and H.264 video export.
22
+
23
+ [Repository](https://github.com/dangminhtai/motionkit2d) |
24
+ [Documentation](https://github.com/dangminhtai/motionkit2d/blob/main/docs/index.md) |
25
+ [Verification evidence](https://github.com/dangminhtai/motionkit2d/blob/main/docs/verification.md) |
26
+ [Issues](https://github.com/dangminhtai/motionkit2d/issues)
27
+
28
+ ## Install
29
+
30
+ Requires Python 3.10+. Install FFmpeg and ffprobe separately and add them to PATH
31
+ for video export, audio processing and media verification.
32
+
33
+ ```shell
34
+ python -m pip install motionkit2d
35
+ # Optional OpenGL support and font glyph checks:
36
+ python -m pip install "motionkit2d[gpu,quality]"
37
+ ```
38
+
39
+ ## Run an animation
40
+
41
+ Save as `demo.py`:
42
+
43
+ ```python
44
+ from motionkit2d import Character, Scene, SceneGraph, Node, Transform, Video
45
+
46
+ actor = Character(transform=Transform(160, 160, .6))
47
+ actor.perform(body="walk", arms="wave", face="happy")
48
+ graph = SceneGraph([Node("actor", actor)])
49
+ VIDEO = Video([Scene("Hello", 2, graph)], width=320, height=180, fps=24)
50
+ ```
51
+
52
+ ```shell
53
+ python -m motionkit2d demo.py --frame 12 --output preview.png
54
+ python -m motionkit2d demo.py --backend cpu --encoder cpu --output demo.mp4
55
+ python -m motionkit2d demo.py --verify --output demo.mp4
56
+ ```
57
+
58
+ ## Current API
59
+
60
+ | Area | Entry points |
61
+ |---|---|
62
+ | Characters | CharacterBuilder, Face, Action, Character.perform |
63
+ | Scenes and cameras | Node, SceneGraph, Camera2D; separate world/HUD roots |
64
+ | Props | Asset, Registry, Prop, Attachment and named anchors |
65
+ | Spatial layout | Rect, SafeZone, fit, arrange, find_path, MotionPath |
66
+ | Animation | Track, Emitter, morph_polygon, Ballistic, spring |
67
+ | Typography | AnimatedText, NFC/wrapping/shrinking, stroke, subtitle timing |
68
+ | Audio | AudioCue, mix_audio, BeatTrack, loudness, normalize_audio |
69
+ | Data | JSON manifests, includes, preset files, preflight |
70
+ | Quality checks | Full decode, bounds, reading time, clipping, pixel heuristics |
71
+
72
+ ## Limits
73
+
74
+ - Characters and social/object actions are procedural gestures. The caller must
75
+ stage contact, partner placement and object transfers; there is no acting planner.
76
+ - Polygon morph requires corresponding vertices. Physics includes ballistics,
77
+ ground bounce and springs, not a general rigid-body solver.
78
+ - Attachment freezes its transform on release. Falling motion requires a separate
79
+ trajectory or physics model.
80
+ - Native GPU drawing requires gpu_paint. Scene graphs and Pillow callbacks raster
81
+ on CPU; GPU upload/downsample does not convert Pillow code into shaders.
82
+ - SpeechSynthesizer accepts a caller-configured provider. No voice model or forced
83
+ alignment is bundled. Beat/BPM detection is an onset heuristic.
84
+ - QC may flag intentional cuts/black frames. PASS covers implemented technical
85
+ checks and does not certify artistic quality or flash safety.
86
+
87
+ ## Documentation and verification
88
+
89
+ The [API guide](https://github.com/dangminhtai/motionkit2d/blob/main/docs/guide.md)
90
+ describes the current API. Versioned historical reports are separate from it.
91
+ [Verification records](https://github.com/dangminhtai/motionkit2d/tree/main/verification/v1.0.0)
92
+ contain the original local 1.0.0 test logs, media checks and file hashes, with scope
93
+ and limitations. These are local test evidence, not CI attestations.
94
+
95
+ The source distribution includes docs/, verification/, examples/ and tests/.
96
+ The installed wheel contains the runtime library and bundled fonts.
97
+ Version 1.0.1 changes documentation, packaging and metadata, not animation behavior.
98
+ See [publishing/provenance](https://github.com/dangminhtai/motionkit2d/blob/main/docs/publishing.md)
99
+ for the distinction between file hashes and publisher identity attestations.
100
+
101
+ ## Develop from source
102
+
103
+ ```shell
104
+ python -m pip install -e ".[gpu,quality]"
105
+ python -m unittest discover -s tests -v
106
+ python -m motionkit2d examples/episode.json --validate
107
+ python -m motionkit2d examples/roadmap.py --quality
108
+ ```
109
+
110
+ The examples/ and tests/ commands require the repository or source distribution.
111
+ --quality exits with 0 for PASS, 1 for FAIL, and 2 for INCOMPLETE.
@@ -0,0 +1,94 @@
1
+ # MotionKit2D
2
+
3
+ Python tools for procedural 2D animation: characters, scene graphs, cameras,
4
+ anchored props, animated text, audio mixing and H.264 video export.
5
+
6
+ [Repository](https://github.com/dangminhtai/motionkit2d) |
7
+ [Documentation](https://github.com/dangminhtai/motionkit2d/blob/main/docs/index.md) |
8
+ [Verification evidence](https://github.com/dangminhtai/motionkit2d/blob/main/docs/verification.md) |
9
+ [Issues](https://github.com/dangminhtai/motionkit2d/issues)
10
+
11
+ ## Install
12
+
13
+ Requires Python 3.10+. Install FFmpeg and ffprobe separately and add them to PATH
14
+ for video export, audio processing and media verification.
15
+
16
+ ```shell
17
+ python -m pip install motionkit2d
18
+ # Optional OpenGL support and font glyph checks:
19
+ python -m pip install "motionkit2d[gpu,quality]"
20
+ ```
21
+
22
+ ## Run an animation
23
+
24
+ Save as `demo.py`:
25
+
26
+ ```python
27
+ from motionkit2d import Character, Scene, SceneGraph, Node, Transform, Video
28
+
29
+ actor = Character(transform=Transform(160, 160, .6))
30
+ actor.perform(body="walk", arms="wave", face="happy")
31
+ graph = SceneGraph([Node("actor", actor)])
32
+ VIDEO = Video([Scene("Hello", 2, graph)], width=320, height=180, fps=24)
33
+ ```
34
+
35
+ ```shell
36
+ python -m motionkit2d demo.py --frame 12 --output preview.png
37
+ python -m motionkit2d demo.py --backend cpu --encoder cpu --output demo.mp4
38
+ python -m motionkit2d demo.py --verify --output demo.mp4
39
+ ```
40
+
41
+ ## Current API
42
+
43
+ | Area | Entry points |
44
+ |---|---|
45
+ | Characters | CharacterBuilder, Face, Action, Character.perform |
46
+ | Scenes and cameras | Node, SceneGraph, Camera2D; separate world/HUD roots |
47
+ | Props | Asset, Registry, Prop, Attachment and named anchors |
48
+ | Spatial layout | Rect, SafeZone, fit, arrange, find_path, MotionPath |
49
+ | Animation | Track, Emitter, morph_polygon, Ballistic, spring |
50
+ | Typography | AnimatedText, NFC/wrapping/shrinking, stroke, subtitle timing |
51
+ | Audio | AudioCue, mix_audio, BeatTrack, loudness, normalize_audio |
52
+ | Data | JSON manifests, includes, preset files, preflight |
53
+ | Quality checks | Full decode, bounds, reading time, clipping, pixel heuristics |
54
+
55
+ ## Limits
56
+
57
+ - Characters and social/object actions are procedural gestures. The caller must
58
+ stage contact, partner placement and object transfers; there is no acting planner.
59
+ - Polygon morph requires corresponding vertices. Physics includes ballistics,
60
+ ground bounce and springs, not a general rigid-body solver.
61
+ - Attachment freezes its transform on release. Falling motion requires a separate
62
+ trajectory or physics model.
63
+ - Native GPU drawing requires gpu_paint. Scene graphs and Pillow callbacks raster
64
+ on CPU; GPU upload/downsample does not convert Pillow code into shaders.
65
+ - SpeechSynthesizer accepts a caller-configured provider. No voice model or forced
66
+ alignment is bundled. Beat/BPM detection is an onset heuristic.
67
+ - QC may flag intentional cuts/black frames. PASS covers implemented technical
68
+ checks and does not certify artistic quality or flash safety.
69
+
70
+ ## Documentation and verification
71
+
72
+ The [API guide](https://github.com/dangminhtai/motionkit2d/blob/main/docs/guide.md)
73
+ describes the current API. Versioned historical reports are separate from it.
74
+ [Verification records](https://github.com/dangminhtai/motionkit2d/tree/main/verification/v1.0.0)
75
+ contain the original local 1.0.0 test logs, media checks and file hashes, with scope
76
+ and limitations. These are local test evidence, not CI attestations.
77
+
78
+ The source distribution includes docs/, verification/, examples/ and tests/.
79
+ The installed wheel contains the runtime library and bundled fonts.
80
+ Version 1.0.1 changes documentation, packaging and metadata, not animation behavior.
81
+ See [publishing/provenance](https://github.com/dangminhtai/motionkit2d/blob/main/docs/publishing.md)
82
+ for the distinction between file hashes and publisher identity attestations.
83
+
84
+ ## Develop from source
85
+
86
+ ```shell
87
+ python -m pip install -e ".[gpu,quality]"
88
+ python -m unittest discover -s tests -v
89
+ python -m motionkit2d examples/episode.json --validate
90
+ python -m motionkit2d examples/roadmap.py --quality
91
+ ```
92
+
93
+ The examples/ and tests/ commands require the repository or source distribution.
94
+ --quality exits with 0 for PASS, 1 for FAIL, and 2 for INCOMPLETE.
@@ -0,0 +1,35 @@
1
+ {
2
+ "version": "1.0.0",
3
+ "python": "3.12.4",
4
+ "platform": "Windows-11-10.0.26100-SP0",
5
+ "dimensions": [
6
+ 320,
7
+ 180
8
+ ],
9
+ "frames": 12,
10
+ "repeats": 3,
11
+ "cpu": {
12
+ "seconds_runs": [
13
+ 0.0680056000019249,
14
+ 0.0623477000008279,
15
+ 0.06470229999831645
16
+ ],
17
+ "median_fps": 185.46481346586194,
18
+ "sha256": "c292dd3840cafec365216e04a154534e10ec9eacd9705b4fe54047ed59df67b7"
19
+ },
20
+ "gpu_info": {
21
+ "available": true,
22
+ "vendor": "Intel",
23
+ "renderer": "Intel(R) Iris(R) Xe Graphics",
24
+ "version": "3.3.0 - Build 31.0.101.5081"
25
+ },
26
+ "gpu_upload": {
27
+ "seconds_runs": [
28
+ 0.04727699999784818,
29
+ 0.047700900002382696,
30
+ 0.053895400000328664
31
+ ],
32
+ "median_fps": 251.5675804733368,
33
+ "sha256": "5b149257cda9efe33861922e943b3c0f45233766c8871a682b2977dd65d8c30c"
34
+ }
35
+ }
@@ -0,0 +1,101 @@
1
+ # MotionKit2D 1.x API guide
2
+
3
+ ## Public API contract
4
+
5
+ - Import từ `motionkit2d` hoặc module cụ thể. Giữ các đường import cũ của v0.3/v0.4.
6
+ - Design pixels, gốc trái trên, giây, rotation CCW, scale >0. Raster API dùng `draw.S=2`.
7
+ - Tất cả motion/particle/physics sampling là hàm của t; đọc frame ngược/ngẫu nhiên
8
+ không được làm đổi kết quả. Physics bounce replay bước cố định từ trạng thái đầu.
9
+ - Scene callbacks vẫn là escape hatch. SceneGraph là optional, không yêu cầu chuyển
10
+ project cũ. Painter/text local raster bị cắt tại viewport trước transform;
11
+ Character/Prop/Attachment được vẽ trực tiếp bằng transform cuối.
12
+ - Manifest runtime giữ schema_version **1** (integer); engine v1 không đổi schema lên 1.0.
13
+ API JSON version độc lập package version. Unknown field/cycle/NaN bị reject.
14
+ - Trong series 1.x giữ tên và positional arguments hiện hữu. Thay đổi breaking cần
15
+ major version; extension thêm optional keyword/registry. Module nội bộ `_...` không
16
+ có cam kết API. Tên asset mặc định và anchor cũ được giữ.
17
+ - Lỗi cấu hình báo ValueError/ManifestError; tên registry không có báo KeyError.
18
+ Lỗi external tool có thể là OSError/subprocess.CalledProcessError. Không nuốt lỗi
19
+ rồi báo đã render hoặc ghi đè file đích khi tác vụ thất bại.
20
+
21
+ ## Cài/chạy
22
+
23
+ ```powershell
24
+ python -m pip install -e ".[gpu,quality]"
25
+ python -m motionkit2d examples/episode.json --validate
26
+ python -m motionkit2d examples/roadmap.py --backend cpu --encoder cpu --workers 2
27
+ python -m motionkit2d examples/roadmap.py --quality --qc-video output/roadmap.mp4 --output output/qc.json
28
+ python -m unittest discover -s tests -v
29
+ python -m build --wheel --no-isolation
30
+ python tools/package_release.py
31
+ ```
32
+
33
+ `--quality`: exit 0 PASS, 1 FAIL, 2 INCOMPLETE. Findings và coverage là dữ liệu nghiệm
34
+ thu kỹ thuật; cảnh đen/cut có chủ ý vẫn có thể bị heuristic báo lỗi. Chưa có bounds
35
+ hoặc graph không thể kiểm thì không đánh PASS cho kiểm đó. QC không thay creative review.
36
+
37
+ ## Spatial / choreography
38
+
39
+ ```python
40
+ from motionkit2d import Rect, MotionPath, find_path, Character
41
+ region = Rect(0, 0, 400, 300)
42
+ points = find_path((0, 0), (400, 300), region, [Rect(190, 0, 20, 200)], cell=10)
43
+ path = MotionPath(points, speed=80)
44
+ actor = Character().move_to(path).perform(body='walk')
45
+ ```
46
+
47
+ Navigation là A* bốn hướng, endpoint trên grid, obstacle đóng và có clearance.
48
+ Không tự gọi pathfinding khi move_to; caller quyết định vùng và footprint.
49
+ `align`/`contain` trả Transform, không âm thầm sửa node; `collisions(graph,t)` trả
50
+ cặp AABB giao nhau, kể cả quan hệ group/child; caller lọc collision layer theo nhu cầu.
51
+
52
+ ## Animation / particles / physics
53
+
54
+ ```python
55
+ from motionkit2d import Ballistic, Emitter, spring, morph_polygon
56
+ point = Ballistic((100, 20), (60, -30), (0, 180))(.5)
57
+ ground_point = Ballistic((0, 0), (30, 0)).bounce(1, floor_y=180, restitution=.6)
58
+ value = spring(.4, initial=0, target=1, damping=.5)
59
+ polygon = morph_polygon(((0,0),(40,0),(20,40)), ((0,0),(80,0),(40,80)), .5)
60
+ hearts = Emitter(position=lambda t: (100+20*t, 80), rate=20, lifetime=1,
61
+ burst=5, shape='heart', seed=8, stop=2)
62
+ ```
63
+
64
+ Morph nội suy **tọa độ vertex**, không gọi crossfade là morph. Hai polygon cần
65
+ số vertex tương ứng; caller chịu trách nhiệm winding/correspondence. Emitter đặt
66
+ position tại thời điểm sinh nên có thể tạo trail. Burst và floating hearts dùng
67
+ cùng cơ chế seed. Ground collision là mô hình đơn giản, không phải rigid-body world.
68
+
69
+ Hiệu ứng wave/glow/reveal/color_grade được đăng ký chung `effects_registry`;
70
+ parameters nhận từ JSON như các effect v0.4. Lighting ở mức raster effect và metadata.
71
+
72
+ ## Audio / TTS
73
+
74
+ ```python
75
+ from motionkit2d import AudioCue, mix_audio, loudness, normalize_audio, BeatTrack
76
+ mix_audio([AudioCue('voice.wav', kind='voice'),
77
+ AudioCue('bgm.wav', kind='bgm', volume=.3, loop=True, ducking=.2)],
78
+ 'mix.wav', seconds=10)
79
+ normalize_audio('mix.wav', 'master.wav', target_lufs=-16, true_peak=-1)
80
+ measurements = loudness('master.wav')
81
+ ```
82
+
83
+ Loudness dùng FFmpeg loudnorm hai lượt, không tự gán RMS thành LUFS. Silence trả
84
+ measurement None và normalize báo lỗi. TTS: `SpeechSynthesizer(provider)` gọi
85
+ `provider(text, temporary_wav_path, **options)`. Provider phải ghi PCM WAV hợp lệ;
86
+ engine kiểm trước khi publish atomic. Core không tự chọn giọng, gọi mạng hay lấy key.
87
+ BeatTrack dùng time của BeatMap làm keyframe. Onset/BPM estimator vẫn là heuristic;
88
+ chưa có speech recognition/forced alignment. Karaoke mặc định chia thời gian hold.
89
+
90
+ ## Manifest và preset
91
+
92
+ `includes: ["scene_a.json", ...]` ghép scenes/audio theo thứ tự, resolve audio path
93
+ theo từng file. `preset_files` chứa node-config maps. Preset trùng bị reject;
94
+ video settings của file ngoài cùng override settings của include. Mỗi include phải
95
+ khai báo schema_version 1, cycle và depth >32 bị reject. Dữ liệu không import code.
96
+ `preflight` kiểm node/camera/property mỗi frame và audio source; không thay render test.
97
+
98
+ PresetLibrary vẫn đọc được catalog project với explicit adapters. 41 preset NEON
99
+ là dữ liệu thiết kế riêng; schema của chúng không chứa đủ transform/choreography
100
+ để engine tự dựng mọi tập. Không nhúng concept kênh vào engine, không công bố 41/41
101
+ đã render. Đó là integration ở tầng project, không phải public engine API.
@@ -0,0 +1,12 @@
1
+ # MotionKit2D documentation
2
+
3
+ Tài liệu hiện tại áp dụng cho API 1.x. Bản 1.0.1 sửa cách phân phối tài liệu và
4
+ metadata, không thay đổi hành vi runtime của 1.0.0.
5
+
6
+ - [Cài đặt và ví dụ](../README.md)
7
+ - [API contract và hướng dẫn](guide.md)
8
+ - [Phạm vi kiểm thử và bằng chứng](verification.md)
9
+ - [Publish và provenance](publishing.md)
10
+
11
+ Các báo cáo acceptance_v04.md/UPGRADE.md ở root là tài liệu lịch sử v0.4, không
12
+ được dùng làm danh sách giới hạn hiện tại.
@@ -0,0 +1,26 @@
1
+ # Publishing và provenance
2
+
3
+ 1.0.0 được upload bằng API token từ máy phát triển. Bản đó không có PyPI publish
4
+ attestation; không gọi SHA-256, test log hay file manifest tự viết là provenance.
5
+
6
+ PyPI tiếp nhận attestation cùng lúc upload file. Luồng cho các bản tiếp:
7
+
8
+ 1. Source nằm trong repository public đã xác minh.
9
+ 2. Build và kiểm wheel/source distribution trên GitHub Actions.
10
+ 3. Cấu hình Trusted Publisher trong trang quản lý PyPI: GitHub owner, repository,
11
+ workflow filename `publish.yml`, environment `pypi` phải khớp workflow.
12
+ 4. Publish bằng `pypa/gh-action-pypi-publish` với OIDC và attestations bật.
13
+ 5. Sau upload, kiểm trang release và PyPI Integrity API có provenance thật.
14
+
15
+ Repository: https://github.com/dangminhtai/motionkit2d
16
+
17
+ Workflow: `.github/workflows/publish.yml`. Tag v1.0.1 phải khớp package version
18
+ 1.0.1; job build kiểm sdist/wheel, chạy tests bằng wheel đã cài, lưu log/report
19
+ trong artifact `verification`. Chỉ job publish có quyền `id-token: write`; không
20
+ truyền PIPI_APIKEY vào CI. GitHub environment là `pypi`.
21
+
22
+ Một workflow chưa chạy không chứng minh release có provenance. API token PyPI
23
+ không thay thế quyền quản trị GitHub hoặc đăng nhập quản lý PyPI để tạo Trusted Publisher.
24
+
25
+ Nguồn: [PyPI producing attestations](https://docs.pypi.org/attestations/producing-attestations/),
26
+ [Trusted Publisher setup](https://docs.pypi.org/trusted-publishers/adding-a-publisher/).
@@ -0,0 +1,31 @@
1
+ # Kiểm chứng bản 1.0.0
2
+
3
+ ## Bản vá tài liệu 1.0.1
4
+
5
+ [Log wheel 1.0.1](../verification/v1.0.1/tests-installed.txt): 62 test PASS trên
6
+ Windows/Python 3.12.4, gồm GPU Intel Iris Xe. [Manifest](../verification/v1.0.1/manifest.json)
7
+ ghi phạm vi: so hai wheel cho thấy chỉ hằng __version__ thay đổi, 35 module Python
8
+ còn lại giống byte. Ví dụ README được chạy qua CLI để xuất frame 12.
9
+ Kiểm YAML workflow ở local không được tính là đã chạy CI hoặc có provenance.
10
+
11
+ ## Báo cáo lịch sử 1.0.0
12
+
13
+ Các file trong [verification/v1.0.0](../verification/v1.0.0/) được sao chép từ lần
14
+ nghiệm thu tại máy phát triển; không phải kết quả GitHub CI hay provenance.
15
+
16
+ | Bằng chứng | Phạm vi |
17
+ |---|---|
18
+ | [tests-source.txt](../verification/v1.0.0/tests-source.txt) | 62 unittest, source tree |
19
+ | [tests-installed.txt](../verification/v1.0.0/tests-installed.txt) | 62 unittest, wheel đã cài |
20
+ | [acceptance.json](../verification/v1.0.0/acceptance.json) | Demo preflight; H.264/yuv420p 320×180, 24 frame; full decode/QC |
21
+ | [benchmark.json](../verification/v1.0.0/benchmark.json) | 12 frame 320×180, ba lượt sau warm-up; không gồm encode |
22
+ | [manifest.json](../verification/v1.0.0/manifest.json) | Commit, hash wheel và hash các file bằng chứng |
23
+
24
+ Log cài wheel gồm kiểm GPU trên Intel Iris Xe. Đây là một cấu hình Windows/Python
25
+ 3.12.4, không phải bằng chứng chạy trên mọi hệ điều hành hoặc GPU.
26
+
27
+ Đường dẫn máy cá nhân trong báo cáo JSON được thay bằng tên logic. Các metric,
28
+ findings và test status được giữ nguyên. Sanitization được ghi trong manifest.
29
+
30
+ Chưa kiểm bằng GUI player, chưa nghe giọng TTS từ provider thực, chưa render toàn
31
+ bộ preset project NEON. Hash file chứng minh tính toàn vẹn, không chứng minh danh tính người build.
@@ -0,0 +1,108 @@
1
+ """Shared choreography for landscape and portrait acceptance films."""
2
+ from motionkit2d import (
3
+ Appearance, Attachment, AudioCue, Character, Cues, Layout, Prop, Scene,
4
+ Transform, Video, catalog, draw, frame_strip, pose_transition, reach, sit,
5
+ stand, text_block, tween, walk,
6
+ )
7
+
8
+
9
+ CAPTION='Bước vào lớp, đặt balô xuống ghế.\nSẵn sàng cho một ngày học mới.'
10
+
11
+
12
+ def make_classroom(width=960,height=540,*,appearance=None,cues=None,audio_path=None):
13
+ appearance=appearance or Appearance()
14
+ cues=cues or Cues(arrive=2.4,release=3.5,leave=4.4,sit=6.5,end=8.2)
15
+ if not 0<cues['arrive']<cues.at('release',-.4)<cues['release']<cues['leave']<cues.at('sit',-.7)<cues['sit']<cues['end']:
16
+ raise ValueError('Classroom cues must leave time for each action')
17
+ layout=Layout(width,height)
18
+ portrait=height>width
19
+ unit=min(width/620,height/430)
20
+ floor=height*(.78 if portrait else .84)
21
+ chair_x=width*(.48 if portrait else .51)
22
+ chair2_x=chair_x+unit*112
23
+ chair1=Prop(catalog.get('school.chair'),transform=Transform(chair_x-42*unit,floor-146*unit,unit))
24
+ chair2=Prop(catalog.get('school.chair'),transform=Transform(chair2_x-42*unit,floor-146*unit,unit))
25
+ seat=chair1.anchor('seat',0)
26
+ stop=chair_x-50*unit
27
+ final=chair2_x-12*unit
28
+ start=layout.safe.x+28*unit
29
+ bag_scale=.65
30
+ # Target handle height places the bag bottom exactly on the seat surface.
31
+ put=(50,(seat[1]-floor)/unit-67*bag_scale)
32
+ grip=(40,-148*appearance.torso)
33
+ standing=stand(appearance)
34
+ holding=reach(standing,grip)
35
+ placing=reach(standing,put)
36
+ seated=sit(appearance)
37
+
38
+ def pose(t):
39
+ if t<cues['arrive']:
40
+ stepping=reach(walk(t,appearance),grip)
41
+ return pose_transition(t,cues.at('arrive',-.4),cues['arrive'],stepping,holding)
42
+ if t<=cues['release']:
43
+ return pose_transition(t,cues.at('arrive',.35),cues['release'],holding,placing)
44
+ if t<cues['leave']:
45
+ return pose_transition(t,cues['release'],cues.at('release',.6),placing,standing)
46
+ if t<cues.at('sit',-.7):
47
+ moving=walk(t-cues['leave'],appearance)
48
+ blend=tween(t,cues['leave'],cues.at('leave',.3))*(1-tween(t,cues.at('sit',-1),cues.at('sit',-.7)))
49
+ return standing.blend(moving,blend)
50
+ return pose_transition(t,cues.at('sit',-.7),cues['sit'],standing,seated)
51
+
52
+ def position(t):
53
+ x=tween(t,0,cues['arrive'],start,stop,ease='linear')
54
+ if t>=cues['leave']:
55
+ x=tween(t,cues['leave'],cues.at('sit',-.7),stop,final,ease='linear')
56
+ return Transform(x,floor,unit)
57
+
58
+ actor=Character(appearance,pose=pose,transform=position)
59
+ bag=Attachment(Prop(catalog.get('school.backpack'),transform=Transform(scale=bag_scale)),
60
+ 'handle',actor,'hand_right',release=cues['release'])
61
+ # Backpack after release is behind the student as they cross to the next chair.
62
+ board_width=width*(.72 if portrait else .32)
63
+ board_x=width*.5-board_width/2 if portrait else layout.safe.x+8
64
+ board=Prop(catalog.get('school.board'),transform=Transform(board_x,
65
+ height*(.29 if portrait else .34),board_width/360))
66
+ title=text_block('VÀO LỚP',layout.safe.width,height*.10,size=round(min(width*.07,44)))
67
+ caption_width=layout.safe.width if portrait else width*.56
68
+ caption=text_block(CAPTION,caption_width,height*.14,size=round(min(width*.04,24)),min_size=12)
69
+ caption_x=layout.safe.x if portrait else width*.38
70
+ caption_y=height*.075+title.height+layout.safe.y if portrait else layout.safe.y+5
71
+
72
+ def paint(im,f):
73
+ d=draw.draw(im)
74
+ im.paste('#EFE9DC',(0,0,*im.size))
75
+ draw.rect(d,0,floor+2,width,height-floor,0,'#D4C5AC')
76
+ draw.line(d,[(0,floor+2),(width,floor+2)],'#A69982',2)
77
+ board.draw(im,f.t)
78
+ chair1.draw(im,f.t)
79
+ chair2.draw(im,f.t)
80
+ bag.draw(im,f.t)
81
+ actor.draw(im,f.t)
82
+ # Handle is above the bag; redraw the small hand to show the grip.
83
+ if f.t<cues['release']:
84
+ hand=actor.anchor('hand_right',f.t)
85
+ draw.oval(d,*hand,4*unit,4*unit,appearance.skin)
86
+ title.draw(im,layout.safe.x,layout.safe.y,color='#254A47')
87
+ caption.draw(im,caption_x,caption_y,color='#5A655D')
88
+ phase=('Đang bước vào' if f.t<cues['arrive'] else
89
+ 'Đặt balô' if f.t<cues['release'] else
90
+ 'Buông tay' if f.t<cues['leave'] else
91
+ 'Đến ghế bên cạnh' if f.t<cues['sit'] else 'Sẵn sàng học')
92
+ draw.text(im,width/2,height*.92,phase,round(min(width*.034,21)),style='sans',c='#42564F')
93
+
94
+ audio=(AudioCue(audio_path,cues['release'],.55),) if audio_path else ()
95
+ video=Video([Scene('Vào lớp · đặt balô · ngồi xuống',cues['end'],paint,still=cues['release'])],
96
+ width=width,height=height,fps=24,audio=audio)
97
+ # Expose scene objects to inspection/tests without mutating animation state.
98
+ video.classroom=dict(actor=actor,bag=bag,chairs=(chair1,chair2),cues=cues,
99
+ layout=layout,title=title,caption=caption,unit=unit,
100
+ caption_origin=(caption_x,caption_y),board=board)
101
+ return video
102
+
103
+
104
+ def write_inspection(video,prefix):
105
+ release=round(video.classroom['cues']['release']*video.fps)
106
+ frame_strip(video,range(release-5,release+7),str(prefix)+'_release_strip.png',columns=4,tile_width=320)
107
+ frame_strip(video,[0,24,57,release-1,release,release+12,120,144,174,195],
108
+ str(prefix)+'_storyboard.png',columns=5,tile_width=280)
@@ -0,0 +1,16 @@
1
+ """Python equivalent: walking, holding a phone, expression and moving camera."""
2
+ from motionkit2d import (Appearance, CharacterBuilder, Face, Transform, Prop, Attachment,
3
+ SceneGraph, Node, Camera2D, Bedroom, AnimatedText, Video, Scene, catalog, expression_transition)
4
+
5
+ actor=CharacterBuilder(hairstyle='ponytail',outfit='jacket',accessories=('watch',),view='front').build(
6
+ transform=lambda t:Transform(210+25*t,300,.85))
7
+ actor.perform(body='walk',arms='texting',head='nod',
8
+ face=expression_transition(Face('anxious'),Face('happy'),1,start=1))
9
+ phone=Attachment(Prop(catalog.get('electronics.phone'),transform=Transform(scale=.17)),
10
+ 'grip',actor,'hand_right')
11
+ room=Bedroom(width=640,height=360,time_of_day='night',theme='neon')
12
+ graph=SceneGraph([*room.nodes(),Node('actor',actor,z_index=20),Node('phone',phone,z_index=21),
13
+ Node('title',AnimatedText('Một khoảnh khắc',x=35,y=22,width=570,height=60,
14
+ preset='word',enter=.6,hold=2.1,exit=.3,size=28),screen_space=True)],
15
+ camera=lambda t:Camera2D(320+t*6,180,1+t*.02))
16
+ VIDEO=Video([Scene('Diễn xuất và attachment',3,graph)],width=640,height=360,fps=24)
@@ -0,0 +1,39 @@
1
+ {
2
+ "schema_version": 1,
3
+ "video": {"width": 640, "height": 360, "fps": 24},
4
+ "presets": {
5
+ "student": {
6
+ "type": "character",
7
+ "appearance": {"hairstyle": "curly", "outfit": "hoodie", "accessories": ["glasses"], "view": "front"},
8
+ "face": {"expression": "anxious", "gaze": [0.4, 0.2]},
9
+ "perform": {"body": "breathe", "arms": "texting", "head": "nod"}
10
+ }
11
+ },
12
+ "scenes": [
13
+ {
14
+ "name": "Một tin nhắn mới",
15
+ "seconds": 3,
16
+ "environment": {"kind": "study", "theme": "warm", "time_of_day": "night"},
17
+ "camera": {"x": {"keys": [{"time": 0, "value": 320}, {"time": 3, "value": 332}]}, "y": 180, "scale": 1.08},
18
+ "nodes": [
19
+ {"id": "student", "preset_ref": "student", "transform": {"x": 260, "y": 302, "scale": 0.85}, "z_index": 20},
20
+ {"id": "phone", "type": "prop", "asset": "electronics.phone", "transform": {"scale": 0.18},
21
+ "attach": {"target": "student", "anchor": "hand_right", "child_anchor": "grip"}, "z_index": 21},
22
+ {"id": "caption", "type": "text", "screen_space": true,
23
+ "text": {"content": "Một tin nhắn mới", "preset": "typewriter", "x": 40, "y": 24, "width": 560, "height": 60, "size": 28, "enter": 0.7, "hold": 2, "exit": 0.3}}
24
+ ]
25
+ },
26
+ {
27
+ "name": "Chào ngày mới",
28
+ "seconds": 3,
29
+ "transition": {"kind": "iris", "seconds": 0.5, "mode": "overlap"},
30
+ "environment": {"kind": "park", "time_of_day": "day"},
31
+ "nodes": [
32
+ {"id": "student", "preset_ref": "student", "face": {"expression": "happy"}, "perform": {"body": "walk", "arms": "wave"},
33
+ "transform": {"x": {"keys": [{"time": 0, "value": 200}, {"time": 3, "value": 380}]}, "y": 302, "scale": 0.85}, "z_index": 20},
34
+ {"id": "caption", "type": "text", "screen_space": true,
35
+ "text": {"content": "Chào ngày mới", "preset": "kinetic_slam", "color": "#233B50", "x": 40, "y": 24, "width": 560, "height": 60, "size": 28, "enter": 0.3, "hold": 2.4, "exit": 0.3}}
36
+ ]
37
+ }
38
+ ]
39
+ }
@@ -0,0 +1,38 @@
1
+ """Same procedural scene on Pillow and GPUCanvas; no external image assets."""
2
+ import math
3
+ from motionkit2d import Scene, Video, draw, effects, tween
4
+
5
+ W,H=1080,1920
6
+
7
+
8
+ def paint(im,f):
9
+ t=f.time
10
+ draw.gradient(im,'#080C16','#22344D',focus=(.65,.3))
11
+ d=draw.draw(im)
12
+ # Large translucent shapes exercise actual blending, not only video encoding.
13
+ for i in range(18):
14
+ x=540+430*math.sin(i*2.3+t*.35)
15
+ y=890+730*math.cos(i*1.7+t*.27)
16
+ r=130+(i%4)*65
17
+ draw.oval(d,x,y,r,r,draw.rgba('#EC536B' if i%2 else '#6AB7D1',.035))
18
+ for i in range(14):
19
+ y=400+i*84
20
+ wave=draw.cubic((-50,y),(260,y-120*math.sin(t+i)),
21
+ (790,y+120*math.cos(t+i)),(1130,y),45)
22
+ draw.line(d,wave,draw.rgba('#AFBDD0',.1),1.5)
23
+ draw.text(im,540,222,'MOTIONKIT 2D',66,style='bold')
24
+ draw.text(im,540,310,'GPU rendering · v0.3',32)
25
+ for i,(title,caption) in enumerate((('01 GPU CANVAS','Hình học và ghép lớp trên GPU'),
26
+ ('02 GPU LANCZOS','Khử răng cưa ở độ phân giải 2×'),
27
+ ('03 HARDWARE ENCODE','Tự chọn NVENC / QSV / CPU'))):
28
+ y=670+i*280
29
+ p=tween(t,.08+i*.18,.34+i*.18)
30
+ xx=90-35*(1-p)
31
+ draw.rect(d,xx,y,900,210,22,draw.rgba('#101928',.86),draw.rgba('#C6D2DE',.6),1.5)
32
+ draw.text(im,xx+42,y+73,title,39,style='bold',align='left',amount=p)
33
+ draw.text(im,xx+42,y+139,caption,30,align='left',amount=p)
34
+ draw.text(im,540,1680,'Một source · hai backend',31)
35
+ effects.wash(im,'#080C16',1-tween(t,0,.15))
36
+
37
+
38
+ VIDEO=Video([Scene('GPU showcase',2,paint,gpu_paint=paint)],width=W,height=H,fps=30)