kraken-engine 1.0.0__cp311-cp311-macosx_11_0_arm64.whl → 1.3.0__cp311-cp311-macosx_11_0_arm64.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.
- {kraken_engine-1.0.0.dist-info → kraken_engine-1.3.0.dist-info}/METADATA +3 -1
- kraken_engine-1.3.0.dist-info/RECORD +28 -0
- pykraken/__init__.py +1 -0
- pykraken/__init__.pyi +115 -15
- pykraken/_core/__init__.pyi +985 -777
- pykraken/_core/collision.pyi +283 -0
- pykraken/_core/event.pyi +46 -1
- pykraken/_core/math.pyi +14 -3
- pykraken/_core/renderer.pyi +22 -11
- pykraken/_core/time.pyi +4 -4
- pykraken/_core/viewport.pyi +30 -0
- pykraken/_core/window.pyi +10 -9
- pykraken/_core.cpython-311-darwin.so +0 -0
- pykraken/shader_uniform.py +47 -0
- pykraken/shader_uniform.pyi +51 -0
- kraken_engine-1.0.0.dist-info/RECORD +0 -24
- {kraken_engine-1.0.0.dist-info → kraken_engine-1.3.0.dist-info}/WHEEL +0 -0
- {kraken_engine-1.0.0.dist-info → kraken_engine-1.3.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Collision detection functions
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
import pykraken._core
|
|
6
|
+
import typing
|
|
7
|
+
__all__: list[str] = ['contains', 'overlap']
|
|
8
|
+
@typing.overload
|
|
9
|
+
def contains(outer: pykraken._core.Rect, inner: pykraken._core.Rect) -> bool:
|
|
10
|
+
"""
|
|
11
|
+
Check whether one rectangle completely contains another rectangle.
|
|
12
|
+
|
|
13
|
+
Args:
|
|
14
|
+
outer (Rect): The outer rectangle.
|
|
15
|
+
inner (Rect): The inner rectangle.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
bool: True if the outer rectangle completely contains the inner rectangle.
|
|
19
|
+
"""
|
|
20
|
+
@typing.overload
|
|
21
|
+
def contains(rect: pykraken._core.Rect, circle: pykraken._core.Circle) -> bool:
|
|
22
|
+
"""
|
|
23
|
+
Check whether a rectangle completely contains a circle.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
rect (Rect): The rectangle.
|
|
27
|
+
circle (Circle): The circle.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
bool: True if the rectangle completely contains the circle.
|
|
31
|
+
"""
|
|
32
|
+
@typing.overload
|
|
33
|
+
def contains(rect: pykraken._core.Rect, line: pykraken._core.Line) -> bool:
|
|
34
|
+
"""
|
|
35
|
+
Check whether a rectangle completely contains a line.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
rect (Rect): The rectangle.
|
|
39
|
+
line (Line): The line.
|
|
40
|
+
|
|
41
|
+
Returns:
|
|
42
|
+
bool: True if the rectangle completely contains the line.
|
|
43
|
+
"""
|
|
44
|
+
@typing.overload
|
|
45
|
+
def contains(outer: pykraken._core.Circle, inner: pykraken._core.Circle) -> bool:
|
|
46
|
+
"""
|
|
47
|
+
Check whether one circle completely contains another circle.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
outer (Circle): The outer circle.
|
|
51
|
+
inner (Circle): The inner circle.
|
|
52
|
+
|
|
53
|
+
Returns:
|
|
54
|
+
bool: True if the outer circle completely contains the inner circle.
|
|
55
|
+
"""
|
|
56
|
+
@typing.overload
|
|
57
|
+
def contains(circle: pykraken._core.Circle, rect: pykraken._core.Rect) -> bool:
|
|
58
|
+
"""
|
|
59
|
+
Check whether a circle completely contains a rectangle.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
circle (Circle): The circle.
|
|
63
|
+
rect (Rect): The rectangle.
|
|
64
|
+
|
|
65
|
+
Returns:
|
|
66
|
+
bool: True if the circle completely contains the rectangle.
|
|
67
|
+
"""
|
|
68
|
+
@typing.overload
|
|
69
|
+
def contains(circle: pykraken._core.Circle, line: pykraken._core.Line) -> bool:
|
|
70
|
+
"""
|
|
71
|
+
Check whether a circle completely contains a line.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
circle (Circle): The circle.
|
|
75
|
+
line (Line): The line.
|
|
76
|
+
|
|
77
|
+
Returns:
|
|
78
|
+
bool: True if the circle completely contains the line.
|
|
79
|
+
"""
|
|
80
|
+
@typing.overload
|
|
81
|
+
def overlap(a: pykraken._core.Rect, b: pykraken._core.Rect) -> bool:
|
|
82
|
+
"""
|
|
83
|
+
Check whether two rectangles overlap.
|
|
84
|
+
|
|
85
|
+
Args:
|
|
86
|
+
a (Rect): The first rectangle.
|
|
87
|
+
b (Rect): The second rectangle.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
bool: True if the rectangles overlap.
|
|
91
|
+
"""
|
|
92
|
+
@typing.overload
|
|
93
|
+
def overlap(rect: pykraken._core.Rect, circle: pykraken._core.Circle) -> bool:
|
|
94
|
+
"""
|
|
95
|
+
Check whether a rectangle and a circle overlap.
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
rect (Rect): The rectangle.
|
|
99
|
+
circle (Circle): The circle.
|
|
100
|
+
|
|
101
|
+
Returns:
|
|
102
|
+
bool: True if the rectangle and circle overlap.
|
|
103
|
+
"""
|
|
104
|
+
@typing.overload
|
|
105
|
+
def overlap(rect: pykraken._core.Rect, line: pykraken._core.Line) -> bool:
|
|
106
|
+
"""
|
|
107
|
+
Check whether a rectangle and a line overlap.
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
rect (Rect): The rectangle.
|
|
111
|
+
line (Line): The line.
|
|
112
|
+
|
|
113
|
+
Returns:
|
|
114
|
+
bool: True if the rectangle and line overlap.
|
|
115
|
+
"""
|
|
116
|
+
@typing.overload
|
|
117
|
+
def overlap(rect: pykraken._core.Rect, point: pykraken._core.Vec2) -> bool:
|
|
118
|
+
"""
|
|
119
|
+
Check whether a rectangle contains a point.
|
|
120
|
+
|
|
121
|
+
Args:
|
|
122
|
+
rect (Rect): The rectangle.
|
|
123
|
+
point (Vec2): The point.
|
|
124
|
+
|
|
125
|
+
Returns:
|
|
126
|
+
bool: True if the rectangle contains the point.
|
|
127
|
+
"""
|
|
128
|
+
@typing.overload
|
|
129
|
+
def overlap(a: pykraken._core.Circle, b: pykraken._core.Circle) -> bool:
|
|
130
|
+
"""
|
|
131
|
+
Check whether two circles overlap.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
a (Circle): The first circle.
|
|
135
|
+
b (Circle): The second circle.
|
|
136
|
+
|
|
137
|
+
Returns:
|
|
138
|
+
bool: True if the circles overlap.
|
|
139
|
+
"""
|
|
140
|
+
@typing.overload
|
|
141
|
+
def overlap(circle: pykraken._core.Circle, rect: pykraken._core.Rect) -> bool:
|
|
142
|
+
"""
|
|
143
|
+
Check whether a circle and a rectangle overlap.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
circle (Circle): The circle.
|
|
147
|
+
rect (Rect): The rectangle.
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
bool: True if the circle and rectangle overlap.
|
|
151
|
+
"""
|
|
152
|
+
@typing.overload
|
|
153
|
+
def overlap(circle: pykraken._core.Circle, line: pykraken._core.Line) -> bool:
|
|
154
|
+
"""
|
|
155
|
+
Check whether a circle and a line overlap.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
circle (Circle): The circle.
|
|
159
|
+
line (Line): The line.
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
bool: True if the circle and line overlap.
|
|
163
|
+
"""
|
|
164
|
+
@typing.overload
|
|
165
|
+
def overlap(circle: pykraken._core.Circle, point: pykraken._core.Vec2) -> bool:
|
|
166
|
+
"""
|
|
167
|
+
Check whether a circle contains a point.
|
|
168
|
+
|
|
169
|
+
Args:
|
|
170
|
+
circle (Circle): The circle.
|
|
171
|
+
point (Vec2): The point.
|
|
172
|
+
|
|
173
|
+
Returns:
|
|
174
|
+
bool: True if the circle contains the point.
|
|
175
|
+
"""
|
|
176
|
+
@typing.overload
|
|
177
|
+
def overlap(a: pykraken._core.Line, b: pykraken._core.Line) -> bool:
|
|
178
|
+
"""
|
|
179
|
+
Check whether two lines overlap (intersect).
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
a (Line): The first line.
|
|
183
|
+
b (Line): The second line.
|
|
184
|
+
|
|
185
|
+
Returns:
|
|
186
|
+
bool: True if the lines intersect.
|
|
187
|
+
"""
|
|
188
|
+
@typing.overload
|
|
189
|
+
def overlap(line: pykraken._core.Line, rect: pykraken._core.Rect) -> bool:
|
|
190
|
+
"""
|
|
191
|
+
Check whether a line and a rectangle overlap.
|
|
192
|
+
|
|
193
|
+
Args:
|
|
194
|
+
line (Line): The line.
|
|
195
|
+
rect (Rect): The rectangle.
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
bool: True if the line and rectangle overlap.
|
|
199
|
+
"""
|
|
200
|
+
@typing.overload
|
|
201
|
+
def overlap(line: pykraken._core.Line, circle: pykraken._core.Circle) -> bool:
|
|
202
|
+
"""
|
|
203
|
+
Check whether a line and a circle overlap.
|
|
204
|
+
|
|
205
|
+
Args:
|
|
206
|
+
line (Line): The line.
|
|
207
|
+
circle (Circle): The circle.
|
|
208
|
+
|
|
209
|
+
Returns:
|
|
210
|
+
bool: True if the line and circle overlap.
|
|
211
|
+
"""
|
|
212
|
+
@typing.overload
|
|
213
|
+
def overlap(point: pykraken._core.Vec2, rect: pykraken._core.Rect) -> bool:
|
|
214
|
+
"""
|
|
215
|
+
Check whether a point is inside a rectangle.
|
|
216
|
+
|
|
217
|
+
Args:
|
|
218
|
+
point (Vec2): The point.
|
|
219
|
+
rect (Rect): The rectangle.
|
|
220
|
+
|
|
221
|
+
Returns:
|
|
222
|
+
bool: True if the point is inside the rectangle.
|
|
223
|
+
"""
|
|
224
|
+
@typing.overload
|
|
225
|
+
def overlap(point: pykraken._core.Vec2, circle: pykraken._core.Circle) -> bool:
|
|
226
|
+
"""
|
|
227
|
+
Check whether a point is inside a circle.
|
|
228
|
+
|
|
229
|
+
Args:
|
|
230
|
+
point (Vec2): The point.
|
|
231
|
+
circle (Circle): The circle.
|
|
232
|
+
|
|
233
|
+
Returns:
|
|
234
|
+
bool: True if the point is inside the circle.
|
|
235
|
+
"""
|
|
236
|
+
@typing.overload
|
|
237
|
+
def overlap(polygon: pykraken._core.Polygon, point: pykraken._core.Vec2) -> bool:
|
|
238
|
+
"""
|
|
239
|
+
Check whether a polygon contains a point.
|
|
240
|
+
|
|
241
|
+
Args:
|
|
242
|
+
polygon (Polygon): The polygon.
|
|
243
|
+
point (Vec2): The point.
|
|
244
|
+
|
|
245
|
+
Returns:
|
|
246
|
+
bool: True if the polygon contains the point.
|
|
247
|
+
"""
|
|
248
|
+
@typing.overload
|
|
249
|
+
def overlap(point: pykraken._core.Vec2, polygon: pykraken._core.Polygon) -> bool:
|
|
250
|
+
"""
|
|
251
|
+
Check whether a point is inside a polygon.
|
|
252
|
+
|
|
253
|
+
Args:
|
|
254
|
+
point (Vec2): The point.
|
|
255
|
+
polygon (Polygon): The polygon.
|
|
256
|
+
|
|
257
|
+
Returns:
|
|
258
|
+
bool: True if the point is inside the polygon.
|
|
259
|
+
"""
|
|
260
|
+
@typing.overload
|
|
261
|
+
def overlap(polygon: pykraken._core.Polygon, rect: pykraken._core.Rect) -> bool:
|
|
262
|
+
"""
|
|
263
|
+
Check whether a polygon and a rectangle overlap.
|
|
264
|
+
|
|
265
|
+
Args:
|
|
266
|
+
polygon (Polygon): The polygon.
|
|
267
|
+
rect (Rect): The rectangle.
|
|
268
|
+
|
|
269
|
+
Returns:
|
|
270
|
+
bool: True if the polygon and rectangle overlap.
|
|
271
|
+
"""
|
|
272
|
+
@typing.overload
|
|
273
|
+
def overlap(rect: pykraken._core.Rect, polygon: pykraken._core.Polygon) -> bool:
|
|
274
|
+
"""
|
|
275
|
+
Check whether a rectangle and a polygon overlap.
|
|
276
|
+
|
|
277
|
+
Args:
|
|
278
|
+
rect (Rect): The rectangle.
|
|
279
|
+
polygon (Polygon): The polygon.
|
|
280
|
+
|
|
281
|
+
Returns:
|
|
282
|
+
bool: True if the rectangle and polygon overlap.
|
|
283
|
+
"""
|
pykraken/_core/event.pyi
CHANGED
|
@@ -3,7 +3,28 @@ Input event handling
|
|
|
3
3
|
"""
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
import pykraken._core
|
|
6
|
-
|
|
6
|
+
import typing
|
|
7
|
+
__all__: list[str] = ['cancel_scheduled', 'new_custom', 'poll', 'push', 'schedule']
|
|
8
|
+
def cancel_scheduled(event: pykraken._core.Event) -> None:
|
|
9
|
+
"""
|
|
10
|
+
Cancel a scheduled event timer.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
event (Event): The custom event whose timer should be cancelled.
|
|
14
|
+
|
|
15
|
+
Raises:
|
|
16
|
+
RuntimeError: If attempting to cancel a non-custom event type.
|
|
17
|
+
"""
|
|
18
|
+
def new_custom() -> pykraken._core.Event:
|
|
19
|
+
"""
|
|
20
|
+
Create a new custom event type.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
Event: A new Event object with a unique custom event type.
|
|
24
|
+
|
|
25
|
+
Raises:
|
|
26
|
+
RuntimeError: If registering a custom event type fails.
|
|
27
|
+
"""
|
|
7
28
|
def poll() -> list[pykraken._core.Event]:
|
|
8
29
|
"""
|
|
9
30
|
Poll for all pending user input events.
|
|
@@ -13,3 +34,27 @@ def poll() -> list[pykraken._core.Event]:
|
|
|
13
34
|
Returns:
|
|
14
35
|
list[Event]: A list of input event objects.
|
|
15
36
|
"""
|
|
37
|
+
def push(event: pykraken._core.Event) -> None:
|
|
38
|
+
"""
|
|
39
|
+
Push a custom event to the event queue.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
event (Event): The custom event to push to the queue.
|
|
43
|
+
|
|
44
|
+
Raises:
|
|
45
|
+
RuntimeError: If attempting to push a non-custom event type.
|
|
46
|
+
"""
|
|
47
|
+
def schedule(event: pykraken._core.Event, delay_ms: typing.SupportsInt, repeat: bool = False) -> None:
|
|
48
|
+
"""
|
|
49
|
+
Schedule a custom event to be pushed after a delay. Will overwrite any existing timer for the same event.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
event (Event): The custom event to schedule.
|
|
53
|
+
delay_ms (int): Delay in milliseconds before the event is pushed.
|
|
54
|
+
repeat (bool, optional): If True, the event will be pushed repeatedly at the
|
|
55
|
+
specified interval. If False, the event is pushed only once. Defaults to False.
|
|
56
|
+
|
|
57
|
+
Raises:
|
|
58
|
+
RuntimeError: If attempting to schedule a non-custom event type, or if timer
|
|
59
|
+
creation fails.
|
|
60
|
+
"""
|
pykraken/_core/math.pyi
CHANGED
|
@@ -4,7 +4,7 @@ Math related functions
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
import pykraken._core
|
|
6
6
|
import typing
|
|
7
|
-
__all__: list[str] = ['angle_between', 'clamp', 'cross', 'dot', 'from_polar', 'lerp', 'normalize', 'remap', 'scale_to_length', 'to_deg', 'to_rad']
|
|
7
|
+
__all__: list[str] = ['angle_between', 'clamp', 'cross', 'dot', 'from_polar', 'lerp', 'normalize', 'remap', 'rotate', 'scale_to_length', 'to_deg', 'to_rad']
|
|
8
8
|
def angle_between(a: pykraken._core.Vec2, b: pykraken._core.Vec2) -> float:
|
|
9
9
|
"""
|
|
10
10
|
Calculate the angle between two vectors.
|
|
@@ -22,7 +22,7 @@ def clamp(vec: pykraken._core.Vec2, min_vec: pykraken._core.Vec2, max_vec: pykra
|
|
|
22
22
|
Clamp a vector between two boundary vectors.
|
|
23
23
|
|
|
24
24
|
Args:
|
|
25
|
-
|
|
25
|
+
vec (Vec2): The vector to clamp.
|
|
26
26
|
min_vec (Vec2): The minimum boundary vector.
|
|
27
27
|
max_vec (Vec2): The maximum boundary vector.
|
|
28
28
|
|
|
@@ -118,7 +118,7 @@ def normalize(vec: pykraken._core.Vec2) -> pykraken._core.Vec2:
|
|
|
118
118
|
Normalize a vector to unit length.
|
|
119
119
|
|
|
120
120
|
Args:
|
|
121
|
-
|
|
121
|
+
vec (Vec2): The input vector.
|
|
122
122
|
|
|
123
123
|
Returns:
|
|
124
124
|
Vec2: A new normalized vector.
|
|
@@ -140,6 +140,17 @@ def remap(in_min: typing.SupportsFloat, in_max: typing.SupportsFloat, out_min: t
|
|
|
140
140
|
Raises:
|
|
141
141
|
ValueError: If in_min equals in_max.
|
|
142
142
|
"""
|
|
143
|
+
def rotate(vec: pykraken._core.Vec2, radians: typing.SupportsFloat) -> pykraken._core.Vec2:
|
|
144
|
+
"""
|
|
145
|
+
Rotate a vector by an angle without mutating the input.
|
|
146
|
+
|
|
147
|
+
Args:
|
|
148
|
+
vec (Vec2): The vector to rotate.
|
|
149
|
+
radians (float): Rotation angle in radians.
|
|
150
|
+
|
|
151
|
+
Returns:
|
|
152
|
+
Vec2: A new rotated vector.
|
|
153
|
+
"""
|
|
143
154
|
def scale_to_length(vector: pykraken._core.Vec2, length: typing.SupportsFloat) -> pykraken._core.Vec2:
|
|
144
155
|
"""
|
|
145
156
|
Scale a vector to a given length.
|
pykraken/_core/renderer.pyi
CHANGED
|
@@ -4,7 +4,7 @@ Functions for rendering graphics
|
|
|
4
4
|
from __future__ import annotations
|
|
5
5
|
import pykraken._core
|
|
6
6
|
import typing
|
|
7
|
-
__all__: list[str] = ['clear', 'draw', 'get_res', 'present']
|
|
7
|
+
__all__: list[str] = ['clear', 'draw', 'get_res', 'present', 'read_pixels']
|
|
8
8
|
@typing.overload
|
|
9
9
|
def clear(color: typing.Any = None) -> None:
|
|
10
10
|
"""
|
|
@@ -30,22 +30,22 @@ def clear(r: typing.SupportsInt, g: typing.SupportsInt, b: typing.SupportsInt, a
|
|
|
30
30
|
@typing.overload
|
|
31
31
|
def draw(texture: pykraken._core.Texture, dst: pykraken._core.Rect, src: typing.Any = None) -> None:
|
|
32
32
|
"""
|
|
33
|
-
|
|
33
|
+
Render a texture with specified destination and source rectangles.
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
Args:
|
|
36
|
+
texture (Texture): The texture to render.
|
|
37
|
+
dst (Rect): The destination rectangle on the renderer.
|
|
38
|
+
src (Rect, optional): The source rectangle from the texture. Defaults to entire texture if not specified.
|
|
39
39
|
"""
|
|
40
40
|
@typing.overload
|
|
41
41
|
def draw(texture: pykraken._core.Texture, pos: typing.Any = None, anchor: pykraken._core.Anchor = pykraken._core.Anchor.CENTER) -> None:
|
|
42
42
|
"""
|
|
43
|
-
|
|
43
|
+
Render a texture at the specified position with anchor alignment.
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
Args:
|
|
46
|
+
texture (Texture): The texture to render.
|
|
47
|
+
pos (Vec2, optional): The position to draw at. Defaults to (0, 0).
|
|
48
|
+
anchor (Anchor, optional): The anchor point for positioning. Defaults to CENTER.
|
|
49
49
|
"""
|
|
50
50
|
def get_res() -> pykraken._core.Vec2:
|
|
51
51
|
"""
|
|
@@ -61,3 +61,14 @@ def present() -> None:
|
|
|
61
61
|
This finalizes the current frame and displays it. Should be called after
|
|
62
62
|
all drawing operations for the frame are complete.
|
|
63
63
|
"""
|
|
64
|
+
def read_pixels(src: typing.Any = None) -> pykraken._core.PixelArray:
|
|
65
|
+
"""
|
|
66
|
+
Read pixel data from the renderer within the specified rectangle.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
src (Rect, optional): The rectangle area to read pixels from. Defaults to entire renderer if None.
|
|
70
|
+
Returns:
|
|
71
|
+
PixelArray: An array containing the pixel data.
|
|
72
|
+
Raises:
|
|
73
|
+
RuntimeError: If reading pixels fails.
|
|
74
|
+
"""
|
pykraken/_core/time.pyi
CHANGED
|
@@ -52,10 +52,10 @@ def set_max_delta(max_delta: typing.SupportsFloat) -> None:
|
|
|
52
52
|
"""
|
|
53
53
|
Set the maximum allowed delta time between frames.
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
max_delta (float):
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
Args:
|
|
56
|
+
max_delta (float): Maximum delta time in seconds (> 0.0).
|
|
57
|
+
Use this to avoid large deltas during frame drops or pauses
|
|
58
|
+
that could destabilize physics or animations.
|
|
59
59
|
"""
|
|
60
60
|
def set_scale(scale: typing.SupportsFloat) -> None:
|
|
61
61
|
"""
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Viewport management functions
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
import pykraken._core
|
|
6
|
+
import typing
|
|
7
|
+
__all__: list[str] = ['layout', 'set', 'unset']
|
|
8
|
+
def layout(count: typing.SupportsInt, mode: pykraken._core.ViewportMode = pykraken._core.ViewportMode.VERTICAL) -> list[pykraken._core.Rect]:
|
|
9
|
+
"""
|
|
10
|
+
Layout the screen into multiple viewports.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
count (int): The number of viewports to create (between 2 and 4).
|
|
14
|
+
mode (ViewportMode, optional): The layout mode for 2 viewports (VERTICAL or HORIZONTAL).
|
|
15
|
+
Defaults to VERTICAL.
|
|
16
|
+
|
|
17
|
+
Returns:
|
|
18
|
+
list[Rect]: A list of Rects representing the viewports.
|
|
19
|
+
"""
|
|
20
|
+
def set(rect: pykraken._core.Rect) -> None:
|
|
21
|
+
"""
|
|
22
|
+
Set the current viewport to the given rectangle.
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
rect (Rect): The rectangle defining the viewport.
|
|
26
|
+
"""
|
|
27
|
+
def unset() -> None:
|
|
28
|
+
"""
|
|
29
|
+
Unset the current viewport, reverting to the full rendering area.
|
|
30
|
+
"""
|
pykraken/_core/window.pyi
CHANGED
|
@@ -13,18 +13,16 @@ def close() -> None:
|
|
|
13
13
|
"""
|
|
14
14
|
def create(title: str, resolution: pykraken._core.Vec2, scaled: bool = False) -> None:
|
|
15
15
|
"""
|
|
16
|
-
Create a window with
|
|
16
|
+
Create a window with the requested title and resolution.
|
|
17
17
|
|
|
18
18
|
Args:
|
|
19
|
-
title (str):
|
|
20
|
-
resolution (Vec2):
|
|
21
|
-
scaled (bool
|
|
22
|
-
display's usable bounds, retaining the resolution's ratio.
|
|
23
|
-
Defaults to False.
|
|
19
|
+
title (str): Non-empty title no longer than 255 characters.
|
|
20
|
+
resolution (Vec2): Target renderer resolution as (width, height).
|
|
21
|
+
scaled (bool): When True, stretches to usable display bounds while maintaining aspect.
|
|
24
22
|
|
|
25
23
|
Raises:
|
|
26
|
-
RuntimeError: If a window already exists or window creation fails.
|
|
27
|
-
ValueError: If title is
|
|
24
|
+
RuntimeError: If a window already exists or SDL window creation fails.
|
|
25
|
+
ValueError: If the title is invalid or any dimension is non-positive.
|
|
28
26
|
"""
|
|
29
27
|
def get_scale() -> int:
|
|
30
28
|
"""
|
|
@@ -68,7 +66,7 @@ def is_fullscreen() -> bool:
|
|
|
68
66
|
"""
|
|
69
67
|
def is_open() -> bool:
|
|
70
68
|
"""
|
|
71
|
-
|
|
69
|
+
Report whether the window is currently open.
|
|
72
70
|
|
|
73
71
|
Returns:
|
|
74
72
|
bool: True if the window is open and active.
|
|
@@ -79,6 +77,9 @@ def save_screenshot(path: str) -> None:
|
|
|
79
77
|
|
|
80
78
|
Args:
|
|
81
79
|
path (str): The path to save the screenshot to.
|
|
80
|
+
|
|
81
|
+
Raises:
|
|
82
|
+
RuntimeError: If the window is not initialized or the screenshot cannot be saved.
|
|
82
83
|
"""
|
|
83
84
|
def set_fullscreen(fullscreen: bool) -> None:
|
|
84
85
|
"""
|
|
Binary file
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
from pydantic import BaseModel
|
|
2
|
+
import struct
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class ShaderUniform(BaseModel):
|
|
6
|
+
"""Base model for shader uniform data structures.
|
|
7
|
+
|
|
8
|
+
Subclass this to describe your shader's uniform layout. Instances can be
|
|
9
|
+
converted to bytes for uploads through ``ShaderState.set_uniform()``. Field
|
|
10
|
+
values are packed according to their types: ``float`` values use the ``f``
|
|
11
|
+
format, ``int`` values use ``i``, ``bool`` values use ``?``, and tuples or
|
|
12
|
+
lists of two to four floats are packed as vector components.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def to_bytes(self) -> bytes:
|
|
16
|
+
"""Serialize the uniform data into a packed binary format.
|
|
17
|
+
|
|
18
|
+
The packing order follows the model's field order, and Python's ``struct``
|
|
19
|
+
module determines the byte layout based on field types.
|
|
20
|
+
|
|
21
|
+
Returns:
|
|
22
|
+
bytes: Packed binary representation of the uniform data.
|
|
23
|
+
|
|
24
|
+
Raises:
|
|
25
|
+
ValueError: If a tuple or list field does not contain 2, 3, or 4 values.
|
|
26
|
+
TypeError: If a field uses an unsupported type.
|
|
27
|
+
"""
|
|
28
|
+
fmt = ""
|
|
29
|
+
values = []
|
|
30
|
+
|
|
31
|
+
for name, value in self.model_dump().items():
|
|
32
|
+
if isinstance(value, float):
|
|
33
|
+
fmt += "f"; values.append(value)
|
|
34
|
+
elif isinstance(value, int):
|
|
35
|
+
fmt += "i"; values.append(value)
|
|
36
|
+
elif isinstance(value, bool):
|
|
37
|
+
fmt += "?"; values.append(value)
|
|
38
|
+
elif isinstance(value, (tuple, list)):
|
|
39
|
+
n = len(value)
|
|
40
|
+
if n not in (2, 3, 4):
|
|
41
|
+
raise ValueError(f"Field '{name}' length {n} invalid, must be 2, 3, or 4.")
|
|
42
|
+
fmt += f"{n}f"
|
|
43
|
+
values.extend(map(float, value))
|
|
44
|
+
else:
|
|
45
|
+
raise TypeError(f"Unsupported uniform field '{name}' of type '{type(value)}'")
|
|
46
|
+
|
|
47
|
+
return struct.pack(fmt, *values)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import inspect
|
|
3
|
+
import pydantic._internal._decorators
|
|
4
|
+
import pydantic.main
|
|
5
|
+
from pydantic.main import BaseModel
|
|
6
|
+
import pydantic_core._pydantic_core
|
|
7
|
+
import struct as struct
|
|
8
|
+
import typing
|
|
9
|
+
__all__: list[str] = ['BaseModel', 'ShaderUniform', 'struct']
|
|
10
|
+
class ShaderUniform(pydantic.main.BaseModel):
|
|
11
|
+
"""
|
|
12
|
+
Base model for shader uniform data structures.
|
|
13
|
+
|
|
14
|
+
Subclass this to describe your shader's uniform layout. Instances can be
|
|
15
|
+
converted to bytes for uploads through ``ShaderState.set_uniform()``. Field
|
|
16
|
+
values are packed according to their types: ``float`` values use the ``f``
|
|
17
|
+
format, ``int`` values use ``i``, ``bool`` values use ``?``, and tuples or
|
|
18
|
+
lists of two to four floats are packed as vector components.
|
|
19
|
+
"""
|
|
20
|
+
__abstractmethods__: typing.ClassVar[frozenset] # value = frozenset()
|
|
21
|
+
__class_vars__: typing.ClassVar[set] = set()
|
|
22
|
+
__private_attributes__: typing.ClassVar[dict] = {}
|
|
23
|
+
__pydantic_complete__: typing.ClassVar[bool] = True
|
|
24
|
+
__pydantic_computed_fields__: typing.ClassVar[dict] = {}
|
|
25
|
+
__pydantic_core_schema__: typing.ClassVar[dict] = {'type': 'model', 'cls': ShaderUniform, 'schema': {'type': 'model-fields', 'fields': {}, 'model_name': 'ShaderUniform', 'computed_fields': list()}, 'custom_init': False, 'root_model': False, 'config': {'title': 'ShaderUniform'}, 'ref': 'pykraken.shader_uniform.ShaderUniform:1434400820944', 'metadata': {'pydantic_js_functions': [pydantic.main.BaseModel.__get_pydantic_json_schema__]}}
|
|
26
|
+
__pydantic_custom_init__: typing.ClassVar[bool] = False
|
|
27
|
+
__pydantic_decorators__: typing.ClassVar[pydantic._internal._decorators.DecoratorInfos] # value = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})
|
|
28
|
+
__pydantic_fields__: typing.ClassVar[dict] = {}
|
|
29
|
+
__pydantic_generic_metadata__: typing.ClassVar[dict] = {'origin': None, 'args': tuple(), 'parameters': tuple()}
|
|
30
|
+
__pydantic_parent_namespace__ = None
|
|
31
|
+
__pydantic_post_init__ = None
|
|
32
|
+
__pydantic_serializer__: typing.ClassVar[pydantic_core._pydantic_core.SchemaSerializer] # value = SchemaSerializer(serializer=Model(...
|
|
33
|
+
__pydantic_setattr_handlers__: typing.ClassVar[dict] = {}
|
|
34
|
+
__pydantic_validator__: typing.ClassVar[pydantic_core._pydantic_core.SchemaValidator] # value = SchemaValidator(title="ShaderUniform", validator=Model(...
|
|
35
|
+
__signature__: typing.ClassVar[inspect.Signature] # value = <Signature () -> None>
|
|
36
|
+
_abc_impl: typing.ClassVar[_abc._abc_data] # value = <_abc._abc_data object>
|
|
37
|
+
model_config: typing.ClassVar[dict] = {}
|
|
38
|
+
def to_bytes(self) -> bytes:
|
|
39
|
+
"""
|
|
40
|
+
Serialize the uniform data into a packed binary format.
|
|
41
|
+
|
|
42
|
+
The packing order follows the model's field order, and Python's ``struct``
|
|
43
|
+
module determines the byte layout based on field types.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
bytes: Packed binary representation of the uniform data.
|
|
47
|
+
|
|
48
|
+
Raises:
|
|
49
|
+
ValueError: If a tuple or list field does not contain 2, 3, or 4 values.
|
|
50
|
+
TypeError: If a field uses an unsupported type.
|
|
51
|
+
"""
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
pykraken/__init__.pyi,sha256=65hwZTYHpcl2SHro0SSd-qwfrQms3yFaBM7i33z-gB0,27931
|
|
2
|
-
pykraken/__init__.py,sha256=0zpBfzO64sy3FMVSKxe4TzTdDEXGpDaPHgG23YWlvts,21
|
|
3
|
-
pykraken/_core.cpython-311-darwin.so,sha256=19eZwynuhjeDiV1WtlTpyXwfIf3VsVTL-gkEPCf7upM,6009096
|
|
4
|
-
pykraken/__pyinstaller/hook-pykraken.py,sha256=g7IX7uKjsqfzHgXctHGbUiC2Ssy6XV3wg_HMNgxxnNg,356
|
|
5
|
-
pykraken/_core/color.pyi,sha256=wKo4Z6uxTUvZQ2d8XGn7Uumk_oW4G8rbRGotMoBUzbw,4574
|
|
6
|
-
pykraken/_core/window.pyi,sha256=mb09p7CBz1WGr7_dauwHiqbaQgT330dG3Jn69iuvT3M,3355
|
|
7
|
-
pykraken/_core/math.pyi,sha256=WFHYUamcz1ONwpnYJsKhUAiDMzD1r1PbEgsu3V4t6Og,5038
|
|
8
|
-
pykraken/_core/gamepad.pyi,sha256=q79k3FWYaHQ7okfxObm_gjPPwyyfLbGtGgIGGXGAgJA,3373
|
|
9
|
-
pykraken/_core/mouse.pyi,sha256=_mag12XmC9RmiI4NZvCd3vMfuKB0bofvtpPxPraL1Kw,2367
|
|
10
|
-
pykraken/_core/__init__.pyi,sha256=omfFsGgXh51bH3uRFrNEJOzHH_DzGD976e7qA9v0e9M,137998
|
|
11
|
-
pykraken/_core/line.pyi,sha256=eCwWYWWib9eeT65YlhB0ssju8Rfr8x6VRA7qMhKjQn4,321
|
|
12
|
-
pykraken/_core/input.pyi,sha256=1nTigN2f4PIU0IUgbtD8LztXFPZae4v4jZDvB9weyqA,2383
|
|
13
|
-
pykraken/_core/key.pyi,sha256=KZb4IwOVClFU56lNlJmjVULiW24HnluChlgg8QS80L0,1867
|
|
14
|
-
pykraken/_core/renderer.pyi,sha256=PIn9jf86r3vFKInxdH2hMPMRoq-czW5Q0ieRnerMgug,2252
|
|
15
|
-
pykraken/_core/time.pyi,sha256=sNn2XXsXPvDaocl17_epmpLjIXwcyvAD5Gy5W1-B72k,2548
|
|
16
|
-
pykraken/_core/event.pyi,sha256=3mbbHrG-02_EpQ9PUp8EqqHMp_p-LxTmJuKxjgtZeRY,386
|
|
17
|
-
pykraken/_core/rect.pyi,sha256=TUbtviTvFgCbjOJ4vCO1e0OF0B9IOt5L4ykgCNOwIKI,2772
|
|
18
|
-
pykraken/_core/ease.pyi,sha256=C9-I9vb1gL3OgIsmDOJc45aENNCEQBXqrobYsTj_FGE,6440
|
|
19
|
-
pykraken/_core/draw.pyi,sha256=8HzUGc35gzng61mJ0Zx6Tz7ymbAv-1143fqmkulHyO8,3738
|
|
20
|
-
pykraken/_core/transform.pyi,sha256=kgR_7iLo6fP1m4wMh5Ps07S-qMhH8lbWS5QKw89kA1A,5445
|
|
21
|
-
kraken_engine-1.0.0.dist-info/RECORD,,
|
|
22
|
-
kraken_engine-1.0.0.dist-info/WHEEL,sha256=4CYzI0otigkuiH5g2UotkgFRS-CesfbfVqGyA9q_pdY,141
|
|
23
|
-
kraken_engine-1.0.0.dist-info/METADATA,sha256=TtTfVjwIaqsaWegjXkH2ia63xZwO24LwHhIZAnFoD50,2066
|
|
24
|
-
kraken_engine-1.0.0.dist-info/licenses/LICENSE,sha256=4NUSEGSVvPUQ_2qD0hmmw_cOamv68n-TFiIpcIEK2eM,1094
|
|
File without changes
|
|
File without changes
|