Commits

Anonymous committed ae12316

default font added, all color args changed to RGBA

Comments (0)

Files changed (56)

 #This is a list of changes in pygame's history.
 
+Nov 28, 2000
+	Surface.convert() better handles surface flags
+	All color arguments (and returns) are RGBA format [BREAK]
+	Removed Surface.map_rgba and unmap_rgba [BREAK]
+	Added a default font, used by passing None as font file
+	pygame.font.font changed to pygame.font.new_font() [BREAK]
+
 pygame-03
 Nov 20, 2000
 	Added Surface.save() to create BMPs.
 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;
 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/Channel.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/Font.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;
 
 <a name=render><font size=+2><b>render
 </b></font><br><font size=+1><tt>
-Font.render(text, antialias, fgcolor, [bgcolor]) -> Surface
+Font.render(text, antialias, fore_RGBA, [back_RGBA]) -> Surface
 </tt></font><ul>
 Render the given text onto a new image surface. The given text
 can be standard python text or unicode. Antialiasing will smooth
 the edges of the font for a much cleaner look. The foreground
-color is a 3-number-sequence containing the desired RGB
-components for the text. The background color is also a
-3-number-sequence of RGB. This sets the background color for the
-text. If the background color is omitted, the text will have a
-transparent background.
+and background color are both RGBA, the alpha component is ignored
+if given. If the background color is omitted, the text will have a
+a transparent background.
 </ul><br>&nbsp;<br>
 
 <a name=set_bold><font size=+2><b>set_bold

docs/ref/Joystick.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/Rect.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;
 around the center).
 <br>&nbsp;<br>
 The rectstyle arguments used frequently with the
-Rect object (and elsewhere in PyGame) is one of
+Rect object (and elsewhere in pygame) is one of
 the following things. First, an actual Rect
 object. Second, a sequence of [xpos, ypos, width,
 height]. Lastly, a pair of sequences, representing

docs/ref/Sound.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/Surface.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;
 convert RGB into a mapped color</td></tr>
 
 
-<tr><td><a href=#map_rgba>map_rgba</a></td><td> -
-convert RGBA into a mapped color</td></tr>
-
-
 <tr><td><a href=#mustlock>mustlock</a></td><td> -
 check if the surface needs locking</td></tr>
 
 convert mapped color into RGB</td></tr>
 
 
-<tr><td><a href=#unmap_rgba>unmap_rgba</a></td><td> -
-convert mapped color into RGBA</td></tr>
-
-
 </table>
 
 <hr>
 
 <a name=get_at><font size=+2><b>get_at
 </b></font><br><font size=+1><tt>
-Surface.get_at([x, y]) -> int
+Surface.get_at([x, y]) -> RGBA
 </tt></font><ul>
-Returns the mapped pixel color at the coordinates
-given point.
+Returns the RGB color values at a given pixel. If the
+Surface has no per-pixel alpha, the alpha will be 255 (opaque).
 </ul><br>&nbsp;<br>
 
 <a name=get_bitsize><font size=+2><b>get_bitsize
 
 <a name=get_colorkey><font size=+2><b>get_colorkey
 </b></font><br><font size=+1><tt>
-Surface.get_colorkey() -> color
+Surface.get_colorkey() -> RGBA
 </tt></font><ul>
 Returns the current mapped color value being used for
 colorkeying. If colorkeying is not enabled for this surface, it
 
 <a name=map_rgb><font size=+2><b>map_rgb
 </b></font><br><font size=+1><tt>
-Surface.map_rgb([r, g, b]) -> int
+Surface.map_rgb(RGBA) -> int
 </tt></font><ul>
-Uses the Surface format to convert RGB into a mapped color value.
-Note that this will work if the RGB is passed as three arguments
-instead of a sequence.
-</ul><br>&nbsp;<br>
-
-<a name=map_rgba><font size=+2><b>map_rgba
-</b></font><br><font size=+1><tt>
-Surface.map_rgba([r, g, b, a]) -> int
-</tt></font><ul>
-Uses the Surface format to convert RGBA into a mapped color
-value. It is safe to call this on a surface with no pixel alpha.
-The alpha will simply be ignored.
+Uses the Surface format to convert RGBA into a mapped color value.
 </ul><br>&nbsp;<br>
 
 <a name=mustlock><font size=+2><b>mustlock
 
 <a name=set_at><font size=+2><b>set_at
 </b></font><br><font size=+1><tt>
-Surface.set_at([x, y], pixel) -> None
+Surface.set_at([x, y], RGBA) -> None
 </tt></font><ul>
-Assigns a mapped pixel color to the image at the give position.
+Assigns RGBA color to the image at the give position.
 </ul><br>&nbsp;<br>
 
 <a name=set_clip><font size=+2><b>set_clip
 
 <a name=set_colorkey><font size=+2><b>set_colorkey
 </b></font><br><font size=+1><tt>
-Surface.set_colorkey([color, [flags]]) -> None
+Surface.set_colorkey([RGBA, [flags]]) -> None
 </tt></font><ul>
 Set the colorkey for the surface by passing a mapped color value
 as the color argument. If no arguments are passed, colorkeying
 
 <a name=unmap_rgb><font size=+2><b>unmap_rgb
 </b></font><br><font size=+1><tt>
-Surface.unmap_rgb(color) -> r, g, b
+Surface.unmap_rgb(color) -> RGBA
 </tt></font><ul>
-This function returns the RGB components for a mapped color
-value.
-</ul><br>&nbsp;<br>
-
-<a name=unmap_rgba><font size=+2><b>unmap_rgba
-</b></font><br><font size=+1><tt>
-Surface.unmap_rgba(color) -> r, g, b, a
-</tt></font><ul>
-This function returns the RGB components for a mapped color
-value. For surfaces with no alpha, the alpha will always be 255.
+This function returns the RGBA components for a mapped color
+value. If Surface has no per-pixel alpha, alpha will be 255 (opaque).
 </ul><br>&nbsp;<br>
 
 

docs/ref/pygame.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;
 <hr>
 
 <table>
-<tr><td><a href=#font>font</a></td><td> -
-create a new font object</td></tr>
-
-
 <tr><td><a href=#get_error>get_error</a></td><td> -
 get current error message</td></tr>
 
 
 <hr>
 
