|
1 | | -.. currentmodule:: sdl2.ext |
| 1 | +`sdl2.ext.renderer` - Accelerated 2D Rendering |
| 2 | +============================================== |
2 | 3 |
|
3 | | -Accelerated 2D Rendering |
4 | | -======================== |
| 4 | +The :mod:`sdl2.ext.renderer` module implements a Pythonic interface for working |
| 5 | +with the SDL Renderer API, which allows for easy hardware-accelerated 2D |
| 6 | +rendering with backends for a number of platforms (e.g. OpenGL, Direct3D, Metal) |
| 7 | +as well as a software-accelerated fallback. |
5 | 8 |
|
6 | | -.. class:: Renderer(target : obj[, logical_size=None[, index=-1[, flags=sdl2.SDL_RENDERER_ACCELERATED]]) |
7 | | - |
8 | | - A rendering context for windows and sprites that can use hardware or |
9 | | - software-accelerated graphics drivers. |
10 | | - |
11 | | - If target is a :class:`sdl2.ext.Window` or :class:`sdl2.SDL_Window`, |
12 | | - *index* and *flags* are passed to the relevant |
13 | | - :class:`sdl2.SDL_CreateRenderer()` call. If *target* is a |
14 | | - :class:`SoftwareSprite` or :class:`sdl2.SDL_Surface`, the *index* |
15 | | - and *flags* arguments are ignored. |
16 | | - |
17 | | - .. attribute:: sdlrenderer |
18 | | - |
19 | | - The underlying :class:`sdl2.SDL_Renderer`. |
20 | | - |
21 | | - .. attribute:: rendertarget |
22 | | - |
23 | | - The target for which the :class:`Renderer` was created. |
24 | | - |
25 | | - .. attribute:: logical_size |
26 | | - |
27 | | - The logical size of the renderer. |
28 | | - |
29 | | - Setting this allows you to draw as if your renderer had this size, even |
30 | | - though the target may be larger or smaller. When drawing, the renderer will |
31 | | - automatically scale your contents to the target, creating letter-boxing or |
32 | | - sidebars if necessary. |
33 | | - |
34 | | - To reset your logical size back to the target's, set it to ``(0, 0)``. |
35 | | - |
36 | | - Setting this to a lower value may be useful for low-resolution effects. |
37 | | - |
38 | | - Setting this to a larger value may be useful for antialiasing. |
39 | | - |
40 | | - .. attribute:: color |
41 | | - |
42 | | - The :class:`sdl2.ext.Color` to use for draw and fill operations. |
43 | | - |
44 | | - .. attribute:: blendmode |
45 | | - |
46 | | - The blend mode used for drawing operations (fill and line). This |
47 | | - can be a value of |
48 | | - |
49 | | - * ``SDL_BLENDMODE_NONE`` for no blending |
50 | | - * ``SDL_BLENDMODE_BLEND`` for alpha blending |
51 | | - * ``SDL_BLENDMODE_ADD`` for additive color blending |
52 | | - * ``SDL_BLENDMODE_MOD`` for multiplied color blending |
53 | | - |
54 | | - .. attribute:: scale |
55 | | - |
56 | | - The horizontal and vertical drawing scale as two-value tuple. |
57 | | - |
58 | | - .. method:: clear([color=None]) |
59 | | - |
60 | | - Clears the rendering context with the currently set or passed |
61 | | - *color*. |
62 | | - |
63 | | - .. method:: copy(src : obj[, srcrect=None[, dstrect=None[, angle=0[, center=None[, flip=render.SDL_FLIP_NONE]]]]]) -> None |
64 | | - |
65 | | - Copies (blits) the passed *src*, which can be a :class:`TextureSprite` or |
66 | | - :class:`sdl2.SDL_Texture`, to the target of the |
67 | | - :class:`Renderer`. *srcrect* is the source rectangle to be used for |
68 | | - clipping portions of *src*. *dstrect* is the destination rectangle. |
69 | | - *angle* will cause the texture to be rotated around *center* by the given |
70 | | - degrees. *flip* can be one of the SDL_FLIP_* constants and will flip the |
71 | | - texture over its horizontal or vertical middle axis. If *src* is a |
72 | | - :class:`TextureSprite`, *angle*, *center* and *flip* will be set from |
73 | | - *src*'s attributes, if not provided. |
74 | | - |
75 | | - .. method:: draw_line(points : iterable[, color=None]) -> None |
76 | | - |
77 | | - Draws one or multiple lines on the rendering context. If *line* consists |
78 | | - of four values ``(x1, y1, x2, y2)`` only, a single line is drawn. If |
79 | | - *line* contains more than four values, a series of connected lines is |
80 | | - drawn. |
81 | | - |
82 | | - .. method:: draw_point(points : iterable[, color=None]) -> None |
83 | | - |
84 | | - Draws one or multiple points on the rendering context. The *points* |
85 | | - argument contains the x and y values of the points as simple sequence in |
86 | | - the form ``(point1_x, point1_y, point2_x, point2_y, ...)``. |
87 | | - |
88 | | - .. method:: draw_rect(rects : iterable[, color=None]) -> None |
89 | | - |
90 | | - Draws one or multiple rectangles on the rendering context. *rects* |
91 | | - contains sequences of four values denoting the x and y offset and width |
92 | | - and height of each individual rectangle in the form ``((x1, y1, w1, h1), |
93 | | - (x2, y2, w2, h2), ...)``. |
94 | | - |
95 | | - .. method:: fill(rects : iterable[, color=None]) -> None |
96 | | - |
97 | | - Fills one or multiple rectangular areas on the rendering context with |
98 | | - the current set or passed *color*. *rects* contains sequences of four |
99 | | - values denoting the x and y offset and width and height of each |
100 | | - individual rectangle in the form ``((x1, y1, w1, h1), (x2, y2, w2, h2), |
101 | | - ...)``. |
102 | | - |
103 | | - .. method:: present() -> None |
104 | | - |
105 | | - Refreshes the rendering context, causing changes to the render buffers |
106 | | - to be shown. |
| 9 | +.. automodule:: sdl2.ext.renderer |
| 10 | + :members: |
0 commit comments