basilisk-engine 0.1.2__py3-none-any.whl → 0.1.3__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.

Potentially problematic release.


This version of basilisk-engine might be problematic. Click here for more details.

Files changed (82) hide show
  1. basilisk/__init__.py +11 -11
  2. basilisk/bsk_assets/cube.obj +48 -48
  3. basilisk/collisions/broad/broad_aabb.py +102 -102
  4. basilisk/collisions/broad/broad_bvh.py +137 -137
  5. basilisk/collisions/collider.py +95 -83
  6. basilisk/collisions/collider_handler.py +225 -228
  7. basilisk/collisions/narrow/contact_manifold.py +90 -90
  8. basilisk/collisions/narrow/dataclasses.py +33 -27
  9. basilisk/collisions/narrow/deprecated.py +46 -46
  10. basilisk/collisions/narrow/epa.py +91 -91
  11. basilisk/collisions/narrow/gjk.py +66 -66
  12. basilisk/collisions/narrow/graham_scan.py +24 -24
  13. basilisk/collisions/narrow/helper.py +29 -29
  14. basilisk/collisions/narrow/line_intersections.py +106 -106
  15. basilisk/collisions/narrow/sutherland_hodgman.py +75 -75
  16. basilisk/config.py +2 -2
  17. basilisk/draw/draw.py +100 -100
  18. basilisk/draw/draw_handler.py +180 -210
  19. basilisk/draw/font_renderer.py +28 -28
  20. basilisk/engine.py +195 -195
  21. basilisk/generic/abstract_bvh.py +15 -15
  22. basilisk/generic/abstract_custom.py +133 -133
  23. basilisk/generic/collisions.py +70 -70
  24. basilisk/generic/input_validation.py +67 -28
  25. basilisk/generic/math.py +6 -6
  26. basilisk/generic/matrices.py +33 -33
  27. basilisk/generic/meshes.py +72 -72
  28. basilisk/generic/quat.py +137 -137
  29. basilisk/generic/quat_methods.py +7 -7
  30. basilisk/generic/raycast_result.py +24 -0
  31. basilisk/generic/vec3.py +143 -143
  32. basilisk/input/mouse.py +61 -59
  33. basilisk/mesh/cube.py +33 -33
  34. basilisk/mesh/mesh.py +230 -230
  35. basilisk/mesh/mesh_from_data.py +132 -132
  36. basilisk/mesh/model.py +271 -271
  37. basilisk/mesh/narrow_aabb.py +89 -89
  38. basilisk/mesh/narrow_bvh.py +91 -91
  39. basilisk/mesh/narrow_primative.py +23 -23
  40. basilisk/nodes/helper.py +29 -0
  41. basilisk/nodes/node.py +681 -617
  42. basilisk/nodes/node_handler.py +95 -118
  43. basilisk/particles/particle_handler.py +63 -54
  44. basilisk/particles/particle_renderer.py +87 -87
  45. basilisk/physics/impulse.py +112 -112
  46. basilisk/physics/physics_body.py +43 -43
  47. basilisk/physics/physics_engine.py +35 -35
  48. basilisk/render/batch.py +86 -86
  49. basilisk/render/camera.py +204 -199
  50. basilisk/render/chunk.py +99 -99
  51. basilisk/render/chunk_handler.py +154 -154
  52. basilisk/render/frame.py +181 -181
  53. basilisk/render/image.py +75 -75
  54. basilisk/render/image_handler.py +122 -122
  55. basilisk/render/light.py +96 -96
  56. basilisk/render/light_handler.py +58 -58
  57. basilisk/render/material.py +219 -219
  58. basilisk/render/material_handler.py +135 -135
  59. basilisk/render/shader.py +109 -109
  60. basilisk/render/shader_handler.py +79 -79
  61. basilisk/render/sky.py +120 -120
  62. basilisk/scene.py +250 -210
  63. basilisk/shaders/batch.frag +276 -276
  64. basilisk/shaders/batch.vert +115 -115
  65. basilisk/shaders/draw.frag +21 -21
  66. basilisk/shaders/draw.vert +21 -21
  67. basilisk/shaders/filter.frag +22 -22
  68. basilisk/shaders/frame.frag +12 -12
  69. basilisk/shaders/frame.vert +13 -13
  70. basilisk/shaders/geometry.frag +8 -8
  71. basilisk/shaders/geometry.vert +41 -41
  72. basilisk/shaders/normal.frag +59 -59
  73. basilisk/shaders/normal.vert +96 -96
  74. basilisk/shaders/particle.frag +71 -71
  75. basilisk/shaders/particle.vert +84 -84
  76. basilisk/shaders/sky.frag +9 -9
  77. basilisk/shaders/sky.vert +13 -13
  78. {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.3.dist-info}/METADATA +45 -38
  79. basilisk_engine-0.1.3.dist-info/RECORD +97 -0
  80. {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.3.dist-info}/WHEEL +1 -1
  81. basilisk_engine-0.1.2.dist-info/RECORD +0 -95
  82. {basilisk_engine-0.1.2.dist-info → basilisk_engine-0.1.3.dist-info}/top_level.txt +0 -0
