Commits

marcus  committed ad801b9

Added FRect.copy() and Rect.copy() methods (from trunk).
Merged alpha blending fix from trunk.
Fixed Color creation from integer and long values.
physics module components use a top-left alignment for the smallest
values now.
Added Color tests.

  • Participants
  • Parent commits 40c9428
  • Branches pgreloaded

Comments (0)

Files changed (20)

File doc/capi.rst

 Pygame2 C API
 =============
 
+Pygame2's C API 
+
 C API:
 
 .. toctree::

File doc/create_cref.py

             # Peserve spacings.
             l = l.replace (":const:", "       ")
             l = l.replace (":class:", "       ")
+            l = l.replace (":meth:", "      ")
+            l = l.replace (":ref:", "     ")
             l = l.replace ("`", " ")
         else:
             l = l.replace (":const:", "")
             l = l.replace (":class:", "")
+            l = l.replace (":meth:", "")
+            l = l.replace (":ref:", "")
             l = l.replace ("`", "")
         
         tmptext += l + "\\n"

File doc/modules.rst

 Pygame2 modules
 ===============
 
+This is the core documentation of the various python modules, Pygame2 offers.
+
 Modules:
 
 .. toctree::

File doc/src/base.xml

         the :class:`FRect`.
       </desc>
     </method>
+    <method name="copy">
+      <call>copy () -> FRect</call>
+      <desc>
+        Creates a copy of the :class:`FRect`.
+
+        Returns a new :class:`FRect`, that contains the same values as the
+        caller.
+      </desc>
+    </method>
     <method name="fit">
       <call>fit (FRect) -> FRect</call>
       <desc>
         the :class:`Rect`.
       </desc>
     </method>
+    <method name="copy">
+      <call>copy () -> Rect</call>
+      <desc>
+        Creates a copy of the :class:`Rect`.
+
+        Returns a new :class:`Rect`, that contains the same values as the
+        caller.
+      </desc>
+    </method>
     <method name="fit">
       <call>fit (Rect) -> Rect</call>
       <desc>

File doc/src/sdlcdrom.xml

       forth.
     </desc>
     <method name="close">
-      <call>CD.close () -> None</call>
+      <call>close () -> None</call>
       <desc>
         Releases the CD internals. Useful for e.g. switching CDs within
         the drive without the need to recreate the CD object. CD.open()
     </attr>
     <attr name="cur_track">The current track</attr>
     <method name="eject">
-      <call>CD.eject () -> None</call>
+      <call>eject () -> None</call>
       <desc>Ejects the CD or DVD.</desc>
     </method>
     <attr name="index">The drive index as specified in the constructor.</attr>
     </attr>
     <attr name="num_tracks">The total number of tracks on the CD or DVD</attr>
     <method name="open">
-      <call>CD.open () -> None</call>
+      <call>open () -> None</call>
       <desc>
         (Re-)Opens the CD and initialises the CD object internals after
         a CD.close() call.
       </desc>
     </method>
     <method name="pause">
-      <call>CD.pause () -> None</call>
+      <call>pause () -> None</call>
       <desc>
         Pauses the actual CD playback.
       </desc>
     </method>
     <method name="play">
-      <call>CD.play (start, length[, asfps]) -> None</call>
+      <call>play (start, length[, asfps]) -> None</call>
       <desc>
         Starts playing the current CD beginning at the give start time
         for a maximum of length seconds. The start and length arguments
       </desc>
     </method>
     <method name="play_tracks">
-      <call>
-        CD.play_tracks ([starttrack, ntracks, start, length, asfps]) -> None
-      </call>
+      <call>play_tracks ([starttrack, ntracks, start, length, asfps]) -> None</call>
       <desc>
         Plays a certain number of tracks beginning at the passed start
         track. If start and length are not 0, start determines the
       </desc>
     </method>
     <method name="resume">
-      <call>CD.resume () -> None</call>
+      <call>resume () -> None</call>
       <desc>Resumes a previously paused playback.</desc>
     </method>
     <attr name="status">Gets the current CD status.</attr>
     <method name="stop">
-      <call>CD.stop () -> None</call>
+      <call>stop () -> None</call>
       <desc>Stops the current playback.</desc>
     </method>
     <attr name="tracks">

File doc/src/sdlextbase.xml

   <class name="PixelArray">
     <constructor>PixelArray (surface) -> PixelArray</constructor>
     <desc>
