Mercurial > pygame
diff src/pixelarray.doc @ 873:5f702ba03cc1
Minor PixelArray doc improvements. Updated WHATSNEW list.
| author | marcus |
|---|---|
| date | Fri, 04 Jan 2008 11:20:27 +0000 |
| parents | 31fa129efd0f |
| children | b46c37340132 |
line wrap: on
line diff
--- a/src/pixelarray.doc Fri Jan 04 08:08:30 2008 +0000 +++ b/src/pixelarray.doc Fri Jan 04 11:20:27 2008 +0000 @@ -1,13 +1,26 @@ pygame.PixelArray pygame Object for direct pixel access of surfaces -pygame.PixelArray(surface): return PixelArray +pygame.PixelArray(Surface): return PixelArray The PixelArray wraps up a 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 while +second axis. It supports slicing and row and pixel manipluation while inplace operations such as addition, subtraction, multiplication, division and slice assignments 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 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. + + pxarray = pygame.PixelArray (surface) + # Check, if the first pixel at the topleft corner is blue + if pxarray[0][0] == surface.map_rgb ((0, 0, 255)): + ... + During its lifetime, the PixelArray locks the surface, thus you explicitly have to delete it once its not used anymore and the surface should perform operations in the same scope.
