diff examples/pixelarray.py @ 852:4db78800a93a

A PixelArray class, which is meant to replace surfarray. It acts as a buffer for surface data. Written by Marcus. It's not quite complete, but basic functionality is implemented.
author Rene Dudfield <renesd@gmail.com>
date Wed, 22 Aug 2007 08:10:12 +0000
parents
children 41b22371307e
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/pixelarray.py	Wed Aug 22 08:10:12 2007 +0000
@@ -0,0 +1,32 @@
+# 8 bit and 24 bit surfaces are currently broken
+import pygame
+from pygame.locals import *
+
+pygame.init ()
+
+screen = pygame.display.set_mode ((400, 400))
+screen.fill ((100, 100, 100))
+
+sf = pygame.Surface ((50, 50))
+
+sf.fill ((0,0,0))
+rect = sf.get_rect ()
+screen.blit (sf, (50, 50))
+pygame.display.flip ()
+
+while 1:
+    event = pygame.event.wait ()
+    if event.type == QUIT:
+        break
+    if event.type == KEYDOWN:
+        if event.key == K_m:
+            print "Creating array"
+            ar = pygame.PixelArray (sf)
+            ar[3] = 0xffffff
+            ar[-2] = 0x808080
+            for i in xrange (rect.w):
+                ar[i][2] = (100, 100, 200)
+            del ar
+
+            screen.blit (sf, (50, 50))
+            pygame.display.flip ()