-      Creates a new PixelArray from the specified pygame2.sdl.Surface.
+      Creates a new PixelArray from the specified :class:`pygame2.sdl.video.Surface`.
 
-      The PixelArray wraps up a Surface and provides a direct 2D array
+      The :class:`PixelArray` wraps up a :class:`pygame2.sdl.video.Surface` and provides a direct 2D array
       access to its pixels using the surface its rows as first and its
       columns as second axis. It supports slicing, row and pixel
       manipluation, slicing and slice assignments while inplace
       and so forth are not allowed.
 
       While it is possible to assign both, integer color values and
-      RGB(A) color tuples, the PixelArray will only use integers for the
+      RGB(A) color tuples, the :class:`PixelArray` will only use integers for the
       color representation. Thus, checking for certain colors has to be
-      done using the Surface.map_rgb() method of the surface , the
-      PixelArray was created for. ::
+      done using the :meth:`pygame2.sdl.video.Surface.map_rgb()` method of the surface, the
+      :class:`PixelArray` was created for. ::
 
         pxarray = pygame.PixelArray (surface)
         # Check, if the first pixel at the topleft corner is blue
       surface should perform operations in the same scope.
     </desc>
     <method name="compare">
-      <call>PixelArray.compare (array, distance=0, weights=(0.299, 0.587, 0.114)) -> PixelArray</call>
+      <call>compare (array, distance=0, weights=(0.299, 0.587, 0.114)) -> PixelArray</call>
       <desc>
-        Compares the PixelArray with another one.
+        Compares the :class:`PixelArray` with another one.
 
-        Compares the contents of the PixelArray with those from the
-        passed PixelArray. It returns a new PixelArray with a
+        Compares the contents of the :class:`PixelArray` with those from the
+        passed :class:`PixelArray`. It returns a new :class:`PixelArray` with a
         black/white color mask that indicates the differences (white) of
-        both arrays. Both PixelArray objects must have indentical bit
+        both arrays. Both :class:`PixelArray` objects must have indentical bit
         depths and dimensions.
 
         It uses a simple weighted euclidian distance formula to
       </desc>
     </method>
     <method name="extract">
-      <call>PixelArray.extract (color, distance=0, weights=(0.299, 0.587, 0.114)) -> PixelArray</call>
+      <call>extract (color, distance=0, weights=(0.299, 0.587, 0.114)) -> PixelArray</call>
       <desc>
-        Extracts the passed color from the PixelArray.
+        Extracts the passed color from the :class:`PixelArray`.
 
         Extracts the passed color by changing all matching pixels to
         white, while non-matching pixels are changed to black. This
-        returns a new PixelArray with the black/white color mask. It
+        returns a new :class:`PixelArray` with the black/white color mask. It
         uses a simple weighted euclidian distance formula to calculate
         the distance between the colors. The distance space ranges from
         0.0 to 1.0 and is used as threshold for the color detection.
       </desc>
     </method>
     <method name="make_surface">
-      <call>PixelArray.make_surface () -> pygame2.sdl.Surface</call>
+      <call>make_surface () -> pygame2.sdl.Surface</call>
       <desc>
-        Creates a new Surface from the current PixelArray.
+        Creates a new Surface from the current :class:`PixelArray`.
 
-        Creates a new Surface from the current PixelArray. Depending on
+        Creates a new Surface from the current :class:`PixelArray`. Depending on
         the current PixelArray the size, pixel order etc. will be
-        different from the original Surface. ::
+        different from the original :class:`pygame2.sdl.video.Surface`. ::
 
           # Create a new surface flipped around the vertical axis.
           sf = pxarray[:,::-1].make_surface ()
       </desc>
     </method>
     <method name="replace">
-      <call>PixelArray.replace (color, repcolor, distance=0, weights=(0.299, 0.587, 0.114)) -> None</call>
+      <call>replace (color, repcolor, distance=0, weights=(0.299, 0.587, 0.114)) -> None</call>
       <desc>
-        Replaces the passed color in the PixelArray with another one.
+        Replaces the passed color in the :class:`PixelArray` with another one.
 
-        Replaces the pixels with the passed color in the PixelArray by
+        Replaces the pixels with the passed color in the :class:`PixelArray` by
         changing them them to the passed replacement color. It uses a
         simple weighted euclidian distance formula to calculate the
         distance between the colors. The distance space ranges from 0.0
         exactly identical color, into account as well.
 
         This is an in place operation that directly affects the pixels
