kraken-engine 1.0.0__cp314-cp314-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.
Potentially problematic release.
This version of kraken-engine might be problematic. Click here for more details.
- kraken_engine-1.0.0.dist-info/METADATA +51 -0
- kraken_engine-1.0.0.dist-info/RECORD +24 -0
- kraken_engine-1.0.0.dist-info/WHEEL +6 -0
- kraken_engine-1.0.0.dist-info/licenses/LICENSE +21 -0
- pykraken/__init__.py +1 -0
- pykraken/__init__.pyi +406 -0
- pykraken/__pyinstaller/hook-pykraken.py +8 -0
- pykraken/_core/__init__.pyi +3576 -0
- pykraken/_core/color.pyi +113 -0
- pykraken/_core/draw.pyi +95 -0
- pykraken/_core/ease.pyi +285 -0
- pykraken/_core/event.pyi +15 -0
- pykraken/_core/gamepad.pyi +105 -0
- pykraken/_core/input.pyi +78 -0
- pykraken/_core/key.pyi +73 -0
- pykraken/_core/line.pyi +10 -0
- pykraken/_core/math.pyi +173 -0
- pykraken/_core/mouse.pyi +85 -0
- pykraken/_core/rect.pyi +93 -0
- pykraken/_core/renderer.pyi +63 -0
- pykraken/_core/time.pyi +75 -0
- pykraken/_core/transform.pyi +141 -0
- pykraken/_core/window.pyi +113 -0
- pykraken/_core.cpython-314-darwin.so +0 -0
pykraken/_core/color.pyi
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
Color utility functions and predefined color constants.
|
|
4
|
+
|
|
5
|
+
This module provides functions for color manipulation and conversion,
|
|
6
|
+
as well as commonly used color constants for convenience.
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
import pykraken._core
|
|
11
|
+
import typing
|
|
12
|
+
__all__: list[str] = ['BLACK', 'BLUE', 'BROWN', 'CYAN', 'DARK_GRAY', 'DARK_GREY', 'GRAY', 'GREEN', 'GREY', 'LIGHT_GRAY', 'LIGHT_GREY', 'MAGENTA', 'MAROON', 'NAVY', 'OLIVE', 'ORANGE', 'PINK', 'PURPLE', 'RED', 'TEAL', 'WHITE', 'YELLOW', 'from_hex', 'from_hsv', 'grayscale', 'invert', 'lerp']
|
|
13
|
+
def from_hex(hex: str) -> pykraken._core.Color:
|
|
14
|
+
"""
|
|
15
|
+
Create a Color from a hex string.
|
|
16
|
+
|
|
17
|
+
Supports multiple hex formats:
|
|
18
|
+
- "#RRGGBB" - 6-digit hex with full opacity
|
|
19
|
+
- "#RRGGBBAA" - 8-digit hex with alpha
|
|
20
|
+
- "#RGB" - 3-digit hex (each digit duplicated)
|
|
21
|
+
- "#RGBA" - 4-digit hex with alpha (each digit duplicated)
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
hex (str): Hex color string (with or without '#' prefix).
|
|
25
|
+
|
|
26
|
+
Returns:
|
|
27
|
+
Color: New Color object from the hex string.
|
|
28
|
+
|
|
29
|
+
Examples:
|
|
30
|
+
from_hex("#FF00FF") # Magenta, full opacity
|
|
31
|
+
from_hex("#FF00FF80") # Magenta, 50% opacity
|
|
32
|
+
from_hex("#F0F") # Same as "#FF00FF"
|
|
33
|
+
from_hex("RGB") # Without '#' prefix
|
|
34
|
+
"""
|
|
35
|
+
def from_hsv(h: typing.SupportsFloat, s: typing.SupportsFloat, v: typing.SupportsFloat, a: typing.SupportsFloat = 1.0) -> pykraken._core.Color:
|
|
36
|
+
"""
|
|
37
|
+
Create a Color from HSV(A) values.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
h (float): Hue angle (0-360).
|
|
41
|
+
s (float): Saturation (0-1).
|
|
42
|
+
v (float): Value/brightness (0-1).
|
|
43
|
+
a (float, optional): Alpha (0-1). Defaults to 1.0.
|
|
44
|
+
"""
|
|
45
|
+
def grayscale(color: pykraken._core.Color) -> pykraken._core.Color:
|
|
46
|
+
"""
|
|
47
|
+
Convert a color to grayscale.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
color (Color): The color to convert.
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
Color: New Color object representing the grayscale version.
|
|
54
|
+
|
|
55
|
+
Example:
|
|
56
|
+
grayscale(Color(255, 0, 0)) # Returns Color(76, 76, 76, 255)
|
|
57
|
+
"""
|
|
58
|
+
def invert(color: pykraken._core.Color) -> pykraken._core.Color:
|
|
59
|
+
"""
|
|
60
|
+
Return the inverse of a color by flipping RGB channels.
|
|
61
|
+
|
|
62
|
+
The alpha channel is preserved unchanged.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
color (Color): The color to invert.
|
|
66
|
+
|
|
67
|
+
Returns:
|
|
68
|
+
Color: New Color with inverted RGB values (255 - original value).
|
|
69
|
+
|
|
70
|
+
Example:
|
|
71
|
+
invert(Color(255, 0, 128, 200)) # Returns Color(0, 255, 127, 200)
|
|
72
|
+
"""
|
|
73
|
+
def lerp(a: pykraken._core.Color, b: pykraken._core.Color, t: typing.SupportsFloat) -> pykraken._core.Color:
|
|
74
|
+
"""
|
|
75
|
+
Linearly interpolate between two colors.
|
|
76
|
+
|
|
77
|
+
Performs component-wise linear interpolation between start and end colors.
|
|
78
|
+
All RGBA channels are interpolated independently.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
a (Color): Start color (when t=0.0).
|
|
82
|
+
b (Color): End color (when t=1.0).
|
|
83
|
+
t (float): Blend factor. Values outside [0,1] will extrapolate.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
Color: New interpolated color.
|
|
87
|
+
|
|
88
|
+
Examples:
|
|
89
|
+
lerp(Color.RED, Color.BLUE, 0.5) # Purple (halfway between red and blue)
|
|
90
|
+
lerp(Color.BLACK, Color.WHITE, 0.25) # Dark gray
|
|
91
|
+
"""
|
|
92
|
+
BLACK: pykraken._core.Color # value = Color(0, 0, 0, 255)
|
|
93
|
+
BLUE: pykraken._core.Color # value = Color(0, 0, 255, 255)
|
|
94
|
+
BROWN: pykraken._core.Color # value = Color(139, 69, 19, 255)
|
|
95
|
+
CYAN: pykraken._core.Color # value = Color(0, 255, 255, 255)
|
|
96
|
+
DARK_GRAY: pykraken._core.Color # value = Color(64, 64, 64, 255)
|
|
97
|
+
DARK_GREY: pykraken._core.Color # value = Color(64, 64, 64, 255)
|
|
98
|
+
GRAY: pykraken._core.Color # value = Color(128, 128, 128, 255)
|
|
99
|
+
GREEN: pykraken._core.Color # value = Color(0, 255, 0, 255)
|
|
100
|
+
GREY: pykraken._core.Color # value = Color(128, 128, 128, 255)
|
|
101
|
+
LIGHT_GRAY: pykraken._core.Color # value = Color(192, 192, 192, 255)
|
|
102
|
+
LIGHT_GREY: pykraken._core.Color # value = Color(192, 192, 192, 255)
|
|
103
|
+
MAGENTA: pykraken._core.Color # value = Color(255, 0, 255, 255)
|
|
104
|
+
MAROON: pykraken._core.Color # value = Color(128, 0, 0, 255)
|
|
105
|
+
NAVY: pykraken._core.Color # value = Color(0, 0, 128, 255)
|
|
106
|
+
OLIVE: pykraken._core.Color # value = Color(128, 128, 0, 255)
|
|
107
|
+
ORANGE: pykraken._core.Color # value = Color(255, 165, 0, 255)
|
|
108
|
+
PINK: pykraken._core.Color # value = Color(255, 192, 203, 255)
|
|
109
|
+
PURPLE: pykraken._core.Color # value = Color(128, 0, 128, 255)
|
|
110
|
+
RED: pykraken._core.Color # value = Color(255, 0, 0, 255)
|
|
111
|
+
TEAL: pykraken._core.Color # value = Color(0, 128, 128, 255)
|
|
112
|
+
WHITE: pykraken._core.Color # value = Color(255, 255, 255, 255)
|
|
113
|
+
YELLOW: pykraken._core.Color # value = Color(255, 255, 0, 255)
|
pykraken/_core/draw.pyi
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Functions for drawing shape objects
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
import collections.abc
|
|
6
|
+
import numpy
|
|
7
|
+
import numpy.typing
|
|
8
|
+
import pykraken._core
|
|
9
|
+
import typing
|
|
10
|
+
__all__: list[str] = ['circle', 'line', 'point', 'points', 'points_from_ndarray', 'polygon', 'rect', 'rects']
|
|
11
|
+
def circle(circle: pykraken._core.Circle, color: pykraken._core.Color, thickness: typing.SupportsInt = 0) -> None:
|
|
12
|
+
"""
|
|
13
|
+
Draw a circle to the renderer.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
circle (Circle): The circle to draw.
|
|
17
|
+
color (Color): The color of the circle.
|
|
18
|
+
thickness (int, optional): The line thickness. If 0 or >= radius, draws filled circle.
|
|
19
|
+
Defaults to 0 (filled).
|
|
20
|
+
"""
|
|
21
|
+
def line(line: pykraken._core.Line, color: pykraken._core.Color, thickness: typing.SupportsInt = 1) -> None:
|
|
22
|
+
"""
|
|
23
|
+
Draw a line to the renderer.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
line (Line): The line to draw.
|
|
27
|
+
color (Color): The color of the line.
|
|
28
|
+
thickness (int, optional): The line thickness in pixels. Defaults to 1.
|
|
29
|
+
"""
|
|
30
|
+
def point(point: pykraken._core.Vec2, color: pykraken._core.Color) -> None:
|
|
31
|
+
"""
|
|
32
|
+
Draw a single point to the renderer.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
point (Vec2): The position of the point.
|
|
36
|
+
color (Color): The color of the point.
|
|
37
|
+
|
|
38
|
+
Raises:
|
|
39
|
+
RuntimeError: If point rendering fails.
|
|
40
|
+
"""
|
|
41
|
+
def points(points: collections.abc.Sequence[pykraken._core.Vec2], color: pykraken._core.Color) -> None:
|
|
42
|
+
"""
|
|
43
|
+
Batch draw an array of points to the renderer.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
points (Sequence[Vec2]): The points to batch draw.
|
|
47
|
+
color (Color): The color of the points.
|
|
48
|
+
|
|
49
|
+
Raises:
|
|
50
|
+
RuntimeError: If point rendering fails.
|
|
51
|
+
"""
|
|
52
|
+
def points_from_ndarray(points: typing.Annotated[numpy.typing.ArrayLike, numpy.float64], color: pykraken._core.Color) -> None:
|
|
53
|
+
"""
|
|
54
|
+
Batch draw points from a NumPy array.
|
|
55
|
+
|
|
56
|
+
This fast path accepts a contiguous NumPy array of shape (N,2) (dtype float64) and
|
|
57
|
+
reads coordinates directly with minimal overhead. Use this to measure the best-case
|
|
58
|
+
zero-copy/buffer-backed path.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
points (numpy.ndarray): Array with shape (N,2) containing x,y coordinates.
|
|
62
|
+
color (Color): The color of the points.
|
|
63
|
+
|
|
64
|
+
Raises:
|
|
65
|
+
ValueError: If the array shape is not (N,2).
|
|
66
|
+
RuntimeError: If point rendering fails.
|
|
67
|
+
"""
|
|
68
|
+
def polygon(polygon: pykraken._core.Polygon, color: pykraken._core.Color, filled: bool = False) -> None:
|
|
69
|
+
"""
|
|
70
|
+
Draw a polygon to the renderer.
|
|
71
|
+
|
|
72
|
+
Args:
|
|
73
|
+
polygon (Polygon): The polygon to draw.
|
|
74
|
+
color (Color): The color of the polygon.
|
|
75
|
+
filled (bool, optional): Whether to draw a filled polygon or just the outline.
|
|
76
|
+
Defaults to False (outline). Works with both convex and concave polygons.
|
|
77
|
+
"""
|
|
78
|
+
def rect(rect: pykraken._core.Rect, color: pykraken._core.Color, thickness: typing.SupportsInt = 0) -> None:
|
|
79
|
+
"""
|
|
80
|
+
Draw a rectangle to the renderer.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
rect (Rect): The rectangle to draw.
|
|
84
|
+
color (Color): The color of the rectangle.
|
|
85
|
+
thickness (int, optional): The border thickness. If 0 or >= half width/height, draws filled rectangle. Defaults to 0 (filled).
|
|
86
|
+
"""
|
|
87
|
+
def rects(rects: collections.abc.Sequence[pykraken._core.Rect], color: pykraken._core.Color, thickness: typing.SupportsInt = 0) -> None:
|
|
88
|
+
"""
|
|
89
|
+
Batch draw an array of rectangles to the renderer.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
rects (Sequence[Rect]): The rectangles to batch draw.
|
|
93
|
+
color (Color): The color of the rectangles.
|
|
94
|
+
thickness (int, optional): The border thickness of the rectangles. If 0 or >= half width/height, draws filled rectangles. Defaults to 0 (filled).
|
|
95
|
+
"""
|
pykraken/_core/ease.pyi
ADDED
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Easing functions and animation utilities
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
import typing
|
|
6
|
+
__all__: list[str] = ['in_back', 'in_bounce', 'in_circ', 'in_cubic', 'in_elastic', 'in_expo', 'in_out_back', 'in_out_bounce', 'in_out_circ', 'in_out_cubic', 'in_out_elastic', 'in_out_expo', 'in_out_quad', 'in_out_quart', 'in_out_quint', 'in_out_sin', 'in_quad', 'in_quart', 'in_quint', 'in_sin', 'linear', 'out_back', 'out_bounce', 'out_circ', 'out_cubic', 'out_elastic', 'out_expo', 'out_quad', 'out_quart', 'out_quint', 'out_sin']
|
|
7
|
+
def in_back(t: typing.SupportsFloat) -> float:
|
|
8
|
+
"""
|
|
9
|
+
Back easing in (overshoot at start).
|
|
10
|
+
|
|
11
|
+
Args:
|
|
12
|
+
t (float): Normalized time.
|
|
13
|
+
Returns:
|
|
14
|
+
float: Eased result.
|
|
15
|
+
"""
|
|
16
|
+
def in_bounce(t: typing.SupportsFloat) -> float:
|
|
17
|
+
"""
|
|
18
|
+
Bounce easing in (bounces toward target).
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
t (float): Normalized time.
|
|
22
|
+
Returns:
|
|
23
|
+
float: Eased result.
|
|
24
|
+
"""
|
|
25
|
+
def in_circ(t: typing.SupportsFloat) -> float:
|
|
26
|
+
"""
|
|
27
|
+
Circular easing in.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
t (float): Normalized time.
|
|
31
|
+
Returns:
|
|
32
|
+
float: Eased result.
|
|
33
|
+
"""
|
|
34
|
+
def in_cubic(t: typing.SupportsFloat) -> float:
|
|
35
|
+
"""
|
|
36
|
+
Cubic easing in (very slow start).
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
t (float): Normalized time.
|
|
40
|
+
Returns:
|
|
41
|
+
float: Eased result.
|
|
42
|
+
"""
|
|
43
|
+
def in_elastic(t: typing.SupportsFloat) -> float:
|
|
44
|
+
"""
|
|
45
|
+
Elastic easing in (springy start).
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
t (float): Normalized time.
|
|
49
|
+
Returns:
|
|
50
|
+
float: Eased result.
|
|
51
|
+
"""
|
|
52
|
+
def in_expo(t: typing.SupportsFloat) -> float:
|
|
53
|
+
"""
|
|
54
|
+
Exponential easing in.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
t (float): Normalized time.
|
|
58
|
+
Returns:
|
|
59
|
+
float: Eased result.
|
|
60
|
+
"""
|
|
61
|
+
def in_out_back(t: typing.SupportsFloat) -> float:
|
|
62
|
+
"""
|
|
63
|
+
Back easing in and out.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
t (float): Normalized time.
|
|
67
|
+
Returns:
|
|
68
|
+
float: Eased result.
|
|
69
|
+
"""
|
|
70
|
+
def in_out_bounce(t: typing.SupportsFloat) -> float:
|
|
71
|
+
"""
|
|
72
|
+
Bounce easing in and out.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
t (float): Normalized time.
|
|
76
|
+
Returns:
|
|
77
|
+
float: Eased result.
|
|
78
|
+
"""
|
|
79
|
+
def in_out_circ(t: typing.SupportsFloat) -> float:
|
|
80
|
+
"""
|
|
81
|
+
Circular easing in and out.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
t (float): Normalized time.
|
|
85
|
+
Returns:
|
|
86
|
+
float: Eased result.
|
|
87
|
+
"""
|
|
88
|
+
def in_out_cubic(t: typing.SupportsFloat) -> float:
|
|
89
|
+
"""
|
|
90
|
+
Cubic easing in and out.
|
|
91
|
+
|
|
92
|
+
Args:
|
|
93
|
+
t (float): Normalized time.
|
|
94
|
+
Returns:
|
|
95
|
+
float: Eased result.
|
|
96
|
+
"""
|
|
97
|
+
def in_out_elastic(t: typing.SupportsFloat) -> float:
|
|
98
|
+
"""
|
|
99
|
+
Elastic easing in and out.
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
t (float): Normalized time.
|
|
103
|
+
Returns:
|
|
104
|
+
float: Eased result.
|
|
105
|
+
"""
|
|
106
|
+
def in_out_expo(t: typing.SupportsFloat) -> float:
|
|
107
|
+
"""
|
|
108
|
+
Exponential easing in and out.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
t (float): Normalized time.
|
|
112
|
+
Returns:
|
|
113
|
+
float: Eased result.
|
|
114
|
+
"""
|
|
115
|
+
def in_out_quad(t: typing.SupportsFloat) -> float:
|
|
116
|
+
"""
|
|
117
|
+
Quadratic easing in and out.
|
|
118
|
+
|
|
119
|
+
Args:
|
|
120
|
+
t (float): Normalized time.
|
|
121
|
+
Returns:
|
|
122
|
+
float: Eased result.
|
|
123
|
+
"""
|
|
124
|
+
def in_out_quart(t: typing.SupportsFloat) -> float:
|
|
125
|
+
"""
|
|
126
|
+
Quartic easing in and out.
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
t (float): Normalized time.
|
|
130
|
+
Returns:
|
|
131
|
+
float: Eased result.
|
|
132
|
+
"""
|
|
133
|
+
def in_out_quint(t: typing.SupportsFloat) -> float:
|
|
134
|
+
"""
|
|
135
|
+
Quintic easing in and out.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
t (float): Normalized time.
|
|
139
|
+
Returns:
|
|
140
|
+
float: Eased result.
|
|
141
|
+
"""
|
|
142
|
+
def in_out_sin(t: typing.SupportsFloat) -> float:
|
|
143
|
+
"""
|
|
144
|
+
Sinusoidal easing in and out.
|
|
145
|
+
|
|
146
|
+
Args:
|
|
147
|
+
t (float): Normalized time.
|
|
148
|
+
Returns:
|
|
149
|
+
float: Eased result.
|
|
150
|
+
"""
|
|
151
|
+
def in_quad(t: typing.SupportsFloat) -> float:
|
|
152
|
+
"""
|
|
153
|
+
Quadratic easing in (slow start).
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
t (float): Normalized time.
|
|
157
|
+
Returns:
|
|
158
|
+
float: Eased result.
|
|
159
|
+
"""
|
|
160
|
+
def in_quart(t: typing.SupportsFloat) -> float:
|
|
161
|
+
"""
|
|
162
|
+
Quartic easing in.
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
t (float): Normalized time.
|
|
166
|
+
Returns:
|
|
167
|
+
float: Eased result.
|
|
168
|
+
"""
|
|
169
|
+
def in_quint(t: typing.SupportsFloat) -> float:
|
|
170
|
+
"""
|
|
171
|
+
Quintic easing in.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
t (float): Normalized time.
|
|
175
|
+
Returns:
|
|
176
|
+
float: Eased result.
|
|
177
|
+
"""
|
|
178
|
+
def in_sin(t: typing.SupportsFloat) -> float:
|
|
179
|
+
"""
|
|
180
|
+
Sinusoidal easing in.
|
|
181
|
+
|
|
182
|
+
Args:
|
|
183
|
+
t (float): Normalized time.
|
|
184
|
+
Returns:
|
|
185
|
+
float: Eased result.
|
|
186
|
+
"""
|
|
187
|
+
def linear(t: typing.SupportsFloat) -> float:
|
|
188
|
+
"""
|
|
189
|
+
Linear easing.
|
|
190
|
+
|
|
191
|
+
Args:
|
|
192
|
+
t (float): Normalized time (0.0 to 1.0).
|
|
193
|
+
Returns:
|
|
194
|
+
float: Eased result.
|
|
195
|
+
"""
|
|
196
|
+
def out_back(t: typing.SupportsFloat) -> float:
|
|
197
|
+
"""
|
|
198
|
+
Back easing out (overshoot at end).
|
|
199
|
+
|
|
200
|
+
Args:
|
|
201
|
+
t (float): Normalized time.
|
|
202
|
+
Returns:
|
|
203
|
+
float: Eased result.
|
|
204
|
+
"""
|
|
205
|
+
def out_bounce(t: typing.SupportsFloat) -> float:
|
|
206
|
+
"""
|
|
207
|
+
Bounce easing out (bounces after start).
|
|
208
|
+
|
|
209
|
+
Args:
|
|
210
|
+
t (float): Normalized time.
|
|
211
|
+
Returns:
|
|
212
|
+
float: Eased result.
|
|
213
|
+
"""
|
|
214
|
+
def out_circ(t: typing.SupportsFloat) -> float:
|
|
215
|
+
"""
|
|
216
|
+
Circular easing out.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
t (float): Normalized time.
|
|
220
|
+
Returns:
|
|
221
|
+
float: Eased result.
|
|
222
|
+
"""
|
|
223
|
+
def out_cubic(t: typing.SupportsFloat) -> float:
|
|
224
|
+
"""
|
|
225
|
+
Cubic easing out (fast then smooth).
|
|
226
|
+
|
|
227
|
+
Args:
|
|
228
|
+
t (float): Normalized time.
|
|
229
|
+
Returns:
|
|
230
|
+
float: Eased result.
|
|
231
|
+
"""
|
|
232
|
+
def out_elastic(t: typing.SupportsFloat) -> float:
|
|
233
|
+
"""
|
|
234
|
+
Elastic easing out (springy end).
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
t (float): Normalized time.
|
|
238
|
+
Returns:
|
|
239
|
+
float: Eased result.
|
|
240
|
+
"""
|
|
241
|
+
def out_expo(t: typing.SupportsFloat) -> float:
|
|
242
|
+
"""
|
|
243
|
+
Exponential easing out.
|
|
244
|
+
|
|
245
|
+
Args:
|
|
246
|
+
t (float): Normalized time.
|
|
247
|
+
Returns:
|
|
248
|
+
float: Eased result.
|
|
249
|
+
"""
|
|
250
|
+
def out_quad(t: typing.SupportsFloat) -> float:
|
|
251
|
+
"""
|
|
252
|
+
Quadratic easing out (fast start).
|
|
253
|
+
|
|
254
|
+
Args:
|
|
255
|
+
t (float): Normalized time.
|
|
256
|
+
Returns:
|
|
257
|
+
float: Eased result.
|
|
258
|
+
"""
|
|
259
|
+
def out_quart(t: typing.SupportsFloat) -> float:
|
|
260
|
+
"""
|
|
261
|
+
Quartic easing out.
|
|
262
|
+
|
|
263
|
+
Args:
|
|
264
|
+
t (float): Normalized time.
|
|
265
|
+
Returns:
|
|
266
|
+
float: Eased result.
|
|
267
|
+
"""
|
|
268
|
+
def out_quint(t: typing.SupportsFloat) -> float:
|
|
269
|
+
"""
|
|
270
|
+
Quintic easing out.
|
|
271
|
+
|
|
272
|
+
Args:
|
|
273
|
+
t (float): Normalized time.
|
|
274
|
+
Returns:
|
|
275
|
+
float: Eased result.
|
|
276
|
+
"""
|
|
277
|
+
def out_sin(t: typing.SupportsFloat) -> float:
|
|
278
|
+
"""
|
|
279
|
+
Sinusoidal easing out.
|
|
280
|
+
|
|
281
|
+
Args:
|
|
282
|
+
t (float): Normalized time.
|
|
283
|
+
Returns:
|
|
284
|
+
float: Eased result.
|
|
285
|
+
"""
|
pykraken/_core/event.pyi
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Input event handling
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
import pykraken._core
|
|
6
|
+
__all__: list[str] = ['poll']
|
|
7
|
+
def poll() -> list[pykraken._core.Event]:
|
|
8
|
+
"""
|
|
9
|
+
Poll for all pending user input events.
|
|
10
|
+
|
|
11
|
+
This clears input states and returns a list of events that occurred since the last call.
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
list[Event]: A list of input event objects.
|
|
15
|
+
"""
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Gamepad input handling functions
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
import pykraken._core
|
|
6
|
+
import typing
|
|
7
|
+
__all__: list[str] = ['get_connected_slots', 'get_deadzone', 'get_left_stick', 'get_left_trigger', 'get_right_stick', 'get_right_trigger', 'is_just_pressed', 'is_just_released', 'is_pressed', 'set_deadzone']
|
|
8
|
+
def get_connected_slots() -> list[int]:
|
|
9
|
+
"""
|
|
10
|
+
Get a list of connected gamepad slot indices.
|
|
11
|
+
|
|
12
|
+
Returns:
|
|
13
|
+
list[int]: A list of slot IDs with active gamepads.
|
|
14
|
+
"""
|
|
15
|
+
def get_deadzone(slot: typing.SupportsInt = 0) -> float:
|
|
16
|
+
"""
|
|
17
|
+
Get the current dead zone value for a gamepad's analog sticks.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
slot (int, optional): Gamepad slot ID (default is 0).
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
float: Deadzone threshold.
|
|
24
|
+
"""
|
|
25
|
+
def get_left_stick(slot: typing.SupportsInt = 0) -> pykraken._core.Vec2:
|
|
26
|
+
"""
|
|
27
|
+
Get the left analog stick position.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
slot (int, optional): Gamepad slot ID (default is 0).
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
Vec2: A vector of stick input normalized to [-1, 1], or (0, 0) if inside dead zone.
|
|
34
|
+
"""
|
|
35
|
+
def get_left_trigger(slot: typing.SupportsInt = 0) -> float:
|
|
36
|
+
"""
|
|
37
|
+
Get the left trigger's current pressure value.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
slot (int, optional): Gamepad slot ID (default is 0).
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
float: Trigger value in range [0.0, 1.0].
|
|
44
|
+
"""
|
|
45
|
+
def get_right_stick(slot: typing.SupportsInt = 0) -> pykraken._core.Vec2:
|
|
46
|
+
"""
|
|
47
|
+
Get the right analog stick position.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
slot (int, optional): Gamepad slot ID (default is 0).
|
|
51
|
+
|
|
52
|
+
Returns:
|
|
53
|
+
Vec2: A vector of stick input normalized to [-1, 1], or (0, 0) if inside dead zone.
|
|
54
|
+
"""
|
|
55
|
+
def get_right_trigger(slot: typing.SupportsInt = 0) -> float:
|
|
56
|
+
"""
|
|
57
|
+
Get the right trigger's current pressure value.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
slot (int, optional): Gamepad slot ID (default is 0).
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
float: Trigger value in range [0.0, 1.0].
|
|
64
|
+
"""
|
|
65
|
+
def is_just_pressed(button: pykraken._core.GamepadButton, slot: typing.SupportsInt = 0) -> bool:
|
|
66
|
+
"""
|
|
67
|
+
Check if a gamepad button was pressed during this frame.
|
|
68
|
+
|
|
69
|
+
Args:
|
|
70
|
+
button (GamepadButton): The button code.
|
|
71
|
+
slot (int, optional): Gamepad slot ID (default is 0).
|
|
72
|
+
|
|
73
|
+
Returns:
|
|
74
|
+
bool: True if the button was just pressed.
|
|
75
|
+
"""
|
|
76
|
+
def is_just_released(button: pykraken._core.GamepadButton, slot: typing.SupportsInt = 0) -> bool:
|
|
77
|
+
"""
|
|
78
|
+
Check if a gamepad button was released during this frame.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
button (GamepadButton): The button code.
|
|
82
|
+
slot (int, optional): Gamepad slot ID (default is 0).
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
bool: True if the button was just released.
|
|
86
|
+
"""
|
|
87
|
+
def is_pressed(button: pykraken._core.GamepadButton, slot: typing.SupportsInt = 0) -> bool:
|
|
88
|
+
"""
|
|
89
|
+
Check if a gamepad button is currently being held down.
|
|
90
|
+
|
|
91
|
+
Args:
|
|
92
|
+
button (GamepadButton): The button code.
|
|
93
|
+
slot (int, optional): Gamepad slot ID (default is 0).
|
|
94
|
+
|
|
95
|
+
Returns:
|
|
96
|
+
bool: True if the button is pressed.
|
|
97
|
+
"""
|
|
98
|
+
def set_deadzone(deadzone: typing.SupportsFloat, slot: typing.SupportsInt = 0) -> None:
|
|
99
|
+
"""
|
|
100
|
+
Set the dead zone threshold for a gamepad's analog sticks.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
deadzone (float): Value from 0.0 to 1.0 where movement is ignored.
|
|
104
|
+
slot (int, optional): Gamepad slot ID (default is 0).
|
|
105
|
+
"""
|
pykraken/_core/input.pyi
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Input handling and action binding
|
|
3
|
+
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
import collections.abc
|
|
6
|
+
import pykraken._core
|
|
7
|
+
__all__: list[str] = ['bind', 'get_axis', 'get_direction', 'is_just_pressed', 'is_just_released', 'is_pressed', 'unbind']
|
|
8
|
+
def bind(name: str, actions: collections.abc.Sequence[pykraken._core.InputAction]) -> None:
|
|
9
|
+
"""
|
|
10
|
+
Bind a name to a list of InputActions.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
name (str): The identifier for this binding (e.g. "jump").
|
|
14
|
+
actions (list[InputAction]): One or more InputActions to bind.
|
|
15
|
+
"""
|
|
16
|
+
def get_axis(negative: str, positive: str) -> float:
|
|
17
|
+
"""
|
|
18
|
+
Get a 1D axis value based on two opposing input actions.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
negative (str): Name of the negative direction action (e.g. "left").
|
|
22
|
+
positive (str): Name of the positive direction action (e.g. "right").
|
|
23
|
+
|
|
24
|
+
Returns:
|
|
25
|
+
float: Value in range [-1.0, 1.0] based on input.
|
|
26
|
+
"""
|
|
27
|
+
def get_direction(up: str, right: str, down: str, left: str) -> pykraken._core.Vec2:
|
|
28
|
+
"""
|
|
29
|
+
Get a directional vector based on named input actions.
|
|
30
|
+
|
|
31
|
+
This is typically used for WASD-style or D-pad movement.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
up (str): Name of action for upward movement.
|
|
35
|
+
right (str): Name of action for rightward movement.
|
|
36
|
+
down (str): Name of action for downward movement.
|
|
37
|
+
left (str): Name of action for leftward movement.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
Vec2: A normalized vector representing the intended direction.
|
|
41
|
+
"""
|
|
42
|
+
def is_just_pressed(name: str) -> bool:
|
|
43
|
+
"""
|
|
44
|
+
Check if the given action was just pressed this frame.
|
|
45
|
+
|
|
46
|
+
Args:
|
|
47
|
+
name (str): The name of the bound input.
|
|
48
|
+
|
|
49
|
+
Returns:
|
|
50
|
+
bool: True if pressed this frame only.
|
|
51
|
+
"""
|
|
52
|
+
def is_just_released(name: str) -> bool:
|
|
53
|
+
"""
|
|
54
|
+
Check if the given action was just released this frame.
|
|
55
|
+
|
|
56
|
+
Args:
|
|
57
|
+
name (str): The name of the bound input.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
bool: True if released this frame only.
|
|
61
|
+
"""
|
|
62
|
+
def is_pressed(name: str) -> bool:
|
|
63
|
+
"""
|
|
64
|
+
Check if the given action is currently being held.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
name (str): The name of the bound input.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
bool: True if any action bound to the name is pressed.
|
|
71
|
+
"""
|
|
72
|
+
def unbind(name: str) -> None:
|
|
73
|
+
"""
|
|
74
|
+
Unbind a previously registered input name.
|
|
75
|
+
|
|
76
|
+
Args:
|
|
77
|
+
name (str): The binding name to remove.
|
|
78
|
+
"""
|