basilisk/render/frame.py CHANGED
@@ -1,182 +1,182 @@
1
- import numpy as np
2
- import moderngl as mgl
3
- from PIL import Image
4
-
5
-
6
- class Frame:
7
- program: mgl.Program=None
8
- vbo: mgl.Buffer=None
9
- vao: mgl.VertexArray=None
10
- frame_texture: mgl.Texture=None
11
- depth_texture: mgl.Texture=None
12
- framebuffer: mgl.Framebuffer=None
13
- pingpong_frame_texture: mgl.Texture=None
14
- pingpong_depth_texture: mgl.Texture=None
15
- pingpong_framebuffer: mgl.Framebuffer=None
16
- postprocess: dict=None
17
-
18
- def __init__(self, scene) -> None:
19
- """
20
- Basilisk render destination.
21
- Can be used to render to the screen or for headless rendering
22
- """
23
-
24
- self.scene = scene
25
- self.engine = scene.engine
26
- self.ctx = scene.ctx
27
-
28
-
29
- self.load_program()
30
- self.set_textures()
31
- self.set_renderer()
32
-
33
- self.postprocess = {}
34
- self.load_post_shader('frame', 'filter')
35
-
36
- def render(self):
37
- """
38
- Renders the current frame to the screen
39
- """
40
-
41
- # self.apply_postprocess('filter')
42
-
43
- self.ctx.screen.use()
44
- self.program['screenTexture'] = 0
45
- self.framebuffer.color_attachments[0].use(location=0)
46
- self.vao.render()
47
-
48
- def use(self):
49
- """
50
- Uses the frame as a render target
51
- """
52
-
53
- self.framebuffer.use()
54
- self.framebuffer.clear()
55
-
56
- def save(self, destination: str=None):
57
- """
58
- Saves the frame as an image to the given file destination
59
- """
60
-
61
- path = destination if destination else 'screenshot'
62
-
63
- data = self.framebuffer.read(components=3, alignment=1)
64
- img = Image.frombytes('RGB', self.framebuffer.size, data).transpose(Image.FLIP_TOP_BOTTOM)
65
- img.save(f'{path}.png')
66
-
67
-
68
- def load_program(self) -> None:
69
- """
70
- Loads the frame shaders
71
- """
72
-
73
- # Release any existing memory
74
- if self.program: self.program.release()
75
-
76
- # Read the shaders
77
- with open(self.engine.root + '/shaders/frame.vert') as file:
78
- vertex_shader = file.read()
79
- with open(self.engine.root + '/shaders/frame.frag') as file:
80
- fragment_shader = file.read()
81
-
82
- # Create the program
83
- self.program = self.ctx.program(vertex_shader=vertex_shader, fragment_shader=fragment_shader)
84
-
85
- def load_post_shader(self, vert: str, frag: str) -> None:
86
- """
87
- Loads a post processing shader
88
- """
89
-
90
- # Read the shaders
91
- with open(self.engine.root + f'/shaders/{vert}.vert') as file:
92
- vertex_shader = file.read()
93
- with open(self.engine.root + f'/shaders/{frag}.frag') as file:
94
- fragment_shader = file.read()
95
-
96
- # Create the program
97
- program = self.ctx.program(vertex_shader=vertex_shader, fragment_shader=fragment_shader)
98
- self.postprocess[frag] = self.ctx.vertex_array(program, [(self.vbo, '3f 2f', 'in_position', 'in_uv')], skip_errors=True)
99
-
100
- def apply_postprocess(self, shader: str):
101
- self.pingpong_framebuffer.use()
102
- self.pingpong_framebuffer.clear()
103
- self.postprocess[shader].program['screenTexture'] = 0
104
- self.framebuffer.color_attachments[0].use(location=0)
105
- self.postprocess[shader].render()
106
-
107
-
108
- temp = self.framebuffer
109
- self.framebuffer = self.pingpong_framebuffer
110
- self.pingpong_framebuffer = temp
111
-
112
- # self.use()
113
- # self.postprocess[shader].program['screenTexture'] = 0
114
- # self.pingpong_frame_texture.use(location=0)
115
- # self.vao.render()
116
-
117
-
118
- def set_textures(self, viewport: tuple=None) -> None:
119
- """
120
- Sets the framebuffer textures
121
- """
122
-
123
- # Release any existing memory in case of a resize
124
- if self.frame_texture: self.frame_texture.release()
125
- if self.depth_texture: self.depth_texture.release()
126
- if self.framebuffer: self.framebuffer.release()
127
- if self.pingpong_frame_texture: self.pingpong_frame_texture.release()
128
- if self.pingpong_depth_texture: self.pingpong_depth_texture.release()
129
- if self.pingpong_framebuffer: self.pingpong_framebuffer.release()
130
-
131
- # Get the size from the engine window if the not specified by the function call
132
- size = viewport if viewport else self.engine.win_size
133
-
134
- # Create textures and frame buffer object
135
- self.frame_texture = self.ctx.texture(size, components=4)
136
- self.depth_texture = self.ctx.depth_texture(size)
137
- self.framebuffer = self.ctx.framebuffer([self.frame_texture], self.depth_texture)
138
- self.pingpong_frame_texture = self.ctx.texture(size, components=4)
139
- self.pingpong_depth_texture = self.ctx.depth_texture(size)
140
- self.pingpong_framebuffer = self.ctx.framebuffer([self.pingpong_frame_texture], self.pingpong_depth_texture)
141
-
142
- def set_renderer(self) -> None:
143
- """
144
- Sets the vertex data and vao for the frame
145
- """
146
-
147
- # Release any existing memory
148
- if self.vbo: self.vbo.release()
149
- if self.vao: self.vao.release()
150
-
151
- # Vertex and index info for the frame
152
- verticies = [[-1, -1, 0], [ 1, -1, 0], [ 1, 1, 0], [-1, 1, 0]]
153
- indicies = [(3, 0, 1), (2, 3, 1)]
154
- uv_verticies = [(0, 0), (1, 0), (1, 1), (0, 1)]
155
- uv_indicies = [(3, 0, 1),(2, 3, 1)]
156
-
157
- # Format the data
158
- vertex_data = [verticies[ind] for triangle in indicies for ind in triangle]
159
- vertex_data = np.array(vertex_data, dtype='f4')
160
- uv_data = [uv_verticies[ind] for triangle in uv_indicies for ind in triangle]
161
- uv_data = np.array(uv_data, dtype='f4')
162
-
163
- vertex_data = np.hstack([vertex_data, uv_data])
164
-
165
- # Create moderngl objects
166
- self.vbo = self.ctx.buffer(vertex_data)
167
- self.vao = self.ctx.vertex_array(self.program, [(self.vbo, '3f 2f', 'in_position', 'in_uv')], skip_errors=True)
168
-
169
- def __del__(self) -> None:
170
- """
171
- Releases memory used by the frame
172
- """
173
-
174
- if self.program: self.program.release()
175
- if self.vbo: self.vbo.release()
176
- if self.vao: self.vao.release()
177
- if self.frame_texture: self.frame_texture.release()
178
- if self.depth_texture: self.depth_texture.release()
179
- if self.framebuffer: self.framebuffer.release()
180
- if self.pingpong_frame_texture: self.frame_texture.release()
181
- if self.pingpong_depth_texture: self.depth_texture.release()
1
+ import numpy as np
2
+ import moderngl as mgl
3
+ from PIL import Image
4
+
5
+
6
+ class Frame:
7
+ program: mgl.Program=None
8
+ vbo: mgl.Buffer=None
9
+ vao: mgl.VertexArray=None
10
+ frame_texture: mgl.Texture=None
11
+ depth_texture: mgl.Texture=None
12
+ framebuffer: mgl.Framebuffer=None
13
+ pingpong_frame_texture: mgl.Texture=None
14
+ pingpong_depth_texture: mgl.Texture=None
15
+ pingpong_framebuffer: mgl.Framebuffer=None
16
+ postprocess: dict=None
17
+
18
+ def __init__(self, scene) -> None:
19
+ """
20
+ Basilisk render destination.
21
+ Can be used to render to the screen or for headless rendering
22
+ """
23
+
24
+ self.scene = scene
25
+ self.engine = scene.engine
26
+ self.ctx = scene.ctx
27
+
28
+
29
+ self.load_program()
30
+ self.set_textures()
31
+ self.set_renderer()
32
+
33
+ self.postprocess = {}
34
+ self.load_post_shader('frame', 'filter')
35
+
36
+ def render(self):
37
+ """
38
+ Renders the current frame to the screen
39
+ """
40
+
41
+ # self.apply_postprocess('filter')
42
+
43
+ self.ctx.screen.use()
44
+ self.program['screenTexture'] = 0
45
+ self.framebuffer.color_attachments[0].use(location=0)
46
+ self.vao.render()
47
+
48
+ def use(self):
49
+ """
50
+ Uses the frame as a render target
51
+ """
52
+
53
+ self.framebuffer.use()
54
+ self.framebuffer.clear()
55
+
56
+ def save(self, destination: str=None):
57
+ """
58
+ Saves the frame as an image to the given file destination
59
+ """
60
+
61
+ path = destination if destination else 'screenshot'
62
+
63
+ data = self.framebuffer.read(components=3, alignment=1)
64
+ img = Image.frombytes('RGB', self.framebuffer.size, data).transpose(Image.FLIP_TOP_BOTTOM)
65
+ img.save(f'{path}.png')
66
+
67
+
68
+ def load_program(self) -> None:
69
+ """
70
+ Loads the frame shaders
71
+ """
72
+
73
+ # Release any existing memory
74
+ if self.program: self.program.release()
75
+
76
+ # Read the shaders
77
+ with open(self.engine.root + '/shaders/frame.vert') as file:
78
+ vertex_shader = file.read()
79
+ with open(self.engine.root + '/shaders/frame.frag') as file:
80
+ fragment_shader = file.read()
81
+
82
+ # Create the program
83
+ self.program = self.ctx.program(vertex_shader=vertex_shader, fragment_shader=fragment_shader)
84
+
85
+ def load_post_shader(self, vert: str, frag: str) -> None:
86
+ """
87
+ Loads a post processing shader
88
+ """
89
+
90
+ # Read the shaders
91
+ with open(self.engine.root + f'/shaders/{vert}.vert') as file:
92
+ vertex_shader = file.read()
93
+ with open(self.engine.root + f'/shaders/{frag}.frag') as file:
94
+ fragment_shader = file.read()
95
+
96
+ # Create the program
97
+ program = self.ctx.program(vertex_shader=vertex_shader, fragment_shader=fragment_shader)
98
+ self.postprocess[frag] = self.ctx.vertex_array(program, [(self.vbo, '3f 2f', 'in_position', 'in_uv')], skip_errors=True)
99
+
100
+ def apply_postprocess(self, shader: str):
101
+ self.pingpong_framebuffer.use()
102
+ self.pingpong_framebuffer.clear()
103
+ self.postprocess[shader].program['screenTexture'] = 0
104
+ self.framebuffer.color_attachments[0].use(location=0)
105
+ self.postprocess[shader].render()
106
+
107
+
108
+ temp = self.framebuffer
109
+ self.framebuffer = self.pingpong_framebuffer
110
+ self.pingpong_framebuffer = temp
111
+
112
+ # self.use()
113
+ # self.postprocess[shader].program['screenTexture'] = 0
114
+ # self.pingpong_frame_texture.use(location=0)
115
+ # self.vao.render()
116
+
117
+
118
+ def set_textures(self, viewport: tuple=None) -> None:
119
+ """
120
+ Sets the framebuffer textures
121
+ """
122
+
123
+ # Release any existing memory in case of a resize
124
+ if self.frame_texture: self.frame_texture.release()
125
+ if self.depth_texture: self.depth_texture.release()
126
+ if self.framebuffer: self.framebuffer.release()
127
+ if self.pingpong_frame_texture: self.pingpong_frame_texture.release()
128
+ if self.pingpong_depth_texture: self.pingpong_depth_texture.release()
129
+ if self.pingpong_framebuffer: self.pingpong_framebuffer.release()
130
+
131
+ # Get the size from the engine window if the not specified by the function call
132
+ size = viewport if viewport else self.engine.win_size
133
+
134
+ # Create textures and frame buffer object
135
+ self.frame_texture = self.ctx.texture(size, components=4)
136
+ self.depth_texture = self.ctx.depth_texture(size)
137
+ self.framebuffer = self.ctx.framebuffer([self.frame_texture], self.depth_texture)
138
+ self.pingpong_frame_texture = self.ctx.texture(size, components=4)
139
+ self.pingpong_depth_texture = self.ctx.depth_texture(size)
140
+ self.pingpong_framebuffer = self.ctx.framebuffer([self.pingpong_frame_texture], self.pingpong_depth_texture)
141
+
142
+ def set_renderer(self) -> None:
143
+ """
144
+ Sets the vertex data and vao for the frame
145
+ """
146
+
147
+ # Release any existing memory
148
+ if self.vbo: self.vbo.release()
149
+ if self.vao: self.vao.release()
150
+
151
+ # Vertex and index info for the frame
152
+ verticies = [[-1, -1, 0], [ 1, -1, 0], [ 1, 1, 0], [-1, 1, 0]]
153
+ indicies = [(3, 0, 1), (2, 3, 1)]
154
+ uv_verticies = [(0, 0), (1, 0), (1, 1), (0, 1)]
155
+ uv_indicies = [(3, 0, 1),(2, 3, 1)]
156
+
157
+ # Format the data
158
+ vertex_data = [verticies[ind] for triangle in indicies for ind in triangle]
159
+ vertex_data = np.array(vertex_data, dtype='f4')
160
+ uv_data = [uv_verticies[ind] for triangle in uv_indicies for ind in triangle]
161
+ uv_data = np.array(uv_data, dtype='f4')
162
+
163
+ vertex_data = np.hstack([vertex_data, uv_data])
164
+
165
+ # Create moderngl objects
166
+ self.vbo = self.ctx.buffer(vertex_data)
167
+ self.vao = self.ctx.vertex_array(self.program, [(self.vbo, '3f 2f', 'in_position', 'in_uv')], skip_errors=True)
168
+
169
+ def __del__(self) -> None:
170
+ """
171
+ Releases memory used by the frame
172
+ """
173
+
174
+ if self.program: self.program.release()
175
+ if self.vbo: self.vbo.release()
176
+ if self.vao: self.vao.release()
177
+ if self.frame_texture: self.frame_texture.release()
178
+ if self.depth_texture: self.depth_texture.release()
179
+ if self.framebuffer: self.framebuffer.release()
180
+ if self.pingpong_frame_texture: self.frame_texture.release()
181
+ if self.pingpong_depth_texture: self.depth_texture.release()
182
182
  if self.pingpong_framebuffer: self.framebuffer.release()
