@@ -15,6 +15,12 @@ class BackgroundTexture:
15
15
16
16
The Mat3s define the scaling, rotation, and translation of the pixel data in the texture.
17
17
see background_fs.glsl in resources/shaders for an implementation of this.
18
+
19
+ Args:
20
+ texture: The texture to use as the background.
21
+ offset: The offset of the texture in pixels.
22
+ scale: The scale of the texture.
23
+ angle: The angle of the texture in radians.
18
24
"""
19
25
20
26
def __init__ (
@@ -41,6 +47,10 @@ def pixel_transform(self):
41
47
42
48
@property
43
49
def scale (self ) -> float :
50
+ """
51
+ Get or set the scale of the texture. This is a multiplier on the size of the texture.
52
+ Default value is ``1.0``.
53
+ """
44
54
return self ._scale
45
55
46
56
@scale .setter
@@ -50,6 +60,10 @@ def scale(self, value: float):
50
60
51
61
@property
52
62
def angle (self ) -> float :
63
+ """
64
+ Get or set the angle of the texture. This is a rotation in radians.
65
+ Default value is ``0.0``.
66
+ """
53
67
return self ._angle
54
68
55
69
@angle .setter
@@ -59,6 +73,10 @@ def angle(self, value: float):
59
73
60
74
@property
61
75
def offset (self ) -> tuple [float , float ]:
76
+ """
77
+ Get or set the offset of the texture. This is a translation in pixels.
78
+ Default value is ``(0.0, 0.0)``.
79
+ """
62
80
return self ._offset
63
81
64
82
@offset .setter
@@ -134,6 +152,17 @@ def render_target(
134
152
color_attachments : list [gl .Texture2D ] | None = None ,
135
153
depth_attachment : gl .Texture2D | None = None ,
136
154
) -> gl .Framebuffer :
155
+ """
156
+ Create a framebuffer for the texture.
157
+
158
+ This framebuffer is used to render to the texture. The framebuffer is created with the
159
+ texture as the color attachment.
160
+
161
+ Args:
162
+ context: The context to use for the framebuffer.
163
+ color_attachments: The color attachments to use for the framebuffer."
164
+ depth_attachment: The depth attachment to use for the framebuffer."
165
+ """
137
166
if color_attachments is None :
138
167
color_attachments = []
139
168
return context .framebuffer (
@@ -149,6 +178,19 @@ def from_file(
149
178
angle : float = 0.0 ,
150
179
filters = (gl .NEAREST , gl .NEAREST ),
151
180
):
181
+ """ "
182
+ Create a BackgroundTexture from a file.
183
+ This is a convenience function to create a BackgroundTexture from a file.
184
+
185
+ The file is loaded using PIL and converted to a texture.
186
+
187
+ Args:
188
+ tex_src: The file to load.
189
+ offset: The offset of the texture in pixels.
190
+ scale: The scale of the texture.
191
+ angle: The angle of the texture in radians.
192
+ filters: The filters to use for the texture.
193
+ """
152
194
_context = get_window ().ctx
153
195
154
196
with Image .open (resolve (tex_src )).convert ("RGBA" ) as img :
0 commit comments