kraken-engine 1.2.1__cp313-cp313-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.
@@ -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
@@ -0,0 +1,55 @@
1
+ from pydantic import BaseModel
2
+ import struct
3
+
4
+
5
+ class ShaderUniform(BaseModel):
6
+ """
7
+ Base class for shader uniform data structures.
8
+
9
+ Inherits from Pydantic's BaseModel to provide type validation and serialization
10
+ for shader uniform buffers. Subclass this to define your shader's uniform layout,
11
+ and use `to_bytes()` to convert the data to a binary format suitable for upload
12
+ to the GPU via `ShaderState.set_uniform()`.
13
+
14
+ Supported field types:
15
+ - float: Packed as 'f' (4 bytes)
16
+ - int: Packed as 'i' (4 bytes, signed)
17
+ - bool: Packed as '?' (1 byte)
18
+ - tuple/list of 2-4 floats: Packed as vectors (vec2, vec3, vec4)
19
+ """
20
+
21
+ def to_bytes(self) -> bytes:
22
+ """
23
+ Converts the uniform data to a packed binary format.
24
+
25
+ Serializes all fields in the model to a bytes object using Python's struct
26
+ module, suitable for uploading to GPU uniform buffers. The packing format
27
+ is automatically determined based on field types.
28
+
29
+ Returns:
30
+ bytes: The packed binary representation of the uniform data.
31
+
32
+ Raises:
33
+ ValueError: If a tuple/list field has an invalid length (not 2, 3, or 4).
34
+ TypeError: If a field has an unsupported type.
35
+ """
36
+ fmt = ""
37
+ values = []
38
+
39
+ for name, value in self.model_dump().items():
40
+ if isinstance(value, float):
41
+ fmt += "f"; values.append(value)
42
+ elif isinstance(value, int):
43
+ fmt += "i"; values.append(value)
44
+ elif isinstance(value, bool):
45
+ fmt += "?"; values.append(value)
46
+ elif isinstance(value, (tuple, list)):
47
+ n = len(value)
48
+ if n not in (2, 3, 4):
49
+ raise ValueError(f"Field '{name}' length {n} invalid, must be 2, 3, or 4.")
50
+ fmt += f"{n}f"
51
+ values.extend(map(float, value))
52
+ else:
53
+ raise TypeError(f"Unsupported uniform field '{name}' of type '{type(value)}'")
54
+
55
+ return struct.pack(fmt, *values)
@@ -0,0 +1,59 @@
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
+
13
+ Base class for shader uniform data structures.
14
+
15
+ Inherits from Pydantic's BaseModel to provide type validation and serialization
16
+ for shader uniform buffers. Subclass this to define your shader's uniform layout,
17
+ and use `to_bytes()` to convert the data to a binary format suitable for upload
18
+ to the GPU via `ShaderState.set_uniform()`.
19
+
20
+ Supported field types:
21
+ - float: Packed as 'f' (4 bytes)
22
+ - int: Packed as 'i' (4 bytes, signed)
23
+ - bool: Packed as '?' (1 byte)
24
+ - tuple/list of 2-4 floats: Packed as vectors (vec2, vec3, vec4)
25
+ """
26
+ __abstractmethods__: typing.ClassVar[frozenset] # value = frozenset()
27
+ __class_vars__: typing.ClassVar[set] = set()
28
+ __private_attributes__: typing.ClassVar[dict] = {}
29
+ __pydantic_complete__: typing.ClassVar[bool] = True
30
+ __pydantic_computed_fields__: typing.ClassVar[dict] = {}
31
+ __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:3103675912064', 'metadata': {'pydantic_js_functions': [pydantic.main.BaseModel.__get_pydantic_json_schema__]}}
32
+ __pydantic_custom_init__: typing.ClassVar[bool] = False
33
+ __pydantic_decorators__: typing.ClassVar[pydantic._internal._decorators.DecoratorInfos] # value = DecoratorInfos(validators={}, field_validators={}, root_validators={}, field_serializers={}, model_serializers={}, model_validators={}, computed_fields={})
34
+ __pydantic_fields__: typing.ClassVar[dict] = {}
35
+ __pydantic_generic_metadata__: typing.ClassVar[dict] = {'origin': None, 'args': tuple(), 'parameters': tuple()}
36
+ __pydantic_parent_namespace__ = None
37
+ __pydantic_post_init__ = None
38
+ __pydantic_serializer__: typing.ClassVar[pydantic_core._pydantic_core.SchemaSerializer] # value = SchemaSerializer(serializer=Model(...
39
+ __pydantic_setattr_handlers__: typing.ClassVar[dict] = {}
40
+ __pydantic_validator__: typing.ClassVar[pydantic_core._pydantic_core.SchemaValidator] # value = SchemaValidator(title="ShaderUniform", validator=Model(...
41
+ __signature__: typing.ClassVar[inspect.Signature] # value = <Signature () -> None>
42
+ _abc_impl: typing.ClassVar[_abc._abc_data] # value = <_abc._abc_data object>
43
+ model_config: typing.ClassVar[dict] = {}
44
+ def to_bytes(self) -> bytes:
45
+ """
46
+
47
+ Converts the uniform data to a packed binary format.
48
+
49
+ Serializes all fields in the model to a bytes object using Python's struct
50
+ module, suitable for uploading to GPU uniform buffers. The packing format
51
+ is automatically determined based on field types.
52
+
53
+ Returns:
54
+ bytes: The packed binary representation of the uniform data.
55
+
56
+ Raises:
57
+ ValueError: If a tuple/list field has an invalid length (not 2, 3, or 4).
58
+ TypeError: If a field has an unsupported type.
59
+ """