Data Fields
-----------
.. data:: __version__

  The version of the Pygame2 package as string.

.. data:: version_info

  The version of the Pygame2 package as value tuple. The tuple is of
  the form ``('major', 'minor', 'micro', 'releaselevel')``, where all
  values except the *releaselevel* are integers.

BufferProxy
-----------
.. class:: BufferProxy () -> BufferProxy

  Creates a new, empty BufferProxy.

  A buffer interface object that acts as a proxy on classes and
  attributes not featuring the buffer interface. A
  BufferProxy usually should be constructed from C code, not Python.


Attributes
^^^^^^^^^^
.. attribute:: BufferProxy.length

  Gets the size of the buffer data in bytes.

.. attribute:: BufferProxy.raw

  Gets the raw buffer data as string. The string may contain
  NUL bytes.

Methods
^^^^^^^
.. method:: BufferProxy.write (buffer, offset) -> None

  Writes raw data to the BufferProxy.

  Writes the raw data from *buffer* to the BufferProxy object,
  starting at the specified *offset* within the BufferProxy. If
  the length of the passed *buffer* exceeds the length of the
  BufferProxy (reduced by *offset*), an :exc:`IndexError` will
  be raised.


Color
-----
.. class:: Color (...) -> Color

  Creates a new Color object.

  The Color class represents RGBA color values using a value range of
  0-255. It allows basic arithmetic operations to create new colors,
  supports conversions to other color spaces such as HSV or HSL and lets
  you adjust single color channels. The following constructors are supported:

  * Color (0xAARRGGBB)
  * Color (0xRRGGBB)
  * Color (r, g, b, a)
  * Color (r, g, b)
  * Color ("0xRRGGBBAA")
  * Color ("#RRGGBBAA")
  * Color ("name")


  **Example:** ::
    
    from pygame2 import Color
    
    red = Color (255, 0, 0)
    green = Color (0x0000FF00)
    blue = Color ("blue")
    

Attributes
^^^^^^^^^^
.. attribute:: Color.a

  Gets or sets the alpha value of the Color.

.. attribute:: Color.b

  Gets or sets the blue value of the Color.

.. attribute:: Color.cmy

  The CMY representation of the Color. The CMY
  components are in the ranges C = [0, 1], M = [0, 1], Y = [0,
  1]. Note that this will not return the absolutely exact CMY values
  for the set RGB values in all cases. Due to the RGB mapping from
  0-255 and the CMY mapping from 0-1 rounding errors may cause the
  CMY values to differ slightly from what you might expect.

.. attribute:: Color.g

  Gets or sets the green value of the Color.

.. attribute:: Color.hsla

  The HSLA representation of the Color. The HSLA
  components are in the ranges H = [0, 360], S = [0, 100], L = [0, 100],
  A = [0, 100]. Note that this will not return the absolutely exact HSL
  values for the set RGB values in all cases. Due to the RGB mapping from
  0-255 and the HSL mapping from 0-100 and 0-360 rounding errors may cause
  the HSL values to differ slightly from what you might expect.

.. attribute:: Color.hsva

  The HSVA representation of the Color. The HSVA
  components are in the ranges H = [0, 360], S = [0, 100], V = [0, 100],
  A = [0, 100]. Note that this will not return the absolutely exact HSV
  values for the set RGB values in all cases. Due to the RGB mapping from
  0-255 and the HSV mapping from 0-100 and 0-360 rounding errors may cause
  the HSV values todiffer slightly from what you might expect.

.. attribute:: Color.i1i2i3

  The I1I2I3 representation of the Color.
  The I1I2I3 components are in the ranges I1 = [0, 1], I2 = [-0.5, 0.5],
  I3 = [-0.5, 0.5]. Note that this will not return the absolutely exact
  I1I2I3 values for the set RGB values in all cases. Due to the RGB mapping
  from 0-255 and the I1I2I3 from 0-1 rounding errors may cause the I1I2I3
  values to differ slightly from what you might expect.

.. attribute:: Color.r

  Gets or sets the red value of the Color.

Methods
^^^^^^^
.. method:: Color.correct_gamma (gamma) -> Color

  Applies a certain gamma value to the Color.

  Applies a certain gamma value to the Color and returns a new
  Color with the adjusted RGBA values.