-<a name=font><font size=+2><b>font
-</b></font><br><font size=+1><tt>
-pygame.font(file, size) -> Font
-</tt></font><ul>
-This will create a new font object. The given file must be an
-existing filename. The font loader does not work with python
-file-like objects. The size represents the height of the font in
-pixels.
-</ul><br>&nbsp;<br>
-
 <a name=get_error><font size=+2><b>get_error
 </b></font><br><font size=+1><tt>
 pygame.get_error() -> errorstring

docs/ref/pygame_cdrom.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/pygame_constants.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/pygame_display.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/pygame_event.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/pygame_font.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;
 initialize the display module</td></tr>
 
 
+<tr><td><a href=#new_font>new_font</a></td><td> -
+create a new font object</td></tr>
+
+
 <tr><td><a href=#quit>quit</a></td><td> -
 uninitialize the font module</td></tr>
 
 font is currently initialized.
 </ul><br>&nbsp;<br>
 
+<a name=new_font><font size=+2><b>new_font
+</b></font><br><font size=+1><tt>
+pygame.font.new_font(file, size) -> Font
+</tt></font><ul>
+This will create a new font object. The given file must be a
+filename to a TTF file. The font loader does not work with python
+file-like objects. The size represents the height of the font in
+pixels. The file argument can be 'None', which will use a plain
+default font.
+</ul><br>&nbsp;<br>
+
 <a name=quit><font size=+2><b>quit
 </b></font><br><font size=+1><tt>
 pygame.font.quit() -> none

docs/ref/pygame_image.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/pygame_joystick.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/pygame_key.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/pygame_mixer.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/pygame_mixer_music.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/pygame_mouse.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/pygame_surfarray.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/ref/pygame_time.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 
 	||&nbsp;

docs/util/pagelate.html

 	<a href=../index.html><font size=+5 color=#ffffff><i><b>
       pygame</b></i></font></a>&nbsp;&nbsp;</td>
 <td valign=middle><tt><font color=#dddddd><br>
-	PyGame<br>Documentation</font>
+	pygame<br>documentation</font>
 </td></tr></table></td><td width=100% align=center valign=middle>
 	
 	||&nbsp;

examples/aliens.py

 
     #attempt to show game over (if font installed)
     if font:
-        fontname = os.path.join('data', 'billbrdi.ttf')
-        f = font.font(fontname, 100)
+        f = font.new_font(None, 100) #None means default font
+        f.set_italic(1)
         text = f.render('Game Over', 1, (200, 200, 200))
         textrect = new_rect((0, 0), text.get_size())
         textrect.center = SCREENRECT.center
Add a comment to this file

examples/data/billbrdi.ttf

Binary file removed.

Add a comment to this file

examples/data/liquid.gif

Added
New image

examples/fonty.py

 def main():
     #initialize
     pygame.init()
-    screen = pygame.display.set_mode((400, 200))
+    resolution = 400, 200
+    screen = pygame.display.set_mode(resolution)
     pygame.mouse.set_cursor(*pygame.cursors.diamond)
 
+    fg = 250, 240, 230
+    bg = 5, 5, 5
+    wincolor = 40, 40, 90
+
     #fill background
-    screen.fill(screen.map_rgb((40, 40, 90)))
-    pygame.display.flip()
+    screen.fill(wincolor)
 
     #load font, prepare values
-    fontname = os.path.join('data', 'billbrdi.ttf')
-    font = pygame.font.font(fontname, 80)
+    font = pygame.font.new_font(None, 80)
     text = 'Fonty'
     size = font.size(text)
-    fg = (250, 240, 230)
-    bg = (5, 5, 5)
 
     #no AA, no transparancy, normal
     ren = font.render(text, 0, fg, bg)
     #no AA, transparancy, underline
     font.set_underline(1)
     ren = font.render(text, 0, fg)
-    screen.blit(ren, (10, 20 + size[1]))
+    screen.blit(ren, (10, 40 + size[1]))
     font.set_underline(0)
 
     #AA, no transparancy, bold
     font.set_bold(1)
     ren = font.render(text, 1, fg, bg)
-    screen.blit(ren, (20 + size[0], 10))
+    screen.blit(ren, (30 + size[0], 10))
     font.set_bold(0)
 
     #AA, transparancy, italic
     font.set_italic(1)
     ren = font.render(text, 1, fg)
-    screen.blit(ren, (20 + size[0], 20 + size[1]))
+    screen.blit(ren, (30 + size[0], 40 + size[1]))
     font.set_italic(0)
 
     #show the surface and await user quit

examples/liquid.py

+
+"""This examples demonstrates a simplish water effect of an
+image. It attempts to create a hardware display surface that
+can use pageflipping for faster updates. Note that the colormap
+from the loaded GIF image is copied to the colormap for the
+display surface.
+
+This is based on the demo named F2KWarp by Brad Graham of Freedom2000
+done in BlitzBasic. I was just translating the BlitzBasic code to
+pygame to compare the results. I didn't bother porting the text and
+sound stuff, that's an easy enough challenge for the reader :]"""
+
+import math, os
+import pygame, pygame.image
+from pygame.locals import *
+
+
+
+def main():
+    #initialize and setup screen
+    pygame.init()
+    screen = pygame.display.set_mode((640, 480), HWSURFACE|DOUBLEBUF, 8)
+
+    #load image
+    imagename = os.path.join('data', 'liquid.gif')
+    bitmap = pygame.image.load(imagename)
+
+    #get the image and screen in the same format
+    if screen.get_bitsize() == 8:
+        screen.set_palette(bitmap.get_palette())
+
+    #prep some variables
+    anim = 0.0
+    sin = math.sin  #note, making sin local speeds up call (slightly)
+    xstep, ystep = range(0, 640, 20), range(0, 480, 20)
+    stopevents = QUIT, KEYDOWN, MOUSEBUTTONDOWN
+
+    #mainloop
+    while not pygame.event.peek(stopevents):
+        anim += 0.4
+        for x in xstep:
+            for y in ystep:
+                xpos = (x+(sin(anim+x*.01)*15))+20
+                ypos = (y+(sin(anim+y*.01)*15))+20
+                screen.blit(bitmap, (x, y), (xpos, ypos, 20, 20))
+        pygame.display.flip()
+
+if __name__ == '__main__':
+    main()
+
+
+
+"""BTW, here is the code from the BlitzBasic example this was derived
+from. This code runs a little faster, yet reads a lot slower. again i've
+snipped the sound and text stuff out.
+-----------------------------------------------------------------
+; Brad@freedom2000.com
+
+; Load a bmp pic (800x600) and slice it into 1600 squares
+Graphics 640,480					
+SetBuffer BackBuffer()				
+bitmap$="f2kwarp.bmp"					
+pic=LoadAnimImage(bitmap$,20,15,0,1600)
+
+; use SIN to move all 1600 squares around to give liquid effect
+Repeat
+f=0:w=w+10:If w=360 Then w=0
+For y=0 To 599 Step 15
+For x = 0 To 799 Step 20
+f=f+1:If f=1600 Then f=0
+DrawBlock pic,(x+(Sin(w+x)*40))/1.7+80,(y+(Sin(w+y)*40))/1.7+60,f 
+Next:Next:Flip:Cls
+Until KeyDown(1)
+"""