-        of the PixelArray.
+        of the :class:`PixelArray`.
       </desc>
     </method>
-    <attr name="surface">Gets the pygame2.sdl.Surface the PixelArray uses.</attr>
+    <attr name="surface">
+      Gets the Surface the :class:`PixelArray` uses.
+    </attr>
   </class>
 
 </module>

File doc/src/sdlextdraw.xml

 
 <module name="pygame2.sdlext.draw">
   <short>extended SDL drawing methods</short>
-  <desc>None</desc>
+  <desc>Extension module containing simple 2D drawing methods for the pygame2
+    SDL modules. Several methods utilise code from the SDL_gfx library, and 
+    were optimised and changed in several ways.
+   </desc>
 
   <func name="aaline">
-    <call></call>
-    <desc></desc>
+    <call>aaline (surface, color, (x1, y1), (x2, y2) [, blend]) -> Rect</call>
+    <desc>Draws a fine anti-aliased line.
+      
+      Draws an anti-aliased line on a surface. This will respect the
+      clipping rectangle. A bounding box of the affected area is returned
+      as a rectangle. If blend is true, the shades will be be blended with
+      existing pixel shades instead of overwriting them.
+    </desc>
   </func>
   <func name="aalines">
     <call></call>
     <desc></desc>
   </func>
   <func name="line">
-    <call></call>
-    <desc></desc>
+    <call>line (surface, color, (x1, y1), (x2, y2) [, width]) -> Rect</call>
+    <desc>Draws a straight line segment on a surface.
+
+      Draws a straight line segment on a surface with an optionally specified
+      line width. If the width argument is omitted, the line will be 1px thick.
+      There are no endcaps, the ends are squared off for thick lines.
+    </desc>
   </func>
   <func name="lines">
     <call></call>

File doc/src/sdlvideo.xml

   </class>
 
   <class name="Surface">
-    <constructor>TODO</constructor>
-    <desc></desc>
+    <constructor>Surface () -> Surface</constructor>
+    <desc>Creates a new Surface</desc>
     <method name="blit">
       <call></call>
       <desc></desc>

File src/base/basemod.c

     return 1;
 }
 