.. method:: Color.normalize() -> (float, float, float, float)

  Returns the normalized RGBA values of the Color.

  Returns the normalized RGBA values of the Color as floating
  point values.


Error
-----
.. class:: Error (...) -> Error

  A specialized exception class that indicates a misbehavior within the
  pygame2 modules.


FRect
-----
.. class:: FRect (...) -> FRect

  A class for storing rectangular coordinates.

  A FRect is used to store and manipulate rectangular coordinates.


Attributes
^^^^^^^^^^
.. attribute:: FRect.bottom

  Gets or sets the bottom edge position of the FRect.

.. attribute:: FRect.bottomleft

  Gets or sets the bottom left corner position of the FRect.

.. attribute:: FRect.bottomright

  Gets or sets the bottom right corner position of the FRect.

.. attribute:: FRect.center

  Gets or sets the center position of the FRect.

.. attribute:: FRect.centerx

  Gets or sets the horizontal center position of the FRect.

.. attribute:: FRect.centery

  Gets or sets the vertical center position of the FRect.

.. attribute:: FRect.h

  Gets or sets the height of the FRect.

.. attribute:: FRect.height

  Gets or sets the height of the FRect.

.. attribute:: FRect.left

  Gets or sets the left edge position of the FRect.

.. attribute:: FRect.midbottom

  Gets or sets the mid bottom edge position of the FRect.

.. attribute:: FRect.midleft

  Gets or sets the mid left edge position of the FRect.

.. attribute:: FRect.midright

  Gets or sets the mid right edge position of the FRect.

.. attribute:: FRect.midtop

  Gets or sets the mid top edge position of the FRect.

.. attribute:: FRect.right

  Gets or sets the right position of the FRect.

.. attribute:: FRect.size

  Gets or sets the width and height of the FRect as
  2-value tuple.

.. attribute:: FRect.top

  Gets or sets the top edge position of the FRect.

.. attribute:: FRect.topleft

  Gets or sets the top left corner position of the FRect.

.. attribute:: FRect.topright

  Gets or sets the top right corner position of the FRect.

.. attribute:: FRect.w

  Gets or sets the width of the FRect.

.. attribute:: FRect.width

  Gets or sets the width of the FRect.

.. attribute:: FRect.x

  Gets or sets the horizontal top left position of the
  FRect.

.. attribute:: FRect.y

  Gets or sets the vertical top left position of the
  FRect.

Methods
^^^^^^^
.. method:: FRect.ceil () -> :class:`Rect`

  Creates a :class:`Rect` from the specified FRect.

  This creates a :class:`Rect` using the smallest integral values greater
  or equal to the FRect floating point values.


.. method:: FRect.clamp (frect) -> FRect

  Moves the rectangle inside another.

  Returns a new rectangle that is moved to be completely inside
  the argument FRect. If the rectangle is too large to
  fit inside, it is centered inside the argument FRect,
  but its size is not changed.


.. method:: FRect.clamp_ip (frect) -> None

  Moves the rectangle inside another, in place.

  Same as :meth:`clamp`, but operates in place.


.. method:: FRect.clip (frect) -> FRect

  Crops a rectangle inside another.

  Returns a new rectangle that is cropped to be completely inside
  the argument FRect. If the two rectangles do not
  overlap to begin with, a FRect with 0 size is
  returned. Thus it returns the area, in which both rects overlap.


.. method:: FRect.collidedict (dict[, checkvals, key]) -> key, value

  Test if one rectangle in a dictionary intersects.

  Returns the key and value of the first dictionary entry that
  collides with the FRect. If no collisions are found,
  None is returned. Depending on the *checkvals* argument either the
  keys or values of *dict* must be FRect objects. By default,
  the keys are checked.

  You can provide your own comparision function as *key*
  argument. The comparision function will take two arguments, the
  FRect itself and a key or value from the passed
  dictionary. It must return True or False ::

            def cmpfunc (rect1, rect2):
                ...
                return True



.. method:: FRect.collidedictall (dict[, checkvals, key]) -> [(key, value), ...]

  Test if all rectangles in a dictionary intersect.

  Returns a list of all the key and value pairs that intersect
  with the FRect. If no collisions are found an empty
  list is returned. Depending on the *checkvals* argument either the
  keys or values of the dict must be FRect objects. By
  default, the keys are checked.

  You can provide your own comparision function as *key*
  argument. The comparision function will take two arguments, the
  FRect itself and a key or value from the passed
  dictionary. It must return True or False ::

            def cmpfunc (rect1, rect2):
                ...
                return True



