@@ -26,6 +26,17 @@ class TextureAccess(enum.IntEnum):
2626 """Texture will be used as a render target."""
2727
2828
29+ class RendererFlip (enum .IntFlag ):
30+ """Flip parameter for :any:`Renderer.copy`."""
31+
32+ NONE = 0
33+ """Default value, no flip."""
34+ HORIZONTAL = 1
35+ """Flip the image horizontally."""
36+ VERTICAL = 2
37+ """Flip the image vertically."""
38+
39+
2940class Texture :
3041 """SDL hardware textures."""
3142
@@ -146,16 +157,37 @@ def __eq__(self, other: Any) -> bool:
146157 def copy (
147158 self ,
148159 texture : Texture ,
149- source : Optional [Tuple [int , int , int , int ]] = None ,
150- dest : Optional [Tuple [int , int , int , int ]] = None ,
160+ source : Optional [Tuple [float , float , float , float ]] = None ,
161+ dest : Optional [Tuple [float , float , float , float ]] = None ,
162+ angle : float = 0 ,
163+ center : Optional [Tuple [float , float ]] = None ,
164+ flip : RendererFlip = RendererFlip .NONE ,
151165 ) -> None :
152166 """Copy a texture to the rendering target.
153167
154- `source` and `dest` are (x, y, width, height) regions of the texture parameter and target texture respectively.
168+ Args:
169+ texture: The texture to copy onto the current texture target.
170+ source: The (x, y, width, height) region of `texture` to copy. If None then the entire texture is copied.
171+ dest: The (x, y, width, height) region of the target. If None then the entire target is drawn over.
172+ angle: The angle in degrees to rotate the image clockwise.
173+ center: The (x, y) point where rotation is applied. If None then the center of `dest` is used.
174+ flip: Flips the `texture` when drawing it.
175+
176+ .. versionchanged:: unreleased
177+ `source` and `dest` can now be float tuples.
178+ Added the `angle`, `center`, and `flip` parameters.
155179 """
156- source_ = ffi .NULL if source is None else ffi .new ("SDL_Rect*" , source )
157- dest_ = ffi .NULL if dest is None else ffi .new ("SDL_Rect*" , dest )
158- _check (lib .SDL_RenderCopy (self .p , texture .p , source_ , dest_ ))
180+ _check (
181+ lib .SDL_RenderCopyExF (
182+ self .p ,
183+ texture .p ,
184+ (source ,) if source is not None else ffi .NULL ,
185+ (dest ,) if dest is not None else ffi .NULL ,
186+ angle ,
187+ (center ,) if center is not None else ffi .NULL ,
188+ flip ,
189+ )
190+ )
159191
160192 def present (self ) -> None :
161193 """Present the currently rendered image to the screen."""
0 commit comments