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.

@@ -0,0 +1,141 @@
1
+ """
2
+ Functions for transforming pixel arrays
3
+ """
4
+ from __future__ import annotations
5
+ import pykraken._core
6
+ import typing
7
+ __all__: list[str] = ['box_blur', 'flip', 'gaussian_blur', 'grayscale', 'invert', 'rotate', 'scale_by', 'scale_to']
8
+ def box_blur(pixel_array: pykraken._core.PixelArray, radius: typing.SupportsInt, repeat_edge_pixels: bool = True) -> pykraken._core.PixelArray:
9
+ """
10
+ Apply a box blur effect to a pixel array.
11
+
12
+ Box blur creates a uniform blur effect by averaging pixels within a square kernel.
13
+ It's faster than Gaussian blur but produces a more uniform, less natural look.
14
+
15
+ Args:
16
+ pixel_array (PixelArray): The pixel array to blur.
17
+ radius (int): The blur radius in pixels. Larger values create stronger blur.
18
+ repeat_edge_pixels (bool, optional): Whether to repeat edge pixels when sampling
19
+ outside the pixel array bounds. Defaults to True.
20
+
21
+ Returns:
22
+ PixelArray: A new pixel array with the box blur effect applied.
23
+
24
+ Raises:
25
+ RuntimeError: If pixel array creation fails during the blur process.
26
+ """
27
+ def flip(pixel_array: pykraken._core.PixelArray, flip_x: bool, flip_y: bool) -> pykraken._core.PixelArray:
28
+ """
29
+ Flip a pixel array horizontally, vertically, or both.
30
+
31
+ Args:
32
+ pixel_array (PixelArray): The pixel array to flip.
33
+ flip_x (bool): Whether to flip horizontally (mirror left-right).
34
+ flip_y (bool): Whether to flip vertically (mirror top-bottom).
35
+
36
+ Returns:
37
+ PixelArray: A new pixel array with the flipped image.
38
+
39
+ Raises:
40
+ RuntimeError: If pixel array creation fails.
41
+ """
42
+ def gaussian_blur(pixel_array: pykraken._core.PixelArray, radius: typing.SupportsInt, repeat_edge_pixels: bool = True) -> pykraken._core.PixelArray:
43
+ """
44
+ Apply a Gaussian blur effect to a pixel array.
45
+
46
+ Gaussian blur creates a natural, smooth blur effect using a Gaussian distribution
47
+ for pixel weighting. It produces higher quality results than box blur but is
48
+ computationally more expensive.
49
+
50
+ Args:
51
+ pixel_array (PixelArray): The pixel array to blur.
52
+ radius (int): The blur radius in pixels. Larger values create stronger blur.
53
+ repeat_edge_pixels (bool, optional): Whether to repeat edge pixels when sampling
54
+ outside the pixel array bounds. Defaults to True.
55
+
56
+ Returns:
57
+ PixelArray: A new pixel array with the Gaussian blur effect applied.
58
+
59
+ Raises:
60
+ RuntimeError: If pixel array creation fails during the blur process.
61
+ """
62
+ def grayscale(pixel_array: pykraken._core.PixelArray) -> pykraken._core.PixelArray:
63
+ """
64
+ Convert a pixel array to grayscale.
65
+
66
+ Converts the pixel array to grayscale using the standard luminance formula:
67
+ gray = 0.299 * red + 0.587 * green + 0.114 * blue
68
+
69
+ This formula accounts for human perception of brightness across different colors.
70
+ The alpha channel is preserved unchanged.
71
+
72
+ Args:
73
+ pixel_array (PixelArray): The pixel array to convert to grayscale.
74
+
75
+ Returns:
76
+ PixelArray: A new pixel array converted to grayscale.
77
+
78
+ Raises:
79
+ RuntimeError: If pixel array creation fails.
80
+ """
81
+ def invert(pixel_array: pykraken._core.PixelArray) -> pykraken._core.PixelArray:
82
+ """
83
+ Invert the colors of a pixel array.
84
+
85
+ Creates a negative image effect by inverting each color channel (RGB).
86
+ The alpha channel is preserved unchanged.
87
+
88
+ Args:
89
+ pixel_array (PixelArray): The pixel array to invert.
90
+
91
+ Returns:
92
+ PixelArray: A new pixel array with inverted colors.
93
+
94
+ Raises:
95
+ RuntimeError: If pixel array creation fails.
96
+ """
97
+ def rotate(pixel_array: pykraken._core.PixelArray, angle: typing.SupportsFloat) -> pykraken._core.PixelArray:
98
+ """
99
+ Rotate a pixel array by a given angle.
100
+
101
+ Args:
102
+ pixel_array (PixelArray): The pixel array to rotate.
103
+ angle (float): The rotation angle in degrees. Positive values rotate clockwise.
104
+
105
+ Returns:
106
+ PixelArray: A new pixel array containing the rotated image. The output pixel array may be
107
+ larger than the input to accommodate the rotated image.
108
+
109
+ Raises:
110
+ RuntimeError: If pixel array rotation fails.
111
+ """
112
+ def scale_by(pixel_array: pykraken._core.PixelArray, factor: typing.SupportsFloat) -> pykraken._core.PixelArray:
113
+ """
114
+ Scale a pixel array by a given factor.
115
+
116
+ Args:
117
+ pixel_array (PixelArray): The pixel array to scale.
118
+ factor (float): The scaling factor (must be > 0). Values > 1.0 enlarge,
119
+ values < 1.0 shrink the pixel array.
120
+
121
+ Returns:
122
+ PixelArray: A new pixel array scaled by the specified factor.
123
+
124
+ Raises:
125
+ ValueError: If factor is <= 0.
126
+ RuntimeError: If pixel array creation or scaling fails.
127
+ """
128
+ def scale_to(pixel_array: pykraken._core.PixelArray, size: pykraken._core.Vec2) -> pykraken._core.PixelArray:
129
+ """
130
+ Scale a pixel array to a new exact size.
131
+
132
+ Args:
133
+ pixel_array (PixelArray): The pixel array to scale.
134
+ size (Vec2): The target size as (width, height).
135
+
136
+ Returns:
137
+ PixelArray: A new pixel array scaled to the specified size.
138
+
139
+ Raises:
140
+ RuntimeError: If pixel array creation or scaling fails.
141
+ """
@@ -0,0 +1,113 @@
1
+ """
2
+ Window related functions
3
+ """
4
+ from __future__ import annotations
5
+ import pykraken._core
6
+ __all__: list[str] = ['close', 'create', 'get_scale', 'get_size', 'get_title', 'is_fullscreen', 'is_open', 'save_screenshot', 'set_fullscreen', 'set_icon', 'set_title']
7
+ def close() -> None:
8
+ """
9
+ Close the window.
10
+
11
+ Marks the window as closed, typically used to signal the main loop to exit.
12
+ This doesn't destroy the window immediately but sets the close flag.
13
+ """
14
+ def create(title: str, resolution: pykraken._core.Vec2, scaled: bool = False) -> None:
15
+ """
16
+ Create a window with specified title and size.
17
+
18
+ Args:
19
+ title (str): The window title. Must be non-empty and <= 255 characters.
20
+ resolution (Vec2): The renderer resolution as (width, height).
21
+ scaled (bool, optional): If True, creates a scaled up window using the
22
+ display's usable bounds, retaining the resolution's ratio.
23
+ Defaults to False.
24
+
25
+ Raises:
26
+ RuntimeError: If a window already exists or window creation fails.
27
+ ValueError: If title is empty, exceeds 255 characters, or size values are <= 0.
28
+ """
29
+ def get_scale() -> int:
30
+ """
31
+ Get the scale of the window relative to the renderer resolution.
32
+
33
+ Returns:
34
+ int: The window's scale
35
+
36
+ Raises:
37
+ RuntimeError: If the window is not initialized.
38
+ """
39
+ def get_size() -> pykraken._core.Vec2:
40
+ """
41
+ Get the current size of the window.
42
+
43
+ Returns:
44
+ tuple[float, float]: The window size as (width, height).
45
+
46
+ Raises:
47
+ RuntimeError: If the window is not initialized.
48
+ """
49
+ def get_title() -> str:
50
+ """
51
+ Get the current title of the window.
52
+
53
+ Returns:
54
+ str: The current window title.
55
+
56
+ Raises:
57
+ RuntimeError: If the window is not initialized.
58
+ """
59
+ def is_fullscreen() -> bool:
60
+ """
61
+ Check if the window is in fullscreen mode.
62
+
63
+ Returns:
64
+ bool: True if the window is currently in fullscreen mode.
65
+
66
+ Raises:
67
+ RuntimeError: If the window is not initialized.
68
+ """
69
+ def is_open() -> bool:
70
+ """
71
+ Check if the window is open.
72
+
73
+ Returns:
74
+ bool: True if the window is open and active.
75
+ """
76
+ def save_screenshot(path: str) -> None:
77
+ """
78
+ Save a screenshot of the current frame to a file.
79
+
80
+ Args:
81
+ path (str): The path to save the screenshot to.
82
+ """
83
+ def set_fullscreen(fullscreen: bool) -> None:
84
+ """
85
+ Set the fullscreen mode of the window.
86
+
87
+ Args:
88
+ fullscreen (bool): True to enable fullscreen mode, False for windowed mode.
89
+
90
+ Raises:
91
+ RuntimeError: If the window is not initialized.
92
+ """
93
+ def set_icon(path: str) -> None:
94
+ """
95
+ Set the window icon from an image file.
96
+
97
+ Args:
98
+ path (str): The file path to the image to use as the icon.
99
+
100
+ Raises:
101
+ RuntimeError: If the window is not initialized or icon setting fails.
102
+ """
103
+ def set_title(title: str) -> None:
104
+ """
105
+ Set the title of the window.
106
+
107
+ Args:
108
+ title (str): The new window title. Must be non-empty and <= 255 characters.
109
+
110
+ Raises:
111
+ RuntimeError: If the window is not initialized or title setting fails.
112
+ ValueError: If title is empty or exceeds 255 characters.
113
+ """
Binary file