examples/stars.py

 	#initialize and prepare screen
 	pygame.init()
 	screen = pygame.display.set_mode(WINSIZE)
-	pygame.display.set_caption('pyGame Stars Example')
-	white = screen.map_rgb(255, 240, 200)
-	black = screen.map_rgb(20, 20, 40)
+	pygame.display.set_caption('pygame Stars Example')
+	white = 255, 240, 200
+	black = 20, 20, 40
 	screen.fill(black)
 
 	#main game loop
 		draw_stars(screen, stars, black)
 		move_stars(stars)
 		draw_stars(screen, stars, white)
-		pygame.display.flip()
+		pygame.display.update()
+		calcfps()
 
 		for e in pygame.event.get():
 			if e.type == QUIT or (e.type == KEYUP and e.key == K_ESCAPE):
 				WINCENTER[:] = list(e.pos)
 
 
+
+fps_frames = 0
+fps_time = 0
+def calcfps():
+    global fps_time, fps_frames
+    if not fps_time:
+        fps_time = pygame.time.get_ticks()
+        fps_frames = 0
+        return
+    fps_frames += 1
+    now = pygame.time.get_ticks()
+    time = now - fps_time
+    if time > 1000:
+        time = time / 1000.0
+        print 'TIME:', time/fps_frames, '  FPS:', fps_frames/time
+        fps_frames = 0
+        fps_time = now
+
+
+
 # if python says run, then we should run
 if __name__ == '__main__':
 	main()
-##    PyGame - Python Game Library
+##    pygame - Python Game Library
 ##    Copyright (C) 2000  Pete Shinners
 ##
 ##    This library is free software; you can redistribute it and/or

Binary file added.

+The fonts contained in this archive are Freeware.
+No payment is required for the use of these fonts.  They're free!
+Commercial use?  Sure, but a donation or a product sample would be
+appreciated.
+
+$40 US is the usual amount per font for commercial use but any amount is appreciated.
+
+I make all the fonts (around 370 of them) on my web page and they're all free.
+I offer Deluxe versions of some of my fonts for sale.  They contain several
+ weights and styles of each font.  Just click on the Deluxe button at Larabie Fonts to see them.
+
+The page is called Larabie Fonts
+It can be found at various mirror sites.
+
+try:
+http://www.larabiefonts.com
+http://uk.zarcrom.com/font/
+http://swankarmy.net/larabiefonts/
+http://come.to/larabiefonts
+
+I've provided the world with about 300 free fonts,
+so if you'd like to make a donation I'd be more than happy to accept it.
+
+No donation is too small!  Music and artwork are good too.
+If you have some CD's you're not listening to anymore, send 'em along!
+
+Send anything at all to
+
+Ray Larabie
+61 Wesley Ave.
+Port Credit
+Ontario, CANADA
+L5H 2M8
+
+If you decide to send a cheque (that's how we spell it in Canada)
+make it payable to Ray Larabie.  If you want to double check the address
+have a look at the donation section on any of my webpages.
+
+Canadian or US funds?  Any funds are fine with me.
+Whatever's easy for you.
+
+
+Ray Larabie
+drowsy@cheerful.com
+or...
+rlarabie@hotmail.com
+
+-------------------------------
+Larabie Fonts End-user license agreement software product from Larabie Fonts
+---------------------------------------------------
+
+SOFTWARE PRODUCT LICENSE
+
+The SOFTWARE PRODUCT is protected by copyright laws and international copyright treaties,
+as well as other intellectual property laws and treaties. The SOFTWARE PRODUCT is licensed,
+not sold.
+
+1. GRANT OF LICENSE. This document grants you the following rights:
+
+- Installation and Use. You may install and use an unlimited number of copies of the
+SOFTWARE PRODUCT.
+
+- Reproduction and Distribution. You may reproduce and distribute an unlimited number of
+copies of the SOFTWARE PRODUCT;  provided that each copy shall be a true and complete copy,
+including all copyright and trademark notices (if applicable) , and shall be accompanied by
+a copy of this text file.  Copies of the SOFTWARE PRODUCT may not be distributed for profit
+either on a standalone basis or included as part of your own product unless by prior
+permission of Larabie Fonts.
+
+2. DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS. 
+
+- Restrictions on Alteration.  You may not rename, edit or create any derivative works from
+the SOFTWARE PRODUCT, other than subsetting when embedding them in documents unless you have
+permission from Larabie Fonts.
+
+LIMITED WARRANTY
+NO WARRANTIES. Larabie Fonts expressly disclaims any warranty for the SOFTWARE PRODUCT. The
+SOFTWARE PRODUCT and any related documentation is provided "as is" without warranty of any
+kind, either express or implied, including, without limitation, the implied warranties or
+merchantability, fitness for a particular purpose, or noninfringement. The entire risk
+arising out of use or performance of the SOFTWARE PRODUCT remains with you.
+
+NO LIABILITY FOR CONSEQUENTIAL DAMAGES. In no event shall Larabie Fonts be liable for any
+damages whatsoever (including, without limitation, damages for loss of business profits,
+business interruption, loss of business information, or any other pecuniary loss) arising
+out of the use of or inability to use this product, even if Larabie Fonts has been advised
+of the possibility of such damages.
+
+3. MISCELLANEOUS
+
+Should you have any questions concerning this document, or if you desire to contact
+Larabie Fonts for any reason, please contact rlarabie@hotmail.com , or write: Ray Larabie,
+61 Wesley Ave. Mississauga, ON Canada L5H 2M8
-##    PyGame - Python Game Library
+##    pygame - Python Game Library
 ##    Copyright (C) 2000  Pete Shinners
 ##
 ##    This library is free software; you can redistribute it and/or
-##    PyGame - Python Game Library
+##    pygame - Python Game Library
 ##    Copyright (C) 2000  Pete Shinners
 ##
 ##    This library is free software; you can redistribute it and/or
 #extra files to install
 data_files = []
 
+#add non .py files in lib directory
+for f in glob.glob(os.path.join('lib', '*')):
+    if not f.endswith('.py') and os.path.isfile(f):
+        data_files.append(f)
+
 #try to find libaries and copy them too
 #(great for windows, bad for linux)
 if sys.platform == 'win32':
             if os.path.isfile(p) and p not in data_files:
                 data_files.append(p)
 
-#don't need to actually compile the COPYLIB modules
+#don't need to actually compile the COPYLIB modules, remove them
 for e in extensions[:]:
     if e.name.startswith('COPYLIB_'):
         extensions.remove(e)
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 	return result;
 }
 