-#if PY_VERSION_HEX >= 0x03000000
+#ifdef IS_PYTHON_3
 PyMODINIT_FUNC PyInit_base (void)
 #else
 PyMODINIT_FUNC initbase (void)
 {
     static void* c_api[PYGAME_BASE_SLOTS];
 
-#if PY_VERSION_HEX >= 0x03000000
+#ifdef IS_PYTHON_3
     static struct PyModuleDef _basemodule = {
         PyModuleDef_HEAD_INIT, "base", DOC_BASE, -1, _base_methods,
         NULL, NULL, NULL, NULL
     Py_INCREF (&PyRect_Type);
     Py_INCREF (&PyBufferProxy_Type);
 
-#if PY_VERSION_HEX < 0x03000000
+#ifdef IS_PYTHON_3
+    mod = PyModule_Create (&_basemodule);
+#else
     mod = Py_InitModule3 ("base", _base_methods, DOC_BASE);
-#else
-    mod = PyModule_Create (&_basemodule);
 #endif
     if (!mod)
         MODINIT_RETURN(NULL);

File src/base/bufferproxy.c

 static PyObject* _bufferproxy_write (PyBufferProxy *buffer, PyObject *args);
 
 /* Buffer methods */
-#if PY_VERSION_HEX < 0x03000000
+#ifndef IS_PYTHON_3
 static Py_ssize_t _bufferproxy_getreadbuf (PyBufferProxy *buffer,
     Py_ssize_t _index, const void **ptr);
 static Py_ssize_t _bufferproxy_getwritebuf (PyBufferProxy *buffer,
     { NULL, NULL, NULL, NULL, NULL }
 };
 
-#if PY_VERSION_HEX < 0x03000000
+#ifndef IS_PYTHON_3
 /**
  * Buffer interface support for the PyBufferProxy.
  */
     0,                          /* tp_str */
     0,                          /* tp_getattro */
     0,                          /* tp_setattro */
-#if PY_VERSION_HEX < 0x03000000
+#ifndef IS_PYTHON_3
     &_bufferproxy_as_buffer,    /* tp_as_buffer */
 #else
     0, /* TODO */
 }   
 
 /*Buffer interfaces */
-#if PY_VERSION_HEX < 0x03000000
+#ifndef IS_PYTHON_3
 
 static Py_ssize_t
 _bufferproxy_getreadbuf (PyBufferProxy *buffer, Py_ssize_t _index,
     return 1;
 }
 
-#endif /* PY_VERSION_HEX < 0x03000000 */
+#endif /* #ifndef IS_PYTHON_3 */
 
 /* C API */
 static PyObject*

File src/base/color.c

 
 static PyNumberMethods _color_as_number =
 {
-#if PY_VERSION_HEX < 0x03000000
+#ifndef IS_PYTHON_3
     (binaryfunc) _color_add, /* nb_add */
     (binaryfunc) _color_sub, /* nb_subtract */
     (binaryfunc) _color_mul, /* nb_multiply */
     if (!val || !color)
         return 0;
 
-    if (IntFromObj (val, &intval))
-        *color = (pguint32) intval;
-    else if (PyLong_Check (val))
+    if (PyLong_Check (val))
     {
         unsigned long longval;
         PyErr_Clear (); /* Clear any error from IntFromObj */
         *color = (pguint32) longval;
         return 1;
     }
+    else if (IntFromObj (val, &intval))
+        *color = (pguint32) intval;
     else
     {
         PyErr_SetString (PyExc_ValueError, "invalid color argument");

File src/base/floatrect.c

     void *closure);
 
 static PyObject* _frect_clip (PyObject* self, PyObject *args);
+static PyObject* _frect_copy (PyObject* self);
 static PyObject* _frect_move (PyObject* self, PyObject *args);
 static PyObject* _frect_move_ip (PyObject* self, PyObject *args);
 static PyObject* _frect_union (PyObject* self, PyObject *args);
  */
 static PyMethodDef _frect_methods[] = {
     { "clip", _frect_clip, METH_VARARGS, DOC_BASE_FRECT_CLIP },
+    { "copy", (PyCFunction)_frect_copy, METH_NOARGS, DOC_BASE_FRECT_COPY },
     { "move", _frect_move, METH_VARARGS, DOC_BASE_FRECT_MOVE },
     { "move_ip",  _frect_move_ip, METH_VARARGS, DOC_BASE_FRECT_MOVE_IP },
     { "union",  _frect_union, METH_VARARGS, DOC_BASE_FRECT_UNION},
 }
 
 static PyObject*
+_frect_copy (PyObject* self)
+{
+    return PyFRect_New (((PyFRect*)self)->x, ((PyFRect*)self)->y,
+        ((PyFRect*)self)->w, ((PyFRect*)self)->h);
+}
+
+static PyObject*
 _frect_move (PyObject* self, PyObject *args)
 {
     PyFRect *frect = (PyFRect*) self;

File src/base/rect.c

     void *closure);
 
 static PyObject* _rect_clip (PyObject* self, PyObject *args);
+static PyObject* _rect_copy (PyObject* self);
 static PyObject* _rect_move (PyObject* self, PyObject *args);
 static PyObject* _rect_move_ip (PyObject* self, PyObject *args);
 static PyObject* _rect_union (PyObject* self, PyObject *args);
  */
 static PyMethodDef _rect_methods[] = {
     { "clip", _rect_clip, METH_VARARGS, DOC_BASE_RECT_CLIP },
+    { "copy", (PyCFunction)_rect_copy, METH_NOARGS, DOC_BASE_RECT_COPY },
     { "move", _rect_move, METH_VARARGS, DOC_BASE_RECT_MOVE },
     { "move_ip",  _rect_move_ip, METH_VARARGS, DOC_BASE_RECT_MOVE_IP },
     { "union",  _rect_union, METH_VARARGS, DOC_BASE_RECT_UNION },
 }
 
 static PyObject*
+_rect_copy (PyObject* self)
+{
+    return PyRect_New (((PyRect*)self)->x, ((PyRect*)self)->y,
+        ((PyRect*)self)->w, ((PyRect*)self)->h);
+}
+
+static PyObject*
 _rect_move_ip (PyObject* self, PyObject *args)
 {
     PyRect *rect = (PyRect*) self;

File src/physics/aabbox.c

 int
 AABBox_Overlaps (AABBox* boxA, AABBox* boxB, double eps)
 {
-    double from_x, from_y, to_x, to_y;
-
     if (!boxA || !boxB)
     {
         PyErr_SetString (PyExc_TypeError, "arguments must not be NULL");
         return 0;
     }
 
-    from_x = MAX (boxA->left, boxB->left);
-    from_y = MAX (boxA->bottom, boxB->bottom);
-    to_x = MIN (boxA->right, boxB->right);
-    to_y = MIN (boxA->top, boxB->top);
-
-    return (from_x - eps <= to_x + eps) && (from_y - eps <= to_y + eps);
+    /* TODO: add eps threshold */
+    if (((boxA->left >= boxB->left && boxA->left < boxB->right)  ||
+         (boxB->left >= boxA->left && boxB->left < boxA->right)) &&
+        ((boxA->top >= boxB->top && boxA->top < boxB->bottom) ||
+        (boxB->top >= boxA->top && boxB->top < boxA->bottom)))
+        return 1;
+    return 0;
 }
 
 int
         return 0;
     }
     return box->left - eps < p->real && p->real < box->right + eps
-        && box->bottom - eps < p->imag && p->imag < box->top + eps;
+        && box->bottom - eps > p->imag && p->imag > box->top + eps;
 }
 
 PyObject*

File src/physics/collision.c

         ret = (q < 0) ? 0 : 1;         \
     else                               \
     {                                  \
-        double _val = q / p;           \
         if (p < 0)                     \
-            u1 = MAX (u1, _val);       \
+            u1 = MAX (u1, q / p);      \
         else                           \
-            u2 = MIN (u2, _val);       \
+            u2 = MIN (u2, q / p);      \
         ret = 1;                       \
     }
 
         u1 = 0.f;
         u2 = 1.f;
         dp = c_diff (vertices[i], vertices[i1]);
-        CLIP_LB (-dp.real, vertices[i].real - box->left, u1, u2, ret);
+        
+        CLIP_LB (dp.real, vertices[i].real - box->left, u1, u2, ret);
         if (!ret)
             continue;
-        CLIP_LB (dp.real, box->right - vertices[i].real, u1, u2, ret);
+        CLIP_LB (-dp.real, box->right - vertices[i].real, u1, u2, ret);
         if (!ret)
             continue;
-        CLIP_LB (-dp.imag, vertices[i].imag - box->bottom, u1, u2, ret);
+        CLIP_LB (dp.imag, vertices[i].imag - box->bottom, u1, u2, ret);
         if (!ret)
             continue;
-        CLIP_LB (dp.imag, box->top - vertices[i].imag, u1, u2, ret);
+        CLIP_LB (-dp.imag, box->top - vertices[i].imag, u1, u2, ret);
         if (!ret)
             continue;
         

File src/sdl/surface.h

  * where all additions are done before the shift, is needed.
 */
 #if (-1 >> 1) < 0
-#define ALPHA_BLEND_COMP(sC, dC, dA) ((((sC - dC) * sA + sC) >> 8) + dC)
+#define ALPHA_BLEND_COMP(sC, dC, sA) ((((sC - dC) * sA + sC) >> 8) + dC)
 #else
-#define ALPHA_BLEND_COMP(sC, dC, dA) (((dC << 8) + (sC - dC) * sA + sC) >> 8)
+#define ALPHA_BLEND_COMP(sC, dC, sA) (((dC << 8) + (sC - dC) * sA + sC) >> 8)
 #endif
 
 #define ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB, dA) \
     do {                                            \
         if (dA)                                     \
         {                                           \
-            dR = ALPHA_BLEND_COMP(sR, dR, dA);      \
-            dG = ALPHA_BLEND_COMP(sG, dG, dA);      \
-            dB = ALPHA_BLEND_COMP(sB, dB, dA);      \
+            dR = ALPHA_BLEND_COMP(sR, dR, sA);      \
+            dG = ALPHA_BLEND_COMP(sG, dG, sA);      \
+            dB = ALPHA_BLEND_COMP(sB, dB, sA);      \
             dA = sA + dA - ((sA * dA) / 255);       \
         }                                           \
         else                                        \

File test/base_color_test.py

 
 ################################################################################
 
-    def todo_test_pygame2_base_Color_a(self):
+    def test_pygame2_base_Color_a(self):
 
         # __doc__ (as of 2008-10-17) for pygame2.base.Color.a:
 
         # Gets or sets the alpha value of the Color.
+        c = Color (100, 100, 100)
+        self.assertEquals (c.a, 255)
+        
+        c = Color (100, 100, 100, 100)
+        self.assertEquals (c.a, 100)
+        
+        c = Color (100, 100, 100)
+        self.assertEquals (c.a, 255)
+        c.a = 200
+        self.assertEquals (c.a, 200)
+        c.a += 22
+        self.assertEquals (c.a, 222)
+        
+        c = Color (0xAABBCCDD)
+        self.assertEquals (c.a, 0xAA)
+        
+        c = Color ("0xBBCCDD")
+        self.assertEquals (c.a, 0xFF)
+        c = Color ("0xAABBCCDD")
+        self.assertEquals (c.a, 0xDD)
+        
+        c = Color ("#AABBCCDD")
+        self.assertEquals (c.a, 0xDD)
+        c = Color ("#BBCCDD")
+        self.assertEquals (c.a, 0xFF)
+        
+        c = Color ("red")
+        self.assertEquals (c.a, 255)
 
-        self.fail() 
-
-    def todo_test_pygame2_base_Color_b(self):
+    def test_pygame2_base_Color_b(self):
 
         # __doc__ (as of 2008-10-17) for pygame2.base.Color.b:
 
         # Gets or sets the blue value of the Color.
-
-        self.fail() 
+        c = Color (100, 100, 100)
+        self.assertEquals (c.b, 100)
+        
+        c = Color (100, 100, 100, 100)
+        self.assertEquals (c.b, 100)
+        
+        c = Color (100, 100, 100)
+        self.assertEquals (c.b, 100)
+        c.b = 200
+        self.assertEquals (c.b, 200)
+        c.b += 22
+        self.assertEquals (c.b, 222)
+        
+        c = Color (0xAABBCCDD)
+        self.assertEquals (c.b, 0xDD)
+        
+        c = Color ("0xBBCCDD")
+        self.assertEquals (c.b, 0xDD)
+        c = Color ("0xAABBCCDD")
+        self.assertEquals (c.b, 0xCC)
+        
+        c = Color ("#AABBCCDD")
+        self.assertEquals (c.b, 0xCC)
+        c = Color ("#BBCCDD")
+        self.assertEquals (c.b, 0xDD)
+        
+        c = Color ("red")
+        self.assertEquals (c.b, 0)
+        c = Color ("blue")
+        self.assertEquals (c.b, 255)
 
     def todo_test_pygame2_base_Color_cmy(self):
 
 
         self.fail() 
 
-    def todo_test_pygame2_base_Color_g(self):
+    def test_pygame2_base_Color_g(self):
 
         # __doc__ (as of 2008-10-17) for pygame2.base.Color.g:
 
         # Gets or sets the green value of the Color.
 
-        self.fail() 
+        c = Color (100, 100, 100)
+        self.assertEquals (c.g, 100)
+        
+        c = Color (100, 100, 100, 100)
+        self.assertEquals (c.g, 100)
+        
+        c = Color (100, 100, 100)
+        self.assertEquals (c.g, 100)
+        c.g = 200
+        self.assertEquals (c.g, 200)
+        c.g += 22
+        self.assertEquals (c.g, 222)
+        
+        c = Color (0xAABBCCDD)
+        self.assertEquals (c.g, 0xCC)
+        
+        c = Color ("0xBBCCDD")
+        self.assertEquals (c.g, 0xCC)
+        c = Color ("0xAABBCCDD")
+        self.assertEquals (c.g, 0xBB)
+        
+        c = Color ("#AABBCCDD")
+        self.assertEquals (c.g, 0xBB)
+        c = Color ("#BBCCDD")
+        self.assertEquals (c.g, 0xCC)
+        
+        c = Color ("red")
+        self.assertEquals (c.g, 0)
+        c = Color ("green")
+        self.assertEquals (c.g, 255)
 
     def todo_test_pygame2_base_Color_hsla(self):
 
         # __doc__ (as of 2008-10-17) for pygame2.base.Color.r:
 
         # Gets or sets the red value of the Color.
-
-        self.fail() 
+        
+        c = Color (100, 100, 100)
+        self.assertEquals (c.r, 100)
+        
+        c = Color (100, 100, 100, 100)
+        self.assertEquals (c.r, 100)
+        
+        c = Color (100, 100, 100)
+        self.assertEquals (c.r, 100)
+        c.r = 200
+        self.assertEquals (c.r, 200)
+        c.r += 22
+        self.assertEquals (c.r, 222)
+        
+        c = Color (0xAABBCCDD)
+        self.assertEquals (c.r, 0xBB)
+        
+        c = Color ("0xBBCCDD")
+        self.assertEquals (c.r, 0xBB)
+        c = Color ("0xAABBCCDD")
+        self.assertEquals (c.r, 0xAA)
+        
+        c = Color ("#AABBCCDD")
+        self.assertEquals (c.r, 0xAA)
+        c = Color ("#BBCCDD")
+        self.assertEquals (c.r, 0xBB)
+        
+        c = Color ("red")
+        self.assertEquals (c.r, 255)
+        c = Color ("blue")
+        self.assertEquals (c.r, 0)
 
 if __name__ == "__main__":
     unittest.main ()

File test/base_frect_test.py

                      "r contains Rect(4,6,1,1)" )
         self.failIf( r.contains( FRect(4,6,0,0) ),
                      "r contains Rect(4,6,0,0)" )
+    
+    def todo_test_pygame2_base_FRect_copy(self):
+
+        # __doc__ (as of 2009-02-23) for pygame2.base.FRect.copy:
+
+        # copy () -> FRect
+        #
+        # Creates a copy of the FRect.
+        #
+        # Returns a new FRect, that contains the same values as the
+        # caller.
+
+        self.fail()
 
     def todo_test_pygame2_base_FRect_fit(self):
 

File test/base_rect_test.py

                      "r contains Rect(4,6,1,1)" )
         self.failIf( r.contains( Rect(4,6,0,0) ),
                      "r contains Rect(4,6,0,0)" )