basilisk/render/image.py CHANGED
@@ -1,76 +1,76 @@
1
- import os
2
- import sys
3
- import numpy as np
4
- import moderngl as mgl
5
- import glm
6
- import pygame as pg
7
- from PIL import Image as PIL_Image
8
-
9
-
10
- texture_sizes = (8, 64, 512, 1024, 2048)
11
-
12
-
13
- class Image():
14
- name: str
15
- """Name of the image"""
16
- index: glm.ivec2
17
- """Location of the image in the texture arrays"""
18
- data: np.ndarray
19
- """Array of the texture data"""
20
- size: int
21
- """The width and height in pixels of the image"""
22
-
23
- def __init__(self, path: str | os.PathLike | pg.Surface) -> None:
24
- """
25
- A basilisk image object that contains a moderngl texture
26
- Args:
27
- path: str | os.PathLike | pg.Surface
28
- The string path to the image. Can also read a pygame surface
29
- """
30
-
31
- # Check if the user is loading a pygame surface
32
- if isinstance(path, pg.Surface):
33
- self.from_pg_surface(path)
34
- return
35
-
36
- # Verify the path type
37
- if not isinstance(path, str) and not isinstance(path, os.PathLike):
38
- raise TypeError(f'Invalid path type: {type(path)}. Expected a string or os.PathLike')
39
-
40
- # Get name from path
41
- self.name = path.split('/')[-1].split('\\')[-1].split('.')[0]
42
-
43
- # Set the texture
44
- # Load image
45
- img = PIL_Image.open(path).convert('RGBA')
46
- # Set the size in one of the size buckets
47
- size_buckets = texture_sizes
48
- self.size = size_buckets[np.argmin(np.array([abs(size - img.size[0]) for size in size_buckets]))]
49
- img = img.resize((self.size, self.size))
50
- # Get the image data
51
- self.data = img.tobytes()
52
-
53
- # Default index value (to be set by image handler)
54
- self.index = glm.ivec2(1, 1)
55
-
56
- def from_pg_surface(self, surf: pg.Surface) -> None:
57
- """
58
- Loads a basilisk image from a pygame surface
59
- Args:
60
- """
61
-
62
- # Set the size in one of the size buckets
63
- size_buckets = texture_sizes
64
- self.size = size_buckets[np.argmin(np.array([abs(size - surf.get_size()[0]) for size in size_buckets]))]
65
- surf = pg.transform.scale(surf, (self.size, self.size)).convert_alpha()
66
- # Get image data
67
- self.data = pg.image.tobytes(surf, 'RGBA')
68
-
69
- # Default index value (to be set by image handler)
70
- self.index = glm.ivec2(1, 1)
71
-
72
- def __repr__(self) -> str:
73
- """
74
- Returns a string representation of the object
75
- """
1
+ import os
2
+ import sys
3
+ import numpy as np
4
+ import moderngl as mgl
5
+ import glm
6
+ import pygame as pg
7
+ from PIL import Image as PIL_Image
8
+
9
+
10
+ texture_sizes = (8, 64, 512, 1024, 2048)
11
+
12
+
13
+ class Image():
14
+ name: str
15
+ """Name of the image"""
16
+ index: glm.ivec2
17
+ """Location of the image in the texture arrays"""
18
+ data: np.ndarray
19
+ """Array of the texture data"""
20
+ size: int
21
+ """The width and height in pixels of the image"""
22
+
23
+ def __init__(self, path: str | os.PathLike | pg.Surface) -> None:
24
+ """
25
+ A basilisk image object that contains a moderngl texture
26
+ Args:
27
+ path: str | os.PathLike | pg.Surface
28
+ The string path to the image. Can also read a pygame surface
29
+ """
30
+
31
+ # Check if the user is loading a pygame surface
32
+ if isinstance(path, pg.Surface):
33
+ self.from_pg_surface(path)
34
+ return
35
+
36
+ # Verify the path type
37
+ if not isinstance(path, str) and not isinstance(path, os.PathLike):
38
+ raise TypeError(f'Invalid path type: {type(path)}. Expected a string or os.PathLike')
39
+
40
+ # Get name from path
41
+ self.name = path.split('/')[-1].split('\\')[-1].split('.')[0]
42
+
43
+ # Set the texture
44
+ # Load image
45
+ img = PIL_Image.open(path).convert('RGBA')
46
+ # Set the size in one of the size buckets
47
+ size_buckets = texture_sizes
48
+ self.size = size_buckets[np.argmin(np.array([abs(size - img.size[0]) for size in size_buckets]))]
49
+ img = img.resize((self.size, self.size))
50
+ # Get the image data
51
+ self.data = img.tobytes()
52
+
53
+ # Default index value (to be set by image handler)
54
+ self.index = glm.ivec2(1, 1)
55
+
56
+ def from_pg_surface(self, surf: pg.Surface) -> None:
57
+ """
58
+ Loads a basilisk image from a pygame surface
59
+ Args:
60
+ """
61
+
62
+ # Set the size in one of the size buckets
63
+ size_buckets = texture_sizes
64
+ self.size = size_buckets[np.argmin(np.array([abs(size - surf.get_size()[0]) for size in size_buckets]))]
65
+ surf = pg.transform.scale(surf, (self.size, self.size)).convert_alpha()
66
+ # Get image data
67
+ self.data = pg.image.tobytes(surf, 'RGBA')
68
+
69
+ # Default index value (to be set by image handler)
70
+ self.index = glm.ivec2(1, 1)
71
+
72
+ def __repr__(self) -> str:
73
+ """
74
+ Returns a string representation of the object
75
+ """
76
76
  return f'<Basilisk Image | {self.name}, ({self.size}x{self.size}), {sys.getsizeof(self.data) / 1024 / 1024:.2} mb>'