Source

pygame / examples / blit_blends.py

Diff from to

examples/blit_blends.py

     blits[K_EQUALS] = BLEND_MAX
     blits[K_MINUS] = BLEND_MIN
 
+    blitsn = {}
+    blitsn[K_a] = "BLEND_ADD"
+    blitsn[K_s] = "BLEND_SUB"
+    blitsn[K_m] = "BLEND_MULT"
+    blitsn[K_EQUALS] = "BLEND_MAX"
+    blitsn[K_MINUS] = "BLEND_MIN"
+
 
     screen.blit(im1, (0, 0))
     pygame.display.flip()
                 print "one pixel is:%s:" % [im1.get_at((0,0))]
                 print "time to do:%s:" % (t2-t1)
 
+
+            elif event.type == KEYDOWN and event.key in [K_t]:
+
+                for bkey in blits.keys():
+                    t1 = time.time()
+
+                    for x in range(300):
+                        im1.blit(img_to_blit, (0,0), None, blits[bkey])
+
+                    t2 = time.time()
+
+                    # show which key we're doing...
+                    onedoing = blitsn[bkey]
+                    print "time to do :%s: is :%s:" % (onedoing, t2-t1)
+
+
             elif event.type == KEYDOWN and event.key in [K_o]:
                 t1 = time.time()
                 # blits is a dict keyed with key -> blit flag.  eg BLEND_ADD.
 def usage():
     print "press keys 1-5 to change image to blit."
     print "A - ADD, S- SUB, M- MULT, - MIN, + MAX"
+    print "T - timing test for special blend modes."
 
 if __name__ == '__main__': 
     usage()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.