File: sdl2ext_draw.rst

package info (click to toggle)
pysdl2 0.9.7%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,824 kB
  • sloc: python: 17,244; makefile: 195; sh: 32
file content (44 lines) | stat: -rw-r--r-- 1,796 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
.. currentmodule:: sdl2.ext

2D drawing routines for software surfaces
=========================================

.. note::

   The drawing functions within this module are unoptimised and should not be
   considered fast. If you want improved drawing of 2D primitives, including
   hardware acceleration, you should use the methods of the
   :class:`Renderer` instead.

.. function:: prepare_color(color : object, target : object) -> int

   Prepares the passed *color* for a specific *target*. *color* can be any
   object type that can be processed by
   :func:`convert_to_color()`. *target* can be any
   :class:`sdl2.SDL_PixelFormat`, :class:`sdl2.SDL_Surface` or
   :class:`SoftwareSprite` instance.

   The returned integer will be a color value matching the target's pixel
   format.

.. function:: fill(target : object, color : object[, area=None]) -> None

   Fills a certain area on the passed *target* with a *color*. If no *area* is
   provided, the entire target will be filled with  the passed color. If an
   iterable item is provided as *area* (such as a list or tuple), it will be
   first checked, if the item denotes a single rectangular area
   (4 integer values) before assuming it to be a sequence of rectangular areas
   to fill with the color.

   *target* can be any :class:`sdl2.SDL_Surface` or :class:`SoftwareSprite`
   instance.

.. function:: line(target : object, color : object[, width=1]) -> None

   Draws one or multiple lines on the passed *target*. *line* can be a
   sequence of four integers for a single line in the form ``(x1, y1,
   x2, y2)`` or a sequence of a multiple of 4 for drawing multiple lines
   at once, e.g. ``(x1, y1, x2, y2, x3, y3, x4, y4, ...)``.

   *target* can be any :class:`sdl2.SDL_Surface` or :class:`SoftwareSprite`
   instance.