+static int RGBAFromObj(PyObject* obj, Uint8* RGBA)
+{
+	int length;
+	Uint32 val;
+	if(PyTuple_Check(obj) && PyTuple_Size(obj)==1)
+		return RGBAFromObj(PyTuple_GET_ITEM(obj, 0), RGBA);
+
+	if(!PySequence_Check(obj))
+		return 0;
+
+	length = PySequence_Length(obj);
+	if(length < 3 || length > 4)
+		return 0;
+
+	if(!UintFromObjIndex(obj, 0, &val) || val > 255)
+		return 0;
+	RGBA[0] = (Uint8)val;
+	if(!UintFromObjIndex(obj, 1, &val) || val > 255)
+		return 0;
+	RGBA[1] = (Uint8)val;
+	if(!UintFromObjIndex(obj, 2, &val) || val > 255)
+		return 0;
+	RGBA[2] = (Uint8)val;
+	if(length == 4)
+	{
+		if(!UintFromObjIndex(obj, 3, &val) || val > 255)
+			return 0;
+		RGBA[3] = (Uint8)val;
+	}
+	else RGBA[3] = (Uint8)255;
+
+	return 1;
+}
 
 
 
 		
 		if(status)
 			return 0;
-		SDL_EnableUNICODE(1); /*the controversy!*/
+		SDL_EnableUNICODE(1);
 		PyGame_RegisterQuit(PyGame_Video_AutoQuit);
 	}
 	return 1;
 	c_api[6] = UintFromObjIndex;
 	c_api[7] = PyGame_Video_AutoQuit;
 	c_api[8] = PyGame_Video_AutoInit;
+	c_api[9] = RGBAFromObj;
 	apiobj = PyCObject_FromVoidPtr(c_api, NULL);
 	PyDict_SetItemString(dict, PYGAMEAPI_LOCAL_ENTRY, apiobj);
 
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 */
 
 /*
- *  PyGAME display module
+ *  pygame display module
  */
 #define PYGAMEAPI_DISPLAY_INTERNAL
 #include "pygame.h"
 
 	SDL_WM_GetCaption(&title, &icontitle);
 	if(!title || !*title)
-		SDL_WM_SetCaption("PyGame Window", "PyGame");
+		SDL_WM_SetCaption("pygame window", "pygame");
 
 	return PySurface_New(surf);
 }
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 */
 
 /*
- *  PyGAME event module
+ *  pygame event module
  */
 #define PYGAMEAPI_EVENT_INTERNAL
 #include "pygame.h"
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 */
 
 /*
- *  font module for PyGAME
+ *  font module for pygame
  */
 #define PYGAMEAPI_FONT_INTERNAL
+#include <string.h>
 #include "pygame.h"
 #include "font.h"
 
 #define PyFont_Check(x) ((x)->ob_type == &PyFont_Type)
 
 static int font_initialized = 0;
-
+static char* font_defaultname = "bluebold.ttf";
+static char* font_defaultpath = NULL;
 
 static void font_autoquit()
 {
 		font_initialized = 0;
 		TTF_Quit();
 	}
+	if(font_defaultpath)
+	{
+		PyMem_Free(font_defaultpath);
+		font_defaultpath = NULL;
+	}
 }
 
 
 		if(TTF_Init())
 			return PyInt_FromLong(0);
 		font_initialized = 1;
+
+		if(!font_defaultpath)
+		{
+			PyObject* module;
+			char* modulepath;
+			module = PyImport_ImportModule("pygame");
+			if(module)
+			{
+				modulepath = PyModule_GetFilename(module);
+				if(modulepath)
+				{
+					font_defaultpath = PyMem_Malloc(strlen(modulepath) + 16);
+					strcpy(font_defaultpath, modulepath);
+					if(font_defaultpath)
+					{
+						char* end = strstr(font_defaultpath, "__init__.");
+						if(end)
+							strcpy(end, font_defaultname);
+						else
+						{
+							PyMem_Free(font_defaultpath);
+							font_defaultpath = NULL;
+						}
+					}
+				}
+				Py_DECREF(module);
+			}
+		}
 	}
 	return PyInt_FromLong(1);
 }
 
 
     /*DOC*/ static char doc_font_render[] =
-    /*DOC*/    "Font.render(text, antialias, fgcolor, [bgcolor]) -> Surface\n"
+    /*DOC*/    "Font.render(text, antialias, fore_RGBA, [back_RGBA]) -> Surface\n"
     /*DOC*/    "render text to a new image\n"
     /*DOC*/    "\n"
     /*DOC*/    "Render the given text onto a new image surface. The given text\n"
     /*DOC*/    "can be standard python text or unicode. Antialiasing will smooth\n"
     /*DOC*/    "the edges of the font for a much cleaner look. The foreground\n"