.. method:: FRect.collidelist (rects[, key]) -> int

  Test if one rectangle in a list intersects.

  Test whether the rectangle collides with any in a sequence of
  rectangles. The index of the first collision found is
  returned. If no collisions are found an index of -1 is returned.

  You can provide your own comparision function as *key*
  argument. The comparision function will take two arguments, the
  FRect itself and a key or value from the passed
  dictionary. It must return True or False ::

            def cmpfunc (rect1, rect2):
                ...
                return True


.. method:: FRect.collidelistall (rects[, key]) -> [int, ...]

  Test if all rectangles in a list intersect.

  Returns a list of all the indices that contain rectangles that
  collide with the FRect. If no intersecting rectangles
  are found, an empty list is returned.

  You can provide your own comparision function as *key*
  argument. The comparision function will take two arguments, the
  FRect itself and a key or value from the passed
  dictionary. It must return True or False ::

            def cmpfunc (rect1, rect2):
                ...
                return True


.. method:: FRect.collidepoint (x, y) -> bool
            FRect.collidepoint (point) -> bool

  Test if a point is inside a rectangle.

  Returns True if the given *point* is inside the rectangle. A point
  along the right or bottom edge is not considered to be inside
  the rectangle.


.. method:: FRect.colliderect (frect) -> bool

  Test if two rectangles overlap.

  Returns True if any portion of either rectangle overlap (except
  the top+bottom or left+right edges).


.. method:: FRect.contains (frect) -> bool

  Test if one rectangle is inside another.

  Returns True when the argument rectangle is completely inside
  the FRect.


.. method:: FRect.copy () -> FRect

  Creates a copy of the FRect.

  Returns a new FRect, that contains the same values as the
  caller.


.. method:: FRect.fit (frect) -> FRect

  Resize and move a rectangle with aspect ratio.

  Returns a new rectangle that is moved and resized to fit
  another. The aspect ratio of the original FRect is
  preserved, so the new rectangle may be smaller than the target
  in either width or height.


.. method:: FRect.floor () -> :class:`Rect`

  Creates a :class:`Rect` from the specified FRect.

  This creates a :class:`Rect` using the largest integral values less than
  or equal to the FRect floating point values.


.. method:: FRect.inflate (x, y) -> FRect
            FRect.inflate (size) -> FRect

  Grow or shrink the rectangle size.

  Returns a new rectangle with the size changed by the given
  offset. The rectangle remains centered around its current
  center. Negative values will shrink the rectangle.


.. method:: FRect.inflate_ip (x, y) -> None
            FRect.inflate_ip (size) -> None

  Grow or shrink the rectangle size, in place.

  Same as :meth:`inflate`, but operates in place.


.. method:: FRect.move (x, y) -> FRect
            FRect.move (point) -> FRect

  Moves the rectangle.

  Returns a new rectangle that is moved by the given offset. The *x*
  and *y* arguments can be any float or integer value, positive or
  negative.


.. method:: FRect.move_ip (x, y) -> None
            FRect.move_ip (point) -> FRect

  Moves the rectangle, in place.

  Same as :meth:`move`, but operates in place.


.. method:: FRect.round () -> :class`Rect`

  Creates a :class:`Rect` from the specified FRect.

  This creates a :class:`Rect` using the FRect floating
  point values rounded to the nearest integral value.


.. method:: FRect.trunc () -> :class:`Rect`

  Creates a :class:`Rect` from the specified FRect.

  This creates a :class:`Rect` using truncated integral values from the
  FRect floating point values.


.. method:: FRect.union (frect) -> FRect

  Joins two rectangles into one.

  Returns a new rectangle that completely covers the area of the
  two provided rectangles. There may be area inside the new FRect
  that is not covered by the originals.


.. method:: FRect.union_ip (frect) -> FRect

  Joins two rectangles into one, in place.

  Same as :meth:`union`, but operates in place.


Rect
----
.. class:: Rect (...) -> Rect

  A class for storing rectangular coordinates.

  A Rect is used to store and manipulate rectangular coordinates.


