@@ -38,6 +38,7 @@ def __init__(
3838 self ._size = size
3939 self ._pos = position
4040 self ._pixel_ratio = pixel_ratio
41+ self ._pixelated = False
4142
4243 self .texture = self .ctx .texture (self .size_scaled , components = 4 )
4344 self .fbo : Framebuffer = self .ctx .framebuffer (color_attachments = [self .texture ])
@@ -142,7 +143,9 @@ def draw_texture(
142143
143144 tex .draw_rect (rect = LBWH (0 , 0 , width , height ))
144145 else :
145- arcade .draw_texture_rect (tex , LBWH (x , y , width , height ), angle = angle , alpha = alpha )
146+ arcade .draw_texture_rect (
147+ tex , LBWH (x , y , width , height ), angle = angle , alpha = alpha , pixelated = self ._pixelated
148+ )
146149
147150 def draw_sprite (self , x : float , y : float , width : float , height : float , sprite : arcade .Sprite ):
148151 """Draw a sprite to the surface
@@ -157,7 +160,7 @@ def draw_sprite(self, x: float, y: float, width: float, height: float, sprite: a
157160 sprite .position = x + width // 2 , y + height // 2
158161 sprite .width = width
159162 sprite .height = height
160- arcade .draw_sprite (sprite )
163+ arcade .draw_sprite (sprite , pixelated = self . _pixelated )
161164
162165 @contextmanager
163166 def activate (self ) -> Generator [Self , None , None ]:
@@ -226,11 +229,18 @@ def draw(
226229 Args:
227230 area: Limit the area in the surface we're drawing
228231 (l, b, w, h)
232+ pixelated: If True, the texture will be rendered pixelated
229233 """
230234 # Set blend function
231235 blend_func = self .ctx .blend_func
232236 self .ctx .blend_func = self .blend_func_render
233237
238+ # Handle the pixelated shortcut if filter is not set
239+ if self ._pixelated :
240+ self .texture .filter = self .ctx .NEAREST , self .ctx .NEAREST
241+ else :
242+ self .texture .filter = self .ctx .LINEAR , self .ctx .LINEAR
243+
234244 self .texture .use (0 )
235245 self ._program ["pos" ] = self ._pos
236246 self ._program ["size" ] = self ._size
0 commit comments