-    /*DOC*/    "color is a 3-number-sequence containing the desired RGB\n"
-    /*DOC*/    "components for the text. The background color is also a\n"
-    /*DOC*/    "3-number-sequence of RGB. This sets the background color for the\n"
-    /*DOC*/    "text. If the background color is omitted, the text will have a\n"
-    /*DOC*/    "transparent background.\n"
+    /*DOC*/    "and background color are both RGBA, the alpha component is ignored\n"
+	/*ODC*/    "if given. If the background color is omitted, the text will have a\n"
+    /*DOC*/    "a transparent background.\n"
     /*DOC*/ ;
 
 static PyObject* font_render(PyObject* self, PyObject* args)
 {
 	TTF_Font* font = PyFont_AsFont(self);
-	int aa, fr, fg, fb, br, bg, bb = -1;
+	int aa;
 	PyObject* text;
+	PyObject* fg_rgba_obj, *bg_rgba_obj = NULL;
+	Uint8 rgba[4];
 	SDL_Surface* surf;
 	SDL_Color foreg, backg;
 
-	if(!PyArg_ParseTuple(args, "Oi(iii)|(iii)", &text, &aa, &fr, &fg, &fb, &br, &bg, &bb))
+	if(!PyArg_ParseTuple(args, "OiO|O", &text, &aa, &fg_rgba_obj, &bg_rgba_obj))
 		return NULL;
 
-	foreg.r = (Uint8)fr; foreg.g = (Uint8)fg; foreg.b = (Uint8)fb;
-	backg.r = (Uint8)br; backg.g = (Uint8)bg; backg.b = (Uint8)bb; 
+	if(!RGBAFromObj(fg_rgba_obj, rgba))
+		return RAISE(PyExc_TypeError, "Invalid foreground RGBA argument");
+	foreg.r = rgba[0]; foreg.g = rgba[1]; foreg.b = rgba[2];
+	if(bg_rgba_obj)
+	{
+		if(!RGBAFromObj(bg_rgba_obj, rgba))
+			return RAISE(PyExc_TypeError, "Invalid background RGBA argument");
+		backg.r = rgba[0]; backg.g = rgba[1]; backg.b = rgba[2];
+	}	
 
 	if(PyUnicode_Check(text))
 	{
 		Py_UNICODE* string = PyUnicode_AsUnicode(text);
 		if(aa)
 		{
-			if(bb == -1)
+			if(!bg_rgba_obj)
 				surf = TTF_RenderUNICODE_Blended(font, string, foreg);
 			else
 				surf = TTF_RenderUNICODE_Shaded(font, string, foreg, backg);
 		char* string = PyString_AsString(text);
 		if(aa)
 		{
-			if(bb == -1)
+			if(!bg_rgba_obj)
 				surf = TTF_RenderText_Blended(font, string, foreg);
 			else
 				surf = TTF_RenderText_Shaded(font, string, foreg, backg);
 	if(!surf)
 		return RAISE(PyExc_SDLError, SDL_GetError());
 
-	if(!aa && bb != -1) /*turn off transparancy*/
+	if(!aa && bg_rgba_obj) /*turn off transparancy*/
 	{			
 		SDL_SetColorKey(surf, 0, 0);
 		surf->format->palette->colors[0].r = backg.r;
 /*font module methods*/
 
     /*DOC*/ static char doc_font_font[] =
-    /*DOC*/    "pygame.font(file, size) -> Font\n"
+    /*DOC*/    "pygame.font.new_font(file, size) -> Font\n"
     /*DOC*/    "create a new font object\n"
     /*DOC*/    "\n"
-    /*DOC*/    "This will create a new font object. The given file must be an\n"
-    /*DOC*/    "existing filename. The font loader does not work with python\n"
+    /*DOC*/    "This will create a new font object. The given file must be a\n"
+    /*DOC*/    "filename to a TTF file. The font loader does not work with python\n"
     /*DOC*/    "file-like objects. The size represents the height of the font in\n"
-    /*DOC*/    "pixels.\n"
+    /*DOC*/    "pixels. The file argument can be 'None', which will use a plain\n"
+    /*DOC*/    "default font.\n"
     /*DOC*/ ;
 
 static PyObject* font_font(PyObject* self, PyObject* args)
 {
+	PyObject* fileobj;
 	char* filename;
 	int fontsize;
 	TTF_Font* font;
 	PyObject* fontobj;
-	if(!PyArg_ParseTuple(args, "si", &filename, &fontsize))
+	if(!PyArg_ParseTuple(args, "Oi", &fileobj, &fontsize))
 		return NULL;
 
 	if(!font_initialized)
 		return RAISE(PyExc_SDLError, "font not initialized");
 
+	if(fileobj == Py_None)
+	{
+		if(!font_defaultpath)
+			return RAISE(PyExc_RuntimeError, "default font not found");
+		filename = font_defaultpath;
+	}
+	else if(PyString_Check(fileobj))
+		filename = PyString_AS_STRING(fileobj);
+	else
+		return RAISE(PyExc_TypeError, "font name must be string or None");
+
 	Py_BEGIN_ALLOW_THREADS
 	font = TTF_OpenFont(filename, fontsize);
 	Py_END_ALLOW_THREADS
 	{ "quit", font_quit, 1, doc_quit },
 	{ "get_init", get_init, 1, doc_get_init },
 
-	{ "font", font_font, 1, doc_font_font },
+	{ "new_font", font_font, 1, doc_font_font },
 
 	{ NULL, NULL }
 };
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 */
 
 /*
- *  image module for PyGAME
+ *  image module for pygame
  */
 #include "pygame.h"
 #include <SDL_image.h>
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 */
 
 /*
- *  PyGAME keyboard module
+ *  pygame keyboard module
  */
 #include "pygame.h"
 
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 */
 
 /*
- *  mixer module for PyGAME
+ *  mixer module for pygame
  */
 #define PYGAMEAPI_MIXER_INTERNAL
 #include "pygame.h"
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 */
 
 /*
- *  PyGAME mouse module
+ *  pygame mouse module
  */
 #include "pygame.h"
 
     /*DOC*/    "visible state of the mouse cursor.\n"
     /*DOC*/    "\n"
     /*DOC*/    "Note that when the cursor is hidden and the application has\n"
-    /*DOC*/    "grabbed the input. pyGame will force the mouse to stay in the\n"
+    /*DOC*/    "grabbed the input. pygame will force the mouse to stay in the\n"
     /*DOC*/    "center of the screen. Since the mouse is hidden it won't matter\n"
     /*DOC*/    "that it's not moving, but it will keep the mouse from the edges\n"
     /*DOC*/    "of the screen so the relative mouse position will always be true.\n"
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 */
 
 /*
- *  music module for PyGAME
+ *  music module for pygame
  */
 #define PYGAMEAPI_MUSIC_INTERNAL
 #include "pygame.h"
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 
 /* BASE */
 #define PYGAMEAPI_BASE_FIRSTSLOT 0
-#define PYGAMEAPI_BASE_NUMSLOTS 9
+#define PYGAMEAPI_BASE_NUMSLOTS 10
 #ifndef PYGAMEAPI_BASE_INTERNAL
 #define PyExc_SDLError ((PyObject*)PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 0])
 #define PyGame_RegisterQuit \
 			(*(void(*)(void))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 7])
 #define PyGame_Video_AutoInit \
 			(*(int(*)(void))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 8])
+#define RGBAFromObj \
+			(*(int(*)(PyObject*, Uint8*))PyGAME_C_API[PYGAMEAPI_BASE_FIRSTSLOT + 9])
 #define import_pygame_base() { \
 	PyObject *module = PyImport_ImportModule("pygame.base"); \
 	if (module != NULL) { \
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
     /*DOC*/    "around the center).\n"
     /*DOC*/    "\n"
     /*DOC*/    "The rectstyle arguments used frequently with the\n"
-    /*DOC*/    "Rect object (and elsewhere in PyGame) is one of\n"
+    /*DOC*/    "Rect object (and elsewhere in pygame) is one of\n"
     /*DOC*/    "the following things. First, an actual Rect\n"
     /*DOC*/    "object. Second, a sequence of [xpos, ypos, width,\n"
     /*DOC*/    "height]. Lastly, a pair of sequences, representing\n"
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 */
 
 /*
- *  PyGAME Surface module
+ *  pygame Surface module
  */
 #define PYGAMEAPI_SURFACE_INTERNAL
 #include "pygame.h"
 
 
     /*DOC*/ static char doc_surf_get_at[] =
-    /*DOC*/    "Surface.get_at([x, y]) -> int\n"
+    /*DOC*/    "Surface.get_at([x, y]) -> RGBA\n"
     /*DOC*/    "get a pixel color\n"
     /*DOC*/    "\n"
-    /*DOC*/    "Returns the mapped pixel color at the coordinates\n"
-    /*DOC*/    "given point.\n"
+    /*DOC*/    "Returns the RGB color values at a given pixel. If the\n"
+    /*DOC*/    "Surface has no per-pixel alpha, the alpha will be 255 (opaque).\n"
     /*DOC*/ ;
 
 static PyObject* surf_get_at(PyObject* self, PyObject* arg)
 	SDL_PixelFormat* format = surf->format;
 	Uint8* pixels = (Uint8*)surf->pixels;
 	int x, y;
+	Uint32 color;
+	Uint8* byte_buf;
+	Uint8 r, g, b, a;
 
 	if(!PyArg_ParseTuple(arg, "(ii)", &x, &y))
 		return NULL;
 
 	if(x < 0 || x >= surf->w || y < 0 || y >= surf->h)
-		return RAISE(PyExc_IndexError, "buffer index out of range");
+		return RAISE(PyExc_IndexError, "pixel index out of range");
 
 	if(!pixels)
 		return RAISE(PyExc_SDLError, "Surface must be locked for pixel access");
 	switch(format->BytesPerPixel)
 	{
 		case 1:
-		{
-			Uint8 col = *((Uint8*)pixels + y * surf->pitch + x);
-			return PyInt_FromLong(col);
-		}
-		break;
+			color = (Uint32)*((Uint8*)pixels + y * surf->pitch + x);
+			break;
 		case 2:
-		{
-			Uint16 col = *((Uint16*)(pixels + y * surf->pitch) + x);
-			return PyInt_FromLong(col); 
-		}
-		break;
+			color = (Uint32)*((Uint16*)(pixels + y * surf->pitch) + x);
+			break;
 		case 3:
-		{
-			Uint32 col;
-			Uint8* byte_buf;
-			
 			byte_buf = ((Uint8*)(pixels + y * surf->pitch) + x * 3);
-			col =
+			color = (Uint32)(
 				*(byte_buf + (format->Rshift >> 3)) << format->Rshift |
 				*(byte_buf + (format->Gshift >> 3)) << format->Gshift |
-				*(byte_buf + (format->Bshift >> 3)) << format->Bshift;
-			return PyInt_FromLong(col);   
-		}
-		break;
+				*(byte_buf + (format->Bshift >> 3)) << format->Bshift);
+			break;
 		case 4:
-		{
-			Uint32 col = *((Uint32*)(pixels + y * surf->pitch) + x);
-			return PyInt_FromLong(col); 
-		}
-		break;
+			color = *((Uint32*)(pixels + y * surf->pitch) + x);
+			break;
+		default:
+			return RAISE(PyExc_RuntimeError, "Unable to determine color depth.");
 	}
-	return RAISE(PyExc_RuntimeError, "Unable to determine color depth.");
+
+	SDL_GetRGBA(color, format, &r, &g, &b, &a);
+	return Py_BuildValue("(bbbb)", r, g, b, a);
 }
 
 
 
     /*DOC*/ static char doc_surf_set_at[] =
-    /*DOC*/    "Surface.set_at([x, y], pixel) -> None\n"
+    /*DOC*/    "Surface.set_at([x, y], RGBA) -> None\n"
     /*DOC*/    "set pixel at given position\n"
     /*DOC*/    "\n"
-    /*DOC*/    "Assigns a mapped pixel color to the image at the give position.\n"
+    /*DOC*/    "Assigns RGBA color to the image at the give position.\n"
     /*DOC*/ ;
 
 static PyObject* surf_set_at(PyObject* self, PyObject* args)
 	Uint8* pixels = (Uint8*)surf->pixels;
 	int x, y;
 	Uint32 color;
-	
-	if(!PyArg_ParseTuple(args, "(ii)i", &x, &y, &color))
+	Uint8 rgba[4];
+	PyObject* rgba_obj;
+	Uint8* byte_buf;
+
+	if(!PyArg_ParseTuple(args, "(ii)O", &x, &y, &rgba_obj))
 		return NULL;
 
 	if(x < 0 || x >= surf->w || y < 0 || y >= surf->h)
 	{
 		printf("%d,%d  -  %d,%d\n",x,y, surf->w, surf->h);
-		PyErr_SetString(PyExc_IndexError, "buffer index out of range");
+		PyErr_SetString(PyExc_IndexError, "pixel index out of range");
 		return NULL;
 	}
 
 	if(!pixels)
 		return RAISE(PyExc_SDLError, "Surface must be locked for pixel access");
 
+	if(!RGBAFromObj(rgba_obj, rgba))
+		return RAISE(PyExc_TypeError, "Invalid RGBA object");
+	color = SDL_MapRGBA(surf->format, rgba[0], rgba[1], rgba[2], rgba[3]);
+
 	switch(format->BytesPerPixel)
 	{
 		case 1:
-		{
 			*((Uint8*)pixels + y * surf->pitch + x) = (Uint8)color;
-		}
-		break;
+			break;
 		case 2:
-		{
 			*((Uint16*)(pixels + y * surf->pitch) + x) = (Uint16)color;
-		}
-		break;
+			break;
 		case 3:
-		{
-			Uint8* byte_buf = (Uint8*)(pixels + y * surf->pitch) + x * 3;
-			Uint8 r, g, b;
-
-			r = (color & format->Rmask) >> format->Rshift;
-			g = (color & format->Gmask) >> format->Gshift;
-			b = (color & format->Bmask) >> format->Bshift;
-
-			*(byte_buf + (format->Rshift >> 3)) = r;
-			*(byte_buf + (format->Gshift >> 3)) = g;
-			*(byte_buf + (format->Bshift >> 3)) = b;	
-		}
-		break;
+			byte_buf = (Uint8*)(pixels + y * surf->pitch) + x * 3;
+			*(byte_buf + (format->Rshift >> 3)) = rgba[0];
+			*(byte_buf + (format->Gshift >> 3)) = rgba[1];
+			*(byte_buf + (format->Bshift >> 3)) = rgba[2];	
+			break;
 		case 4:
-		{
 			*((Uint32*)(pixels + y * surf->pitch) + x) = color;
-		}
-		break;
+			break;
 		default:
 			return RAISE(PyExc_SDLError, "Unable to determine color depth.");
 	}
 
 
     /*DOC*/ static char doc_surf_map_rgb[] =
-    /*DOC*/    "Surface.map_rgb([r, g, b]) -> int\n"
+    /*DOC*/    "Surface.map_rgb(RGBA) -> int\n"
     /*DOC*/    "convert RGB into a mapped color\n"
     /*DOC*/    "\n"
-    /*DOC*/    "Uses the Surface format to convert RGB into a mapped color value.\n"
-    /*DOC*/    "Note that this will work if the RGB is passed as three arguments\n"
-    /*DOC*/    "instead of a sequence.\n"
+    /*DOC*/    "Uses the Surface format to convert RGBA into a mapped color value.\n"
     /*DOC*/ ;
 
 static PyObject* surf_map_rgb(PyObject* self,PyObject* args)
 {
 	SDL_Surface* surf = PySurface_AsSurface(self);
-	Uint8 r, g, b;
+	Uint8 rgba[4];
+	int color;
 
-	if(PyTuple_Size(args)==1)
-	{
-		if(!PyArg_ParseTuple(args, "(bbb)", &r, &g, &b))
-			return NULL;
-	}
-	else if(!PyArg_ParseTuple(args, "bbb", &r, &g, &b))
-		return NULL;
+	if(!RGBAFromObj(args, rgba))
+		return RAISE(PyExc_TypeError, "Invalid RGBA argument");
 
-	return PyInt_FromLong(SDL_MapRGB(surf->format, r, g, b));
+	color = SDL_MapRGBA(surf->format, rgba[0], rgba[1], rgba[2], rgba[3]);
+	return PyInt_FromLong(color);
 }
 
 
 
     /*DOC*/ static char doc_surf_unmap_rgb[] =
-    /*DOC*/    "Surface.unmap_rgb(color) -> r, g, b\n"
+    /*DOC*/    "Surface.unmap_rgb(color) -> RGBA\n"
     /*DOC*/    "convert mapped color into RGB\n"
     /*DOC*/    "\n"
-    /*DOC*/    "This function returns the RGB components for a mapped color\n"
-    /*DOC*/    "value.\n"
+    /*DOC*/    "This function returns the RGBA components for a mapped color\n"
+    /*DOC*/    "value. If Surface has no per-pixel alpha, alpha will be 255 (opaque).\n"
     /*DOC*/ ;
 
 static PyObject* surf_unmap_rgb(PyObject* self,PyObject* args)
 {
 	SDL_Surface* surf = PySurface_AsSurface(self);
 	Uint32 col;
-	Uint8 r, g, b;
-	
-	if(!PyArg_ParseTuple(args, "i", &col))
-		return NULL;
-
-	SDL_GetRGB(col,surf->format, &r, &g, &b);	
-
-	return Py_BuildValue("(bbb)", r, g, b);
-}
-
-
-    /*DOC*/ static char doc_surf_map_rgba[] =
-    /*DOC*/    "Surface.map_rgba([r, g, b, a]) -> int\n"
-    /*DOC*/    "convert RGBA into a mapped color\n"
-    /*DOC*/    "\n"
-    /*DOC*/    "Uses the Surface format to convert RGBA into a mapped color\n"
-    /*DOC*/    "value. It is safe to call this on a surface with no pixel alpha.\n"
-    /*DOC*/    "The alpha will simply be ignored.\n"
-    /*DOC*/ ;
-
-static PyObject* surf_map_rgba(PyObject* self,PyObject* args)
-{
-	SDL_Surface* surf = PySurface_AsSurface(self);
-	Uint8 r, g, b, a;
-
-	if(PyTuple_Size(args)==1)
-	{
-		if(!PyArg_ParseTuple(args, "(bbbb)", &r, &g, &b, &a))
-			return NULL;
-	}
-	else if(!PyArg_ParseTuple(args, "bbbb", &r, &g, &b, &a))
-		return NULL;
-
-	return PyInt_FromLong(SDL_MapRGBA(surf->format, r, g, b, a));
-}
-
-
-
-    /*DOC*/ static char doc_surf_unmap_rgba[] =
-    /*DOC*/    "Surface.unmap_rgba(color) -> r, g, b, a\n"
-    /*DOC*/    "convert mapped color into RGBA\n"
-    /*DOC*/    "\n"
-    /*DOC*/    "This function returns the RGB components for a mapped color\n"
-    /*DOC*/    "value. For surfaces with no alpha, the alpha will always be 255.\n"
-    /*DOC*/ ;
-
-static PyObject* surf_unmap_rgba(PyObject* self,PyObject* args)
-{
-	SDL_Surface* surf = PySurface_AsSurface(self);
-	Uint32 col;
 	Uint8 r, g, b, a;
 	
 	if(!PyArg_ParseTuple(args, "i", &col))
 		return NULL;
 
-	SDL_GetRGBA(col,surf->format, &r, &g, &b, &a);	
+	SDL_GetRGBA(col,surf->format, &r, &g, &b, &a);
 
-	return Py_BuildValue("(bbb)", r, g, b, a);
+	return Py_BuildValue("(bbbb)", r, g, b, a);
 }
 
 
 
 
     /*DOC*/ static char doc_surf_set_colorkey[] =
-    /*DOC*/    "Surface.set_colorkey([color, [flags]]) -> None\n"
+    /*DOC*/    "Surface.set_colorkey([RGBA, [flags]]) -> None\n"
     /*DOC*/    "change colorkey information\n"
     /*DOC*/    "\n"
     /*DOC*/    "Set the colorkey for the surface by passing a mapped color value\n"
 {
 	SDL_Surface* surf = PySurface_AsSurface(self);
 	Uint32 flags = 0, key = 0;
+	PyObject* rgba_obj = NULL;
+	Uint8 rgba[4];
 
-	if(!PyArg_ParseTuple(args, "|ii", &key, &flags))
+	if(!PyArg_ParseTuple(args, "|Oi", &rgba_obj, &flags))
 		return NULL;
-	
+
+	if(rgba_obj)
+	{
+		if(!RGBAFromObj(rgba_obj, rgba))
+			return RAISE(PyExc_TypeError, "Invalid RGBA argument");
+		key = SDL_MapRGBA(surf->format, rgba[0], rgba[1], rgba[2], rgba[3]);
+	}
+
 	if(PyTuple_Size(args) > 0)
 		flags |= SDL_SRCCOLORKEY;
 
 
 
     /*DOC*/ static char doc_surf_get_colorkey[] =
-    /*DOC*/    "Surface.get_colorkey() -> color\n"
+    /*DOC*/    "Surface.get_colorkey() -> RGBA\n"
     /*DOC*/    "query colorkey\n"
     /*DOC*/    "\n"
     /*DOC*/    "Returns the current mapped color value being used for\n"
 static PyObject* surf_get_colorkey(PyObject* self, PyObject* args)
 {
 	SDL_Surface* surf = PySurface_AsSurface(self);
+	Uint8 r, g, b, a;
 
 	if(!PyArg_ParseTuple(args, ""))
 		return NULL;
 	
-	if(surf->flags&SDL_SRCCOLORKEY)
-		return PyInt_FromLong(surf->format->colorkey);
+	if(!(surf->flags&SDL_SRCCOLORKEY))
+		RETURN_NONE
 
-	RETURN_NONE
+	SDL_GetRGBA(surf->format->colorkey, surf->format, &r, &g, &b, &a);
+	return Py_BuildValue("(bbbb)", r, g, b, a);
 }
 
 
 	PySurfaceObject* srcsurf = NULL;
 	SDL_Surface* src;
 	SDL_Surface* newsurf;
+	Uint32 flags;
 	
 	if(!PyArg_ParseTuple(args, "|O!", &PySurface_Type, &srcsurf))
 		return NULL;
 	if(srcsurf)
 	{
 		src = PySurface_AsSurface(srcsurf);
-		newsurf = SDL_ConvertSurface(surf, src->format, src->flags);
+        flags = src->flags | (surf->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA));
+        newsurf = SDL_ConvertSurface(surf, src->format, flags);
 	}
 	else
 		newsurf = SDL_DisplayFormat(surf);
 	PyObject* r = NULL;
 	Uint32 color;
 	int result;
+	PyObject* rgba_obj;
+	Uint8 rgba[4];
 	
-	if(!PyArg_ParseTuple(args, "i|O", &color, &r))
+	if(!PyArg_ParseTuple(args, "O|O", &rgba_obj, &r))
 		return NULL;
 
+	if(!RGBAFromObj(rgba_obj, rgba))
+		return RAISE(PyExc_TypeError, "Invalid RGBA argument");
+	color = SDL_MapRGBA(surf->format, rgba[0], rgba[1], rgba[2], rgba[3]);
+
 	if(!r)
 	{
 		rect = &temp;
 
 	{"map_rgb",			surf_map_rgb,		1, doc_surf_map_rgb },
 	{"unmap_rgb",		surf_unmap_rgb,		1, doc_surf_unmap_rgb },
-	{"map_rgba",		surf_map_rgba,		1, doc_surf_map_rgba },
-	{"unmap_rgba",		surf_unmap_rgba,	1, doc_surf_unmap_rgba },
 
 	{"get_palette",		surf_get_palette,	1, doc_surf_get_palette },
 	{"get_palette_at",	surf_get_palette_at,1, doc_surf_get_palette_at },
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
 /*
-    PyGame - Python Game Library
+    pygame - Python Game Library
     Copyright (C) 2000  Pete Shinners
 
     This library is free software; you can redistribute it and/or
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.