Attributes
^^^^^^^^^^
.. attribute:: Rect.bottom

  Gets or sets the bottom edge position of the Rect.

.. attribute:: Rect.bottomleft

  Gets or sets the bottom left corner position of the Rect.

.. attribute:: Rect.bottomright

  Gets or sets the bottom right corner position of the Rect.

.. attribute:: Rect.center

  Gets or sets the center position of the Rect.

.. attribute:: Rect.centerx

  Gets or sets the horizontal center position of the Rect.

.. attribute:: Rect.centery

  Gets or sets the vertical center position of the Rect.

.. attribute:: Rect.h

  Gets or sets the height of the Rect.

.. attribute:: Rect.height

  Gets or sets the height of the Rect.

.. attribute:: Rect.left

  Gets or sets the left edge position of the Rect.

.. attribute:: Rect.midbottom

  Gets or sets the mid bottom edge position of the Rect.

.. attribute:: Rect.midleft

  Gets or sets the mid left edge position of the Rect.

.. attribute:: Rect.midright

  Gets or sets the mid right edge position of the Rect.

.. attribute:: Rect.midtop

  Gets or sets the mid top edge position of the Rect.

.. attribute:: Rect.right

  Gets or sets the right position of the Rect.

.. attribute:: Rect.size

  Gets or sets the width and height of the Rect as
  2-value tuple.

.. attribute:: Rect.top

  Gets or sets the top edge position of the Rect.

.. attribute:: Rect.topleft

  Gets or sets the top left corner position of the Rect.

.. attribute:: Rect.topright

  Gets or sets the top right corner position of the Rect.

.. attribute:: Rect.w

  Gets or sets the width of the Rect.

.. attribute:: Rect.width

  Gets or sets the width of the Rect.

.. attribute:: Rect.x

  Gets or sets the horizontal top left position of the Rect.

.. attribute:: Rect.y

  Gets or sets the vertical top left position of the Rect.

Methods
^^^^^^^
.. method:: Rect.clamp (rect) -> Rect

  Moves the rectangle inside another.

  Returns a new rectangle that is moved to be completely inside
  the argument Rect. If the rectangle is too large to fit inside,
  it is centered inside the argument Rect, but its size is not
  changed.


.. method:: Rect.clamp_ip (rect) -> None

  Moves the rectangle inside another, in place.

  Same as :meth:`clamp`, but operates in place.


.. method:: Rect.clip (rect) -> Rect

  Crops a rectangle inside another.

  Returns a new rectangle that is cropped to be completely inside
  the argument Rect. If the two rectangles do not overlap
  to begin with, a Rect with 0 size is returned. Thus it
  returns the area, in which both rects overlap.


.. method:: Rect.collidedict (dict[, checkvals, key]) -> key, value

  Test if one rectangle in a dictionary intersects.

  Returns the key and value of the first dictionary entry that
  collides with the Rect. If no collisions are found,
  None is returned. Depending on the *checkvals* argument either the
  keys or values of the *dict* must be Rect objects. By
  default, the keys are checked.

  You can provide your own comparision function as *key*
  argument. The comparision function will take two arguments, the
  Rect itself and a key or value from the passed
  dictionary. It must return True or False ::

            def cmpfunc (rect1, rect2):
                ...
                return True


.. method:: Rect.collidedictall (dict[, checkvals, key]) -> [(key, value), ...]

  Test if all rectangles in a dictionary intersect.

  Returns a list of all the key and value pairs that intersect
  with the Rect. If no collisions are found an empty list
  is returned. Depending on the *checkvals* argument either the keys
  or values of the *dict* must be Rect objects. By default,
  the keys are checked.

  You can provide your own comparision function as *key*
  argument. The comparision function will take two arguments, the
  Rect itself and an key or value from the passed
  dictionary. It must return True or False ::

            def cmpfunc (rect1, rect2):
                ...
                return True


.. method:: Rect.collidelist (list[, key]) -> int

  Test if one rectangle in a list intersects.

  Test whether the rectangle collides with any in a sequence of
  rectangles. The index of the first collision found is
  returned. If no collisions are found an index of -1 is returned.

  You can provide your own comparision function as *key*
  argument. The comparision function will take two arguments, the
  Rect itself and an key or value from the passed
  dictionary. It must return True or False ::

            def cmpfunc (rect1, rect2):
                ...
                return True


