File: rect.rst

package info (click to toggle)
pygame 1.9.6%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 12,060 kB
  • sloc: ansic: 59,765; python: 31,220; objc: 334; makefile: 57; cpp: 25
file content (74 lines) | stat: -rw-r--r-- 2,063 bytes parent folder | download
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
.. include:: ../common.txt

.. highlight:: c

******************************************
  Class Rect API exported by pygame.rect
******************************************

src_c/rect.c
============

This extension module defines Python type :py:class:`pygame.Rect`.

Header file: src_c/pygame.h

.. c:type:: GAME_Rect

   .. c:member:: int x

      Horizontal position of the top-left corner.

   .. c:member:: int y

      Vertical position of the top-left corner.

   .. c:member:: int w

      Width.

   .. c:member:: int h

      Height.

   A rectangle at (*x*, *y*) and of size (*w*, *h*).

   SDL 2: equivalent to SDL_Rect.

.. c:type:: pgRectObject

   .. c:member:: GAME_Rect r

   The Pygame rectangle type instance.

.. c:var:: PyTypeObject *pgRect_Type

   The Pygame rectangle object type pygame.Rect.

.. c:function:: GAME_Rect pgRect_AsRect(PyObject *obj)

   A macro to access the GAME_Rect field of a :py:class:`pygame.Rect` instance.

.. c:function:: PyObject* pgRect_New(SDL_Rect *r)

   Return a new :py:class:`pygame.Rect` instance from the SDL_Rect *r*.
   On failure, raise a Python exception and return *NULL*.

.. c:function:: PyObject* pgRect_New4(int x, int y, int w, int h)

   Return a new pygame.Rect instance with position (*x*, *y*) and
   size (*w*, *h*).
   On failure raise a Python exception and return *NULL*.

.. c:function:: GAME_Rect* pgRect_FromObject(PyObject *obj, GAME_Rect *temp)

   Translate a Python rectangle representation as a Pygame :c:type:`GAME_Rect`.
   A rectangle can be a length 4 sequence integers (x, y, w, h),
   or a length 2 sequence of position (x, y) and size (w, h),
   or a length 1 tuple containing a rectangle representation,
   or have a method *rect* that returns a rectangle.
   Pass a pointer to a locally declared c:type:`GAME_Rect` as *temp*.
   Do not rely on this being filled in; use the function's return value instead.
   On success return a pointer to a :c:type:`GAME_Rect` representation
   of the rectangle.
   One failure may raise a Python exception before returning *NULL*.