+    
+    def todo_test_pygame2_base_Rect_copy(self):
 
+        # __doc__ (as of 2009-02-23) for pygame2.base.Rect.copy:
+
+        # copy () -> Rect
+        #
+        # Creates a copy of the Rect.
+        #
+        # Returns a new Rect, that contains the same values as the
+        # caller.
+
+        self.fail()
+        
     def todo_test_pygame2_base_Rect_fit(self):
 
         # __doc__ (as of 2008-10-17) for pygame2.base.Rect.fit:

File test/c_api/physics_tests.c

 
     AABBox_Reset (&b);
     if (b.left != DBL_MAX || b.right != -DBL_MAX || 
-        b.bottom != DBL_MAX || b.top != -DBL_MAX)
+        b.bottom != -DBL_MAX || b.top != DBL_MAX)
         ERROR ("Mismatch in AABBox_Reset");
 
     PyVector2_Set (v, 10, 10);
     AABBox_ExpandTo (&a, &v);
-    if (a.left != 1 || a.right != 10 || a.bottom != 3 || a.top != 10)
+    if (a.left != 1 || a.right != 10 || a.bottom != 10 || a.top != 4)
         ERROR ("Mismatch in AABBox_ExpandTo");
 
     b = AABBox_New (2, 4, 6, 8);
     rect = AABBox_AsFRect (&a);
     if (!rect || !PyFRect_Check (rect))
         ERROR ("Mismatch in AABBox_AsFRect return value");
-    if (((PyFRect*)rect)->x != 1 || ((PyFRect*)rect)->y != 10 ||
-        ((PyFRect*)rect)->w != 9 || ((PyFRect*)rect)->h != 7)
+    if (((PyFRect*)rect)->x != 1 || ((PyFRect*)rect)->y != 4 ||
+        ((PyFRect*)rect)->w != 9 || ((PyFRect*)rect)->h != 6)
         ERROR ("Mismatch in AABBox_AsFRect");
 
     seq = PyTuple_New (4);
 
     if (!AABBox_FromRect (rect, &c))
         ERROR ("Mismatch in AABBox_FromRect creation");
-    if (!IS_NEAR_ZERO (c.top - 10.f) || !IS_NEAR_ZERO (c.left - 1.f) ||
-        !IS_NEAR_ZERO (c.bottom - 17.f) || !IS_NEAR_ZERO (c.right - 10.f))
+    if (!IS_NEAR_ZERO (c.top - 4.f) || !IS_NEAR_ZERO (c.left - 1.f) ||
+        !IS_NEAR_ZERO (c.bottom - 10.f) || !IS_NEAR_ZERO (c.right - 10.f))
         ERROR ("Mismatch in AABBox_FromRect");
     
     Py_DECREF (rect);