.. method:: Rect.collidelistall (list[, key]) -> [int, ...]

  Test if all rectangles in a list intersect.

  Returns a list of all the indices that contain rectangles that
  collide with the Rect. If no intersecting rectangles are found,
  an empty list is returned.

  You can provide your own comparision function as *key*
  argument. The comparision function will take two arguments, the
  Rect itself and an key or value from the passed
  dictionary. It must return True or False ::

            def cmpfunc (rect1, rect2):
                ...
                return True


.. method:: Rect.collidepoint (x, y) -> bool
            Rect.collidepoint (point) -> bool

  Test if a point is inside a rectangle.

  Returns True if the given point is inside the rectangle. A point
  along the right or bottom edge is not considered to be inside
  the rectangle.


.. method:: Rect.colliderect (rect) -> bool

  Test if two rectangles overlap.

  Returns True if any portion of either rectangle overlap (except
  the top+bottom or left+right edges).


.. method:: Rect.contains (rect) -> bool

  Test if one rectangle is inside another.

  Returns True when the argument rectangle is completely inside
  the Rect.


.. method:: Rect.copy () -> Rect

  Creates a copy of the Rect.

  Returns a new Rect, that contains the same values as the
  caller.


.. method:: Rect.fit (rect) -> Rect

  Resize and move a rectangle with aspect ratio.

  Returns a new rectangle that is moved and resized to fit
  another. The aspect ratio of the original Rect is preserved, so
  the new rectangle may be smaller than the target in either width
  or height.


.. method:: Rect.inflate (x, y) -> Rect
            Rect.inflate (size) -> Rect

  Grow or shrink the rectangle size.

  Returns a new rectangle with the size changed by the given
  offset. The rectangle remains centered around its current
  center. Negative values will shrink the rectangle.


.. method:: Rect.inflate_ip (x, y) -> None
            Rect.inflate_ip (size) -> Rect

  Grow or shrink the rectangle size, in place.

  Same as :meth:`inflate`, but operates in place.


.. method:: Rect.move (x, y) -> Rect
            Rect.move (point) -> Rect

  Moves the rectangle.

  Returns a new rectangle that is moved by the given offset. The *x*
  and *y* arguments can be any integer value, positive or negative.


.. method:: Rect.move_ip (x, y) -> None
            Rect.move_ip (point) -> None

  Moves the rectangle, in place.

  Same as :meth:`move`, but operates in place.


.. method:: Rect.union (rect) -> Rect

  Joins two rectangles into one.

  Returns a new rectangle that completely covers the area of the
  two provided rectangles. There may be area inside the new Rect
  that is not covered by the originals.


.. method:: Rect.union_ip (rect) -> Rect

  Joins two rectangles into one, in place.

  Same as :meth:`union`, but operates in place.


Surface
-------
.. class:: Surface () -> Surface

  An abstract base class for arbitrary Surface objects.

  You should not instantiate this class directly.


Attributes
^^^^^^^^^^
.. attribute:: Surface.height

  Gets the height of the Surface.

.. attribute:: Surface.pixels

  Gets a buffer with the pixels of the Surface.

.. attribute:: Surface.size

  Gets the width and height of the Surface.

.. attribute:: Surface.width

  Gets the width of the Surface.

Methods
^^^^^^^
.. method:: Surface.blit (**kwds) -> object

  Performs a blit operation on the Surface.

  The behavior, arguments and return value depend on the concrete
  Surface implementation.


.. method:: Surface.copy () -> Surface

  Creates a copy of this Surface.

Font
----
.. class:: Font () -> Font

  An abstract base class for arbitrary Font objects.

  You should not instantiate this class directly.


Attributes
^^^^^^^^^^
.. attribute:: Font.height

  Gets the standard height of the Font typography.

.. attribute:: Font.size

  Gets the width and height of the Font typography.

.. attribute:: Font.name

  Gets the name of the loaded Font.

.. attribute:: Font.style

  Gets or sets the style used to render the Font.

Methods
^^^^^^^
.. method:: Font.render (**kwds) -> object

  Renders the specified text using the Font object. The exact input
  arguments and return value is dependand on each specific Font
  implementation.


.. method:: Font.copy () -> Font

  Creates a copy of this Font.


