pypixel-core 0.4.0__py3-none-any.whl

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 (230) hide show
  1. PyPixelCore/LICENSE +194 -0
  2. PyPixelCore/__init__.py +162 -0
  3. PyPixelCore/animation/__init__.py +42 -0
  4. PyPixelCore/animation/effects.py +294 -0
  5. PyPixelCore/animation/image.py +276 -0
  6. PyPixelCore/animation/interpolation.py +102 -0
  7. PyPixelCore/animation/move.py +71 -0
  8. PyPixelCore/animation/text.py +165 -0
  9. PyPixelCore/animation/work_piece.py +76 -0
  10. PyPixelCore/assets/__init__.py +39 -0
  11. PyPixelCore/assets/async_tasks.py +160 -0
  12. PyPixelCore/assets/manager.py +513 -0
  13. PyPixelCore/assets/paths.py +10 -0
  14. PyPixelCore/assets/scope.py +85 -0
  15. PyPixelCore/config/__init__.py +17 -0
  16. PyPixelCore/config/declarations.py +24 -0
  17. PyPixelCore/config/runtime.py +204 -0
  18. PyPixelCore/config/schema.py +206 -0
  19. PyPixelCore/config/services.py +50 -0
  20. PyPixelCore/config/session.py +229 -0
  21. PyPixelCore/config/store.py +133 -0
  22. PyPixelCore/config/toml.py +273 -0
  23. PyPixelCore/config/transaction.py +60 -0
  24. PyPixelCore/diagnostics/__init__.py +48 -0
  25. PyPixelCore/diagnostics/registry.py +419 -0
  26. PyPixelCore/diagnostics/ui.py +1004 -0
  27. PyPixelCore/diagnostics/window.py +307 -0
  28. PyPixelCore/game/__init__.py +29 -0
  29. PyPixelCore/game/game_panel.py +533 -0
  30. PyPixelCore/game/game_state.py +48 -0
  31. PyPixelCore/platform/__init__.py +1 -0
  32. PyPixelCore/platform/clipboard.py +100 -0
  33. PyPixelCore/platform/display.py +15 -0
  34. PyPixelCore/platform/files.py +288 -0
  35. PyPixelCore/platform/network/__init__.py +1 -0
  36. PyPixelCore/platform/network/errors.py +4 -0
  37. PyPixelCore/platform/network/message.py +71 -0
  38. PyPixelCore/platform/network/socket_link.py +557 -0
  39. PyPixelCore/qa/__init__.py +111 -0
  40. PyPixelCore/qa/__main__.py +207 -0
  41. PyPixelCore/qa/_perf_protocol.py +41 -0
  42. PyPixelCore/qa/_plan_protocol.py +41 -0
  43. PyPixelCore/qa/_semantic_protocol.py +118 -0
  44. PyPixelCore/qa/_stream_protocol.py +63 -0
  45. PyPixelCore/qa/_support.py +780 -0
  46. PyPixelCore/qa/_window_protocol.py +54 -0
  47. PyPixelCore/qa/_window_service.py +102 -0
  48. PyPixelCore/qa/_workflow_protocol.py +40 -0
  49. PyPixelCore/qa/actions.py +399 -0
  50. PyPixelCore/qa/adapters/__init__.py +76 -0
  51. PyPixelCore/qa/agent.py +1151 -0
  52. PyPixelCore/qa/artifacts.py +240 -0
  53. PyPixelCore/qa/assertions.py +678 -0
  54. PyPixelCore/qa/benchmark.py +85 -0
  55. PyPixelCore/qa/commands.py +966 -0
  56. PyPixelCore/qa/evidence.py +155 -0
  57. PyPixelCore/qa/fixtures.py +503 -0
  58. PyPixelCore/qa/history.py +71 -0
  59. PyPixelCore/qa/html_report.py +61 -0
  60. PyPixelCore/qa/inspection.py +33 -0
  61. PyPixelCore/qa/intents.py +241 -0
  62. PyPixelCore/qa/perf.py +322 -0
  63. PyPixelCore/qa/plan.py +243 -0
  64. PyPixelCore/qa/portable.py +176 -0
  65. PyPixelCore/qa/probe.py +306 -0
  66. PyPixelCore/qa/process.py +25 -0
  67. PyPixelCore/qa/protocol.py +873 -0
  68. PyPixelCore/qa/report.py +163 -0
  69. PyPixelCore/qa/runner.py +290 -0
  70. PyPixelCore/qa/scene.py +825 -0
  71. PyPixelCore/qa/schema.py +123 -0
  72. PyPixelCore/qa/semantics.py +476 -0
  73. PyPixelCore/qa/session.py +407 -0
  74. PyPixelCore/qa/stream.py +138 -0
  75. PyPixelCore/qa/summary.py +193 -0
  76. PyPixelCore/qa/targets.py +115 -0
  77. PyPixelCore/qa/transport.py +311 -0
  78. PyPixelCore/qa/visual.py +181 -0
  79. PyPixelCore/qa/windows.py +203 -0
  80. PyPixelCore/qa/wire.py +79 -0
  81. PyPixelCore/qa/worker.py +165 -0
  82. PyPixelCore/render/__init__.py +66 -0
  83. PyPixelCore/render/atlas.py +27 -0
  84. PyPixelCore/render/camera.py +50 -0
  85. PyPixelCore/render/images.py +39 -0
  86. PyPixelCore/render/nine_patch.py +24 -0
  87. PyPixelCore/render/particles.py +1762 -0
  88. PyPixelCore/render/presentation.py +46 -0
  89. PyPixelCore/render/surface_cache.py +35 -0
  90. PyPixelCore/render/text/__init__.py +39 -0
  91. PyPixelCore/render/text/cache.py +148 -0
  92. PyPixelCore/render/text/fallback.py +100 -0
  93. PyPixelCore/render/text/fonts.py +205 -0
  94. PyPixelCore/render/text/renderer.py +299 -0
  95. PyPixelCore/resources/among.png +0 -0
  96. PyPixelCore/resources/fonts/Cubic-11-OFL.txt +108 -0
  97. PyPixelCore/resources/fonts/Fusion-Pixel-OFL.txt +96 -0
  98. PyPixelCore/resources/fonts/LICENSES/ark-pixel/OFL.txt +96 -0
  99. PyPixelCore/resources/fonts/LICENSES/cubic-11/OFL.txt +108 -0
  100. PyPixelCore/resources/fonts/LICENSES/galmuri/LICENSE.txt +93 -0
  101. PyPixelCore/resources/fonts/README.md +29 -0
  102. PyPixelCore/resources/fonts/Unifont-LICENSE.txt +476 -0
  103. PyPixelCore/resources/fonts/Unifont-OFL.txt +90 -0
  104. PyPixelCore/resources/fonts/Zpix-README.md +111 -0
  105. PyPixelCore/resources/fonts/cubic-11.ttf +0 -0
  106. PyPixelCore/resources/fonts/fusion-pixel-12px-monospaced-zh_hans.ttf +0 -0
  107. PyPixelCore/resources/fonts/unifont.otf +0 -0
  108. PyPixelCore/resources/pypixel_icon.png +0 -0
  109. PyPixelCore/resources/pypixel_icon_128.png +0 -0
  110. PyPixelCore/resources/pypixel_icon_16.png +0 -0
  111. PyPixelCore/resources/pypixel_icon_32.png +0 -0
  112. PyPixelCore/resources/pypixel_icon_64.png +0 -0
  113. PyPixelCore/resources/pypixel_logo.jpg +0 -0
  114. PyPixelCore/resources/skins/README.md +7 -0
  115. PyPixelCore/resources/skins/ember/default-disabled.png +0 -0
  116. PyPixelCore/resources/skins/ember/default-hover.png +0 -0
  117. PyPixelCore/resources/skins/ember/default-normal.png +0 -0
  118. PyPixelCore/resources/skins/ember/default-pressed.png +0 -0
  119. PyPixelCore/resources/skins/ember/primary-disabled.png +0 -0
  120. PyPixelCore/resources/skins/ember/primary-hover.png +0 -0
  121. PyPixelCore/resources/skins/ember/primary-normal.png +0 -0
  122. PyPixelCore/resources/skins/ember/primary-pressed.png +0 -0
  123. PyPixelCore/resources/skins/ember/skin.json +162 -0
  124. PyPixelCore/resources/skins/woodland/default-disabled.png +0 -0
  125. PyPixelCore/resources/skins/woodland/default-hover.png +0 -0
  126. PyPixelCore/resources/skins/woodland/default-normal.png +0 -0
  127. PyPixelCore/resources/skins/woodland/default-pressed.png +0 -0
  128. PyPixelCore/resources/skins/woodland/primary-disabled.png +0 -0
  129. PyPixelCore/resources/skins/woodland/primary-hover.png +0 -0
  130. PyPixelCore/resources/skins/woodland/primary-normal.png +0 -0
  131. PyPixelCore/resources/skins/woodland/primary-pressed.png +0 -0
  132. PyPixelCore/resources/skins/woodland/skin.json +162 -0
  133. PyPixelCore/resources/system_animation_img/before_step.png +0 -0
  134. PyPixelCore/resources/system_animation_img/cunchu.png +0 -0
  135. PyPixelCore/resources/system_animation_img/desktop.png +0 -0
  136. PyPixelCore/resources/system_animation_img/error_icon.png +0 -0
  137. PyPixelCore/resources/system_animation_img/file-open.png +0 -0
  138. PyPixelCore/resources/system_animation_img/file_img.png +0 -0
  139. PyPixelCore/resources/system_animation_img/folder_img.png +0 -0
  140. PyPixelCore/resources/system_animation_img/idea_icon.png +0 -0
  141. PyPixelCore/resources/system_animation_img/inform_icon.png +0 -0
  142. PyPixelCore/resources/system_animation_img/next_step.png +0 -0
  143. PyPixelCore/resources/system_animation_img/pic_img.png +0 -0
  144. PyPixelCore/resources/system_animation_img/quest_icon.png +0 -0
  145. PyPixelCore/resources/system_animation_img/video_img.png +0 -0
  146. PyPixelCore/resources/ui/pixel_controls.json +44 -0
  147. PyPixelCore/resources/warning.png +0 -0
  148. PyPixelCore/runtime/__init__.py +39 -0
  149. PyPixelCore/runtime/child_windows.py +101 -0
  150. PyPixelCore/runtime/controller.py +1536 -0
  151. PyPixelCore/runtime/group.py +73 -0
  152. PyPixelCore/runtime/groups.py +625 -0
  153. PyPixelCore/runtime/navigation.py +138 -0
  154. PyPixelCore/runtime/recorder.py +467 -0
  155. PyPixelCore/runtime/work_queue.py +95 -0
  156. PyPixelCore/settings.py +287 -0
  157. PyPixelCore/timing/__init__.py +51 -0
  158. PyPixelCore/timing/cycle_time_timer.py +44 -0
  159. PyPixelCore/timing/cycle_timer.py +62 -0
  160. PyPixelCore/timing/frequency_time_timer.py +83 -0
  161. PyPixelCore/timing/frequency_timer.py +84 -0
  162. PyPixelCore/timing/only_time_timer.py +75 -0
  163. PyPixelCore/timing/only_timer.py +53 -0
  164. PyPixelCore/timing/time_clock.py +50 -0
  165. PyPixelCore/ui/__init__.py +147 -0
  166. PyPixelCore/ui/configuration.py +167 -0
  167. PyPixelCore/ui/containers/__init__.py +30 -0
  168. PyPixelCore/ui/containers/panel.py +533 -0
  169. PyPixelCore/ui/containers/panel_list.py +835 -0
  170. PyPixelCore/ui/contracts.py +127 -0
  171. PyPixelCore/ui/declarative/__init__.py +11 -0
  172. PyPixelCore/ui/declarative/builder.py +116 -0
  173. PyPixelCore/ui/declarative/schema.py +149 -0
  174. PyPixelCore/ui/dialogs/__init__.py +54 -0
  175. PyPixelCore/ui/dialogs/_chooser_art.py +366 -0
  176. PyPixelCore/ui/dialogs/_process_window.py +438 -0
  177. PyPixelCore/ui/dialogs/dialog.py +618 -0
  178. PyPixelCore/ui/dialogs/file_chooser.py +1209 -0
  179. PyPixelCore/ui/dialogs/qrcode_window.py +251 -0
  180. PyPixelCore/ui/dialogs/style.py +51 -0
  181. PyPixelCore/ui/forms/__init__.py +33 -0
  182. PyPixelCore/ui/forms/_widgets.py +68 -0
  183. PyPixelCore/ui/forms/controls.py +32 -0
  184. PyPixelCore/ui/forms/style.py +34 -0
  185. PyPixelCore/ui/forms/view.py +261 -0
  186. PyPixelCore/ui/layout/__init__.py +36 -0
  187. PyPixelCore/ui/layout/hbox.py +24 -0
  188. PyPixelCore/ui/layout/hint.py +62 -0
  189. PyPixelCore/ui/layout/panel.py +451 -0
  190. PyPixelCore/ui/layout/vbox.py +23 -0
  191. PyPixelCore/ui/primitives/__init__.py +33 -0
  192. PyPixelCore/ui/primitives/base.py +485 -0
  193. PyPixelCore/ui/primitives/block.py +248 -0
  194. PyPixelCore/ui/primitives/button_base.py +334 -0
  195. PyPixelCore/ui/primitives/visibility.py +106 -0
  196. PyPixelCore/ui/skins/__init__.py +15 -0
  197. PyPixelCore/ui/skins/base.py +54 -0
  198. PyPixelCore/ui/skins/default.py +6 -0
  199. PyPixelCore/ui/skins/pack.py +173 -0
  200. PyPixelCore/ui/skins/pixel/__init__.py +3 -0
  201. PyPixelCore/ui/skins/pixel/painters.py +206 -0
  202. PyPixelCore/ui/skins/pixel/skin.py +147 -0
  203. PyPixelCore/ui/theme.py +471 -0
  204. PyPixelCore/ui/widgets/__init__.py +87 -0
  205. PyPixelCore/ui/widgets/bar.py +189 -0
  206. PyPixelCore/ui/widgets/check_box.py +101 -0
  207. PyPixelCore/ui/widgets/context_menu.py +78 -0
  208. PyPixelCore/ui/widgets/dynamic_image_block.py +508 -0
  209. PyPixelCore/ui/widgets/edit_text.py +786 -0
  210. PyPixelCore/ui/widgets/icon_button.py +181 -0
  211. PyPixelCore/ui/widgets/image_button.py +184 -0
  212. PyPixelCore/ui/widgets/log_view.py +80 -0
  213. PyPixelCore/ui/widgets/menu_bar.py +320 -0
  214. PyPixelCore/ui/widgets/multi_line_text_block.py +248 -0
  215. PyPixelCore/ui/widgets/progress_bar.py +104 -0
  216. PyPixelCore/ui/widgets/qr_code_block.py +52 -0
  217. PyPixelCore/ui/widgets/select_button.py +217 -0
  218. PyPixelCore/ui/widgets/simplify_button.py +146 -0
  219. PyPixelCore/ui/widgets/slider.py +177 -0
  220. PyPixelCore/ui/widgets/super_multi_line_text_block.py +351 -0
  221. PyPixelCore/ui/widgets/switch.py +150 -0
  222. PyPixelCore/ui/widgets/text_block.py +224 -0
  223. PyPixelCore/ui/widgets/text_button.py +241 -0
  224. PyPixelCore/ui/widgets/text_view.py +660 -0
  225. PyPixelCore/ui/widgets/tip_box.py +176 -0
  226. PyPixelCore/version.py +3 -0
  227. pypixel_core-0.4.0.dist-info/METADATA +59 -0
  228. pypixel_core-0.4.0.dist-info/RECORD +230 -0
  229. pypixel_core-0.4.0.dist-info/WHEEL +4 -0
  230. pypixel_core-0.4.0.dist-info/licenses/LICENSE +194 -0
PyPixelCore/LICENSE ADDED
@@ -0,0 +1,194 @@
1
+ 木兰宽松许可证,第2版
2
+
3
+ 木兰宽松许可证,第2版
4
+
5
+ 2020年1月 http://license.coscl.org.cn/MulanPSL2
6
+
7
+ 您对“软件”的复制、使用、修改及分发受木兰宽松许可证,第2版(“本许可证”)的如下条款的约束:
8
+
9
+ 0. 定义
10
+
11
+ “软件” 是指由“贡献”构成的许可在“本许可证”下的程序和相关文档的集合。
12
+
13
+ “贡献” 是指由任一“贡献者”许可在“本许可证”下的受版权法保护的作品。
14
+
15
+ “贡献者” 是指将受版权法保护的作品许可在“本许可证”下的自然人或“法人实体”。
16
+
17
+ “法人实体” 是指提交贡献的机构及其“关联实体”。
18
+
19
+ “关联实体” 是指,对“本许可证”下的行为方而言,控制、受控制或与其共同受控制的机构,此处的控制是
20
+ 指有受控方或共同受控方至少50%直接或间接的投票权、资金或其他有价证券。
21
+
22
+ 1. 授予版权许可
23
+
24
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的版权许可,您可
25
+ 以复制、使用、修改、分发其“贡献”,不论修改与否。
26
+
27
+ 2. 授予专利许可
28
+
29
+ 每个“贡献者”根据“本许可证”授予您永久性的、全球性的、免费的、非独占的、不可撤销的(根据本条规定
30
+ 撤销除外)专利许可,供您制造、委托制造、使用、许诺销售、销售、进口其“贡献”或以其他方式转移其“贡
31
+ 献”。前述专利许可仅限于“贡献者”现在或将来拥有或控制的其“贡献”本身或其“贡献”与许可“贡献”时的“软
32
+ 件”结合而将必然会侵犯的专利权利要求,不包括对“贡献”的修改或包含“贡献”的其他结合。如果您或您的“
33
+ 关联实体”直接或间接地,就“软件”或其中的“贡献”对任何人发起专利侵权诉讼(包括反诉或交叉诉讼)或
34
+ 其他专利维权行动,指控其侵犯专利权,则“本许可证”授予您对“软件”的专利许可自您提起诉讼或发起维权
35
+ 行动之日终止。
36
+
37
+ 3. 无商标许可
38
+
39
+ “本许可证”不提供对“贡献者”的商品名称、商标、服务标志或产品名称的商标许可,但您为满足第4条规定
40
+ 的声明义务而必须使用除外。
41
+
42
+ 4. 分发限制
43
+
44
+ 您可以在任何媒介中将“软件”以源程序形式或可执行形式重新分发,不论修改与否,但您必须向接收者提供“
45
+ 本许可证”的副本,并保留“软件”中的版权、商标、专利及免责声明。
46
+
47
+ 5. 免责声明与责任限制
48
+
49
+ “软件”及其中的“贡献”在提供时不带任何明示或默示的担保。在任何情况下,“贡献者”或版权所有者不对
50
+ 任何人因使用“软件”或其中的“贡献”而引发的任何直接或间接损失承担责任,不论因何种原因导致或者基于
51
+ 何种法律理论,即使其曾被建议有此种损失的可能性。
52
+
53
+ 6. 语言
54
+
55
+ “本许可证”以中英文双语表述,中英文版本具有同等法律效力。如果中英文版本存在任何冲突不一致,以中文
56
+ 版为准。
57
+
58
+ 条款结束
59
+
60
+ 如何将木兰宽松许可证,第2版,应用到您的软件
61
+
62
+ 如果您希望将木兰宽松许可证,第2版,应用到您的新软件,为了方便接收者查阅,建议您完成如下三步:
63
+
64
+ 1, 请您补充如下声明中的空白,包括软件名、软件的首次发表年份以及您作为版权人的名字;
65
+
66
+ 2, 请您在软件包的一级目录下创建以“LICENSE”为名的文件,将整个许可证文本放入该文件中;
67
+
68
+ 3, 请将如下声明文本放入每个源文件的头部注释中。
69
+
70
+ Copyright (c) [Year] [name of copyright holder]
71
+ [Software Name] is licensed under Mulan PSL v2.
72
+ You can use this software according to the terms and conditions of the Mulan
73
+ PSL v2.
74
+ You may obtain a copy of Mulan PSL v2 at:
75
+ http://license.coscl.org.cn/MulanPSL2
76
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
77
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
78
+ NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
79
+ See the Mulan PSL v2 for more details.
80
+
81
+ Mulan Permissive Software License,Version 2
82
+
83
+ Mulan Permissive Software License,Version 2 (Mulan PSL v2)
84
+
85
+ January 2020 http://license.coscl.org.cn/MulanPSL2
86
+
87
+ Your reproduction, use, modification and distribution of the Software shall
88
+ be subject to Mulan PSL v2 (this License) with the following terms and
89
+ conditions:
90
+
91
+ 0. Definition
92
+
93
+ Software means the program and related documents which are licensed under
94
+ this License and comprise all Contribution(s).
95
+
96
+ Contribution means the copyrightable work licensed by a particular
97
+ Contributor under this License.
98
+
99
+ Contributor means the Individual or Legal Entity who licenses its
100
+ copyrightable work under this License.
101
+
102
+ Legal Entity means the entity making a Contribution and all its
103
+ Affiliates.
104
+
105
+ Affiliates means entities that control, are controlled by, or are under
106
+ common control with the acting entity under this License, ‘control’ means
107
+ direct or indirect ownership of at least fifty percent (50%) of the voting
108
+ power, capital or other securities of controlled or commonly controlled
109
+ entity.
110
+
111
+ 1. Grant of Copyright License
112
+
113
+ Subject to the terms and conditions of this License, each Contributor hereby
114
+ grants to you a perpetual, worldwide, royalty-free, non-exclusive,
115
+ irrevocable copyright license to reproduce, use, modify, or distribute its
116
+ Contribution, with modification or not.
117
+
118
+ 2. Grant of Patent License
119
+
120
+ Subject to the terms and conditions of this License, each Contributor hereby
121
+ grants to you a perpetual, worldwide, royalty-free, non-exclusive,
122
+ irrevocable (except for revocation under this Section) patent license to
123
+ make, have made, use, offer for sale, sell, import or otherwise transfer its
124
+ Contribution, where such patent license is only limited to the patent claims
125
+ owned or controlled by such Contributor now or in future which will be
126
+ necessarily infringed by its Contribution alone, or by combination of the
127
+ Contribution with the Software to which the Contribution was contributed.
128
+ The patent license shall not apply to any modification of the Contribution,
129
+ and any other combination which includes the Contribution. If you or your
130
+ Affiliates directly or indirectly institute patent litigation (including a
131
+ cross claim or counterclaim in a litigation) or other patent enforcement
132
+ activities against any individual or entity by alleging that the Software or
133
+ any Contribution in it infringes patents, then any patent license granted to
134
+ you under this License for the Software shall terminate as of the date such
135
+ litigation or activity is filed or taken.
136
+
137
+ 3. No Trademark License
138
+
139
+ No trademark license is granted to use the trade names, trademarks, service
140
+ marks, or product names of Contributor, except as required to fulfill notice
141
+ requirements in section 4.
142
+
143
+ 4. Distribution Restriction
144
+
145
+ You may distribute the Software in any medium with or without modification,
146
+ whether in source or executable forms, provided that you provide recipients
147
+ with a copy of this License and retain copyright, patent, trademark and
148
+ disclaimer statements in the Software.
149
+
150
+ 5. Disclaimer of Warranty and Limitation of Liability
151
+
152
+ THE SOFTWARE AND CONTRIBUTION IN IT ARE PROVIDED WITHOUT WARRANTIES OF ANY
153
+ KIND, EITHER EXPRESS OR IMPLIED. IN NO EVENT SHALL ANY CONTRIBUTOR OR
154
+ COPYRIGHT HOLDER BE LIABLE TO YOU FOR ANY DAMAGES, INCLUDING, BUT NOT
155
+ LIMITED TO ANY DIRECT, OR INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING
156
+ FROM YOUR USE OR INABILITY TO USE THE SOFTWARE OR THE CONTRIBUTION IN IT, NO
157
+ MATTER HOW IT’S CAUSED OR BASED ON WHICH LEGAL THEORY, EVEN IF ADVISED OF
158
+ THE POSSIBILITY OF SUCH DAMAGES.
159
+
160
+ 6. Language
161
+
162
+ THIS LICENSE IS WRITTEN IN BOTH CHINESE AND ENGLISH, AND THE CHINESE VERSION
163
+ AND ENGLISH VERSION SHALL HAVE THE SAME LEGAL EFFECT. IN THE CASE OF
164
+ DIVERGENCE BETWEEN THE CHINESE AND ENGLISH VERSIONS, THE CHINESE VERSION
165
+ SHALL PREVAIL.
166
+
167
+ END OF THE TERMS AND CONDITIONS
168
+
169
+ How to Apply the Mulan Permissive Software License,Version 2
170
+ (Mulan PSL v2) to Your Software
171
+
172
+ To apply the Mulan PSL v2 to your work, for easy identification by
173
+ recipients, you are suggested to complete following three steps:
174
+
175
+ i. Fill in the blanks in following statement, including insert your software
176
+ name, the year of the first publication of your software, and your name
177
+ identified as the copyright owner;
178
+
179
+ ii. Create a file named "LICENSE" which contains the whole context of this
180
+ License in the first directory of your software package;
181
+
182
+ iii. Attach the statement to the appropriate annotated syntax at the
183
+ beginning of each source file.
184
+
185
+ Copyright (c) [Year] [name of copyright holder]
186
+ [Software Name] is licensed under Mulan PSL v2.
187
+ You can use this software according to the terms and conditions of the Mulan
188
+ PSL v2.
189
+ You may obtain a copy of Mulan PSL v2 at:
190
+ http://license.coscl.org.cn/MulanPSL2
191
+ THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
192
+ KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
193
+ NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
194
+ See the Mulan PSL v2 for more details.
@@ -0,0 +1,162 @@
1
+ """PyPixelCore public interfaces; implementations are organized by subsystem."""
2
+ from importlib import import_module
3
+ from typing import TYPE_CHECKING
4
+
5
+ if TYPE_CHECKING:
6
+ from PyPixelCore.settings import BlockType as BlockType
7
+ from PyPixelCore.settings import ColorType as ColorType
8
+ from PyPixelCore.settings import FPSType as FPSType
9
+ from PyPixelCore.timing import OnlyTimer as OnlyTimer
10
+ from PyPixelCore.timing import CycleTimer as CycleTimer
11
+ from PyPixelCore.timing import FrequencyTimer as FrequencyTimer
12
+ from PyPixelCore.timing import OnlyTimeTimer as OnlyTimeTimer
13
+ from PyPixelCore.timing import CycleTimeTimer as CycleTimeTimer
14
+ from PyPixelCore.timing import FrequencyTimeTimer as FrequencyTimeTimer
15
+ from PyPixelCore.timing import update_frame_clock as update_frame_clock
16
+ from PyPixelCore.timing import now_ms as now_ms
17
+ from PyPixelCore.assets import PixelResourceManager as PixelResourceManager
18
+ from PyPixelCore.assets import Resource as Resource
19
+ from PyPixelCore.assets import PreloadApply as PreloadApply
20
+ from PyPixelCore.assets import AsyncTaskManager as AsyncTaskManager
21
+ from PyPixelCore.ui.theme import Theme as Theme
22
+ from PyPixelCore.ui.theme import ThemePalette as ThemePalette
23
+ from PyPixelCore.ui.theme import WARM_PAPER as WARM_PAPER
24
+ from PyPixelCore.ui.theme import DARK_INK as DARK_INK
25
+ from PyPixelCore.ui.theme import OCEAN as OCEAN
26
+ from PyPixelCore.ui.theme import LIGHT as LIGHT
27
+ from PyPixelCore.ui.theme import BUILTIN_PALETTES as BUILTIN_PALETTES
28
+ from PyPixelCore.ui.theme import get_theme as get_theme
29
+ from PyPixelCore.game import GamePanel as GamePanel
30
+ from PyPixelCore.game import GameState as GameState
31
+ from PyPixelCore.render import ParticleSystem as ParticleSystem
32
+ from PyPixelCore.render import ParticleStyle as ParticleStyle
33
+ from PyPixelCore.render import ParticlePreset as ParticlePreset
34
+ from PyPixelCore.render import ParticleShape as ParticleShape
35
+ from PyPixelCore.render import SoftwareBackend as SoftwareBackend
36
+ from PyPixelCore.render import GLPointBackend as GLPointBackend
37
+ from PyPixelCore.render import GL_FRIENDLY_SHAPES as GL_FRIENDLY_SHAPES
38
+ from PyPixelCore.render import GLAvailable as GLAvailable
39
+ from PyPixelCore.render import create_default_presets as create_default_presets
40
+ from PyPixelCore.runtime.recorder import VideoRecorder as VideoRecorder
41
+ from PyPixelCore.render.text.fonts import FontResources as FontResources
42
+ from PyPixelCore.render.text.fonts import FontSpec as FontSpec
43
+ from PyPixelCore.render.text.fonts import TextStyle as TextStyle
44
+ from PyPixelCore.runtime.work_queue import FrameWorkQueue as FrameWorkQueue
45
+ from PyPixelCore.config import PyPixelConfig as PyPixelConfig
46
+ from PyPixelCore.config import WindowConfig as WindowConfig
47
+ from PyPixelCore.config import LayerConfig as LayerConfig
48
+ from PyPixelCore.config import RuntimeConfig as RuntimeConfig
49
+ from PyPixelCore.config import QAConfig as QAConfig
50
+ from PyPixelCore.config import RecordingConfig as RecordingConfig
51
+ from PyPixelCore.version import __version__ as __version__
52
+
53
+ __all__ = [
54
+ 'BlockType',
55
+ 'ColorType',
56
+ 'FPSType',
57
+ 'OnlyTimer',
58
+ 'CycleTimer',
59
+ 'FrequencyTimer',
60
+ 'OnlyTimeTimer',
61
+ 'CycleTimeTimer',
62
+ 'FrequencyTimeTimer',
63
+ 'update_frame_clock',
64
+ 'now_ms',
65
+ 'PixelResourceManager',
66
+ 'Resource',
67
+ 'PreloadApply',
68
+ 'AsyncTaskManager',
69
+ 'Theme',
70
+ 'ThemePalette',
71
+ 'WARM_PAPER',
72
+ 'DARK_INK',
73
+ 'OCEAN',
74
+ 'LIGHT',
75
+ 'BUILTIN_PALETTES',
76
+ 'get_theme',
77
+ 'GamePanel',
78
+ 'GameState',
79
+ 'ParticleSystem',
80
+ 'ParticleStyle',
81
+ 'ParticlePreset',
82
+ 'ParticleShape',
83
+ 'SoftwareBackend',
84
+ 'GLPointBackend',
85
+ 'GL_FRIENDLY_SHAPES',
86
+ 'GLAvailable',
87
+ 'create_default_presets',
88
+ 'VideoRecorder',
89
+ 'FontResources',
90
+ 'FontSpec',
91
+ 'TextStyle',
92
+ 'FrameWorkQueue',
93
+ 'PyPixelConfig',
94
+ 'WindowConfig',
95
+ 'LayerConfig',
96
+ 'RuntimeConfig',
97
+ 'QAConfig',
98
+ 'RecordingConfig',
99
+ '__version__',
100
+ ]
101
+
102
+ _EXPORTS = {
103
+ 'BlockType': 'PyPixelCore.settings',
104
+ 'ColorType': 'PyPixelCore.settings',
105
+ 'FPSType': 'PyPixelCore.settings',
106
+ 'OnlyTimer': 'PyPixelCore.timing',
107
+ 'CycleTimer': 'PyPixelCore.timing',
108
+ 'FrequencyTimer': 'PyPixelCore.timing',
109
+ 'OnlyTimeTimer': 'PyPixelCore.timing',
110
+ 'CycleTimeTimer': 'PyPixelCore.timing',
111
+ 'FrequencyTimeTimer': 'PyPixelCore.timing',
112
+ 'update_frame_clock': 'PyPixelCore.timing',
113
+ 'now_ms': 'PyPixelCore.timing',
114
+ 'PixelResourceManager': 'PyPixelCore.assets',
115
+ 'Resource': 'PyPixelCore.assets',
116
+ 'PreloadApply': 'PyPixelCore.assets',
117
+ 'AsyncTaskManager': 'PyPixelCore.assets',
118
+ 'Theme': 'PyPixelCore.ui.theme',
119
+ 'ThemePalette': 'PyPixelCore.ui.theme',
120
+ 'WARM_PAPER': 'PyPixelCore.ui.theme',
121
+ 'DARK_INK': 'PyPixelCore.ui.theme',
122
+ 'OCEAN': 'PyPixelCore.ui.theme',
123
+ 'LIGHT': 'PyPixelCore.ui.theme',
124
+ 'BUILTIN_PALETTES': 'PyPixelCore.ui.theme',
125
+ 'get_theme': 'PyPixelCore.ui.theme',
126
+ 'GamePanel': 'PyPixelCore.game',
127
+ 'GameState': 'PyPixelCore.game',
128
+ 'ParticleSystem': 'PyPixelCore.render',
129
+ 'ParticleStyle': 'PyPixelCore.render',
130
+ 'ParticlePreset': 'PyPixelCore.render',
131
+ 'ParticleShape': 'PyPixelCore.render',
132
+ 'SoftwareBackend': 'PyPixelCore.render',
133
+ 'GLPointBackend': 'PyPixelCore.render',
134
+ 'GL_FRIENDLY_SHAPES': 'PyPixelCore.render',
135
+ 'GLAvailable': 'PyPixelCore.render',
136
+ 'create_default_presets': 'PyPixelCore.render',
137
+ 'VideoRecorder': 'PyPixelCore.runtime.recorder',
138
+ 'FontResources': 'PyPixelCore.render.text.fonts',
139
+ 'FontSpec': 'PyPixelCore.render.text.fonts',
140
+ 'TextStyle': 'PyPixelCore.render.text.fonts',
141
+ 'FrameWorkQueue': 'PyPixelCore.runtime.work_queue',
142
+ 'PyPixelConfig': 'PyPixelCore.config',
143
+ 'WindowConfig': 'PyPixelCore.config',
144
+ 'LayerConfig': 'PyPixelCore.config',
145
+ 'RuntimeConfig': 'PyPixelCore.config',
146
+ 'QAConfig': 'PyPixelCore.config',
147
+ 'RecordingConfig': 'PyPixelCore.config',
148
+ '__version__': 'PyPixelCore.version',
149
+ }
150
+
151
+
152
+ def __getattr__(name):
153
+ owner = _EXPORTS.get(name)
154
+ if owner is None:
155
+ raise AttributeError(name)
156
+ value = getattr(import_module(owner), name)
157
+ globals()[name] = value
158
+ return value
159
+
160
+
161
+ def __dir__():
162
+ return sorted(set(globals()) | set(__all__))
@@ -0,0 +1,42 @@
1
+ """Interpolation and reusable visual effects."""
2
+ from importlib import import_module
3
+ from typing import TYPE_CHECKING
4
+
5
+ from .interpolation import Tween as Tween
6
+
7
+ if TYPE_CHECKING:
8
+ from PyPixelCore.animation.interpolation import linear as linear
9
+ from PyPixelCore.animation.interpolation import ease_in_out as ease_in_out
10
+ from PyPixelCore.animation.interpolation import ping_pong as ping_pong
11
+ from PyPixelCore.animation.effects import Animation as Animation
12
+ from PyPixelCore.animation.work_piece import WorkPiece as WorkPiece
13
+
14
+ __all__ = [
15
+ 'Tween',
16
+ 'linear',
17
+ 'ease_in_out',
18
+ 'ping_pong',
19
+ 'Animation',
20
+ 'WorkPiece',
21
+ ]
22
+
23
+ _EXPORTS = {
24
+ 'linear': 'PyPixelCore.animation.interpolation',
25
+ 'ease_in_out': 'PyPixelCore.animation.interpolation',
26
+ 'ping_pong': 'PyPixelCore.animation.interpolation',
27
+ 'Animation': 'PyPixelCore.animation.effects',
28
+ 'WorkPiece': 'PyPixelCore.animation.work_piece',
29
+ }
30
+
31
+
32
+ def __getattr__(name):
33
+ owner = _EXPORTS.get(name)
34
+ if owner is None:
35
+ raise AttributeError(name)
36
+ value = getattr(import_module(owner), name)
37
+ globals()[name] = value
38
+ return value
39
+
40
+
41
+ def __dir__():
42
+ return sorted(set(globals()) | set(__all__))
@@ -0,0 +1,294 @@
1
+ """统一动画入口。
2
+
3
+ 所有动画工厂方法集中在此类,返回 WorkPiece,调用 ``.run(target)`` 执行。
4
+ 消除旧的 4 个分散工厂类 + 2 个模块级函数的不一致性。
5
+
6
+ 设计原则:
7
+ - 所有非核心参数用 keyword-only(``*`` 后),防止位置参数混淆
8
+ - 所有方法返回 WorkPiece,延迟执行
9
+ - run(target) 的 target 是实际添加精灵的目标(Panel 或 Controller)
10
+ """
11
+
12
+ from typing import Any, List, Optional, Tuple
13
+
14
+ from PyPixelCore.runtime.controller import PyPixelController
15
+ from PyPixelCore.settings import (
16
+ IMG_ANIMATION_DEFAULT_SIZE,
17
+ TEXT_ANIMATION_DISAPPEAR_FADE_SPEED,
18
+ TEXT_ANIMATION_FLEX_FADE_SPEED,
19
+ basic_font_size,
20
+ warning_img_url,
21
+ ColorType,
22
+ )
23
+ from PyPixelCore.animation.work_piece import WorkPiece
24
+ from PyPixelCore.animation.text import (
25
+ _make_text_block,
26
+ _setup_flex_animation,
27
+ _setup_disappear_animation,
28
+ )
29
+ from PyPixelCore.animation.image import ImgFactory
30
+ from PyPixelCore.animation.move import MoveFactory
31
+ from PyPixelCore.ui.primitives.block import Block
32
+ from PyPixelCore.ui.containers.panel import Panel
33
+
34
+
35
+ class Animation:
36
+ """统一动画入口。所有方法返回 WorkPiece,调用 ``.run(target)`` 执行。
37
+
38
+ 新增动画只需在此类中添加一个静态方法。
39
+
40
+ 用法::
41
+
42
+ from PyPixelCore.animation import Animation
43
+
44
+ # 浮动文字
45
+ Animation.flex_text("Hello", panel=panel, font_size=24).run(panel)
46
+ Animation.flex_text("Hi", controller=ppc, pos=(400, 300)).run(ppc)
47
+
48
+ # 原地消失
49
+ Animation.disappear_text("Bye", panel=panel, show_time=2).run(panel)
50
+
51
+ # 直线移动
52
+ Animation.move(sprite, target=(200, 300), speed=0.3).run(ppc)
53
+
54
+ # 震动渐隐
55
+ Animation.vibrate(width=80, height=80).run(ppc)
56
+
57
+ # 淡入/淡出
58
+ Animation.fade_in(blocks, speed=5).run(ppc)
59
+ Animation.fade_out(blocks, speed=8, delete=True).run(ppc)
60
+ """
61
+
62
+ # ------------------------------------------------------------------
63
+ # 文字动画
64
+ # ------------------------------------------------------------------
65
+
66
+ @staticmethod
67
+ def flex_text(
68
+ text: str,
69
+ *,
70
+ controller: Optional[PyPixelController] = None,
71
+ panel: Optional[Panel] = None,
72
+ pos: Optional[Tuple[int, int]] = None,
73
+ is_center: bool = True,
74
+ font_size: int = basic_font_size,
75
+ bk_color=None,
76
+ font_color: Tuple[int, int, int] = ColorType.RED,
77
+ offset_y: float = 0.2,
78
+ disappear_speed: int = TEXT_ANIMATION_FLEX_FADE_SPEED,
79
+ ) -> WorkPiece:
80
+ """浮动渐隐文字动画。支持添加到 controller(顶层)或 panel(面板内)。
81
+
82
+ Args:
83
+ text: 显示的文字。
84
+ controller: 目标控制器(与 panel 二选一,同时传则 controller 优先)。
85
+ panel: 目标面板(与 controller 二选一)。
86
+ pos: 绝对位置(controller 模式使用),默认 panel 中心偏上。
87
+ is_center: pos 是否为中心点。
88
+ font_size: 字体大小。
89
+ bk_color: 背景色,None 表示透明。
90
+ font_color: 字体颜色。
91
+ offset_y: 相对面板中心的 Y 偏移比例(panel 模式使用)。
92
+ disappear_speed: 渐隐速度(每帧 alpha 减少量)。
93
+
94
+ Returns:
95
+ WorkPiece 实例,调用 .run(target) 执行。
96
+ """
97
+ message_block = _make_text_block(text, font_size, bk_color, font_color)
98
+
99
+ if controller is not None:
100
+ # controller 模式:用 pos 定位,run 时 add_block
101
+ def run_ctrl(target: Any) -> None:
102
+ if pos is not None:
103
+ if is_center:
104
+ message_block.rect.center = pos
105
+ else:
106
+ message_block.rect.topleft = pos
107
+ controller.add_block(message_block)
108
+ _setup_flex_animation(message_block, disappear_speed, panel_mode=False)
109
+ return WorkPiece(message_block, run_func=run_ctrl)
110
+ else:
111
+ # panel 模式:用 offset_y 定位,run 时 add_sprites
112
+ target_panel = panel
113
+ if target_panel is None:
114
+ raise ValueError("flex_text 需要 controller 或 panel 参数")
115
+ message_block.rect.center = (
116
+ target_panel.rect.center[0] - target_panel.point_x,
117
+ target_panel.rect.center[1] - target_panel.point_y - target_panel.height * offset_y,
118
+ )
119
+ def run_panel(target: Any) -> None:
120
+ target.add_sprites(message_block)
121
+ _setup_flex_animation(message_block, disappear_speed, panel_mode=True)
122
+ return WorkPiece(message_block, run_func=run_panel)
123
+
124
+ @staticmethod
125
+ def disappear_text(
126
+ text: str,
127
+ *,
128
+ panel: Panel,
129
+ font_size: int = basic_font_size,
130
+ bk_color=None,
131
+ font_color: Tuple[int, int, int] = ColorType.RED,
132
+ offset_y: float = 0.3,
133
+ show_time: int = 1,
134
+ disappear_speed: int = TEXT_ANIMATION_DISAPPEAR_FADE_SPEED,
135
+ ) -> WorkPiece:
136
+ """原地渐隐文字动画,添加到面板。
137
+
138
+ Args:
139
+ text: 显示的文字。
140
+ panel: 目标面板。
141
+ font_size: 字体大小。
142
+ bk_color: 背景色,None 表示透明。
143
+ font_color: 字体颜色。
144
+ offset_y: 相对面板中心的 Y 偏移比例。
145
+ show_time: 停留时间(秒)。
146
+ disappear_speed: 渐隐速度。
147
+
148
+ Returns:
149
+ WorkPiece 实例,调用 .run(target) 执行。
150
+ """
151
+ message_block = _make_text_block(text, font_size, bk_color, font_color)
152
+ message_block.rect.center = (
153
+ panel.rect.center[0] - panel.point_x,
154
+ panel.rect.center[1] - panel.point_y - panel.height * offset_y,
155
+ )
156
+ _setup_disappear_animation(message_block, show_time, disappear_speed)
157
+ return WorkPiece(message_block)
158
+
159
+ # ------------------------------------------------------------------
160
+ # 移动动画
161
+ # ------------------------------------------------------------------
162
+
163
+ @staticmethod
164
+ def move(
165
+ sprite: Block,
166
+ target: Tuple[int, int],
167
+ *,
168
+ speed: float,
169
+ ) -> WorkPiece:
170
+ """直线移动动画,将精灵从当前位置移动到目标位置。
171
+
172
+ Args:
173
+ sprite: 需要移动的精灵块。
174
+ target: 目标位置 (x, y)。
175
+ speed: 移动速度(像素/帧),总帧数 = speed * fps_limit。
176
+
177
+ Returns:
178
+ WorkPiece 实例,调用 .run(ctrl) 执行。
179
+ """
180
+ # P2-22: 复用 MoveFactory.direct_move_animation,消除重复闭包逻辑
181
+ return MoveFactory.direct_move_animation(sprite, target, speed)
182
+
183
+ # ------------------------------------------------------------------
184
+ # 图像动画
185
+ # ------------------------------------------------------------------
186
+
187
+ @staticmethod
188
+ def vibrate(
189
+ *,
190
+ width: int,
191
+ height: int,
192
+ pos: Optional[Tuple[int, int]] = None,
193
+ pattern: Optional[List[tuple]] = None,
194
+ img_url: str = warning_img_url,
195
+ ) -> WorkPiece:
196
+ """震动后渐隐的警告动画。
197
+
198
+ Args:
199
+ width: 图像宽度。
200
+ height: 图像高度。
201
+ pos: 显示位置 (x, y),默认屏幕居中。
202
+ pattern: 震动偏移序列,默认四方向震动。
203
+ img_url: 图像资源路径。
204
+
205
+ Returns:
206
+ WorkPiece 实例,调用 .run(ctrl) 执行。
207
+ """
208
+ # P2-23: 委托给 ImgFactory.vibrate_animation,消除重复实现
209
+ if pos is not None:
210
+ point_x, point_y = pos
211
+ else:
212
+ point_x = None
213
+ point_y = None
214
+ return ImgFactory.vibrate_animation(
215
+ None, width, height,
216
+ point_x=point_x, point_y=point_y,
217
+ vibrate_arr=pattern, img_url=img_url,
218
+ )
219
+
220
+ @staticmethod
221
+ def dynamic(
222
+ img_url: str,
223
+ *,
224
+ controller: PyPixelController,
225
+ state: str = "dynamic",
226
+ interval: int = 6,
227
+ width: int = IMG_ANIMATION_DEFAULT_SIZE,
228
+ height: int = IMG_ANIMATION_DEFAULT_SIZE,
229
+ ) -> WorkPiece:
230
+ """动态图像播放动画。延迟注册:在 run() 时才 add_block。
231
+
232
+ Args:
233
+ img_url: 动态图像资源路径。
234
+ controller: 目标控制器。
235
+ state: 动画状态名称。
236
+ interval: 帧间隔。
237
+ width: 宽度。
238
+ height: 高度。
239
+
240
+ Returns:
241
+ WorkPiece 实例,调用 .run(ctrl) 执行。
242
+ """
243
+ # P3-4: 委托给 ImgFactory.dynamic_animation,消除重复实现
244
+ return ImgFactory.dynamic_animation(
245
+ img_url, controller,
246
+ state_name=state,
247
+ animation_interval=interval,
248
+ width=width,
249
+ height=height,
250
+ )
251
+
252
+ @staticmethod
253
+ def fade_in(
254
+ blocks: List[Any],
255
+ *,
256
+ speed: int = 5,
257
+ interval: int = 2,
258
+ ) -> WorkPiece:
259
+ """淡入显示动画。
260
+
261
+ Args:
262
+ blocks: 目标精灵块列表。
263
+ speed: 每帧 alpha 增加量。
264
+ interval: 帧间隔。
265
+
266
+ Returns:
267
+ WorkPiece 实例,调用 .run(ctrl) 执行。
268
+ """
269
+ return ImgFactory._create_fade_animation(
270
+ blocks, None, interval, speed, fade_in=True,
271
+ )
272
+
273
+ @staticmethod
274
+ def fade_out(
275
+ blocks: List[Any],
276
+ *,
277
+ speed: int = 20,
278
+ interval: int = 2,
279
+ delete: bool = False,
280
+ ) -> WorkPiece:
281
+ """淡出隐藏动画。
282
+
283
+ Args:
284
+ blocks: 目标精灵块列表。
285
+ speed: 每帧 alpha 减少量。
286
+ interval: 帧间隔。
287
+ delete: 动画完成后是否销毁精灵。
288
+
289
+ Returns:
290
+ WorkPiece 实例,调用 .run(ctrl) 执行。
291
+ """
292
+ return ImgFactory._create_fade_animation(
293
+ blocks, None, interval, speed, fade_in=False, delete=delete,
294
+ )