pen-commits Mailing List for Puzzles from the Engineer's Notebook
Brought to you by:
mdgeorge
You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(7) |
Dec
(29) |
---|
From: <mdg...@us...> - 2008-12-23 18:17:08
|
Revision: 131 http://pen.svn.sourceforge.net/pen/?rev=131&view=rev Author: mdgeorge Date: 2008-12-23 18:17:04 +0000 (Tue, 23 Dec 2008) Log Message: ----------- Added note about menus Added Paths: ----------- doc/menu Added: doc/menu =================================================================== --- doc/menu (rev 0) +++ doc/menu 2008-12-23 18:17:04 UTC (rev 131) @@ -0,0 +1,90 @@ +1. To invoke the menu, user right-clicks anywhere on an object + +2a. the cursor is warped to the center of the object + - we move the cursor because there are two logical places for the menu to + appear. We want it to appear around the center of the selected object so + that we can show the object without it obstructing the menu. We want it to + appear where the cursor is so that the same gesture (i.e. right-click move + up and right) always selects the same action. +2b. the menu expands in an animated way + - however the menu is completely responsive during the animation +2c. if the menu is off the edge then the screen slides to make it visible + - the cursor slides with the menu so that it stays in the same logical spot. + Again, this supports the correspondence between gestures and actions + - something amusing should be in the background + +3. The appearance of the menu + - something like this: + + \ <-> / + \ / + foo \ / other + \ / action + + ------ obj ------- + + toggle / \ set + state / \ target + / X \ + / \ + + - objects obscured by the menu should be either faded out, drawn with dashed + lines (it's not clear the best way to do this), or both + - the object in the center is drawn normally, above the menu + - the entries themselves, and their positions and sizes are specified by the + part. I was thinking of an api where the designer specifies, for each + entry, an action, an image, and a weight. The weight determines the + relative size of that entry. For example, to get the following shape: + + | + | + --- --- + / \ + / \ + + they could specify weights of 3, 3, 2, 2, and 2 + - I think we should have conventions for where things "should" go though, for + example rotation is always on top, delete is always on the bottom or + something. Again, this helps muscle memory + - One thing I'm a little worried about is that the menus have to be different + for the editor and the game. + - It's also not clear what to do with large objects (e.g. a plank that spans + half the screen). + - finally, it's not clear whether the inner and/or outer radii of the menu + should be fixed, specified by the designer, or computed + +4. Interaction with the menu + - there's no buttons that the user has to hit exactly. Anywhere they click is + in one of the "wedges". I think this will aid usability + - as they move the cursor around the selected action is highlighted (e.g. + drawn in blue). We might make a little clicky sound when they cross the + border + - Left click selects an action from the menu, right click dismisses the menu + - Some actions (e.g. rotation) may change the shape of an object, possibly + causing it to intersect with another object. We will always show the black + object where the user has positioned it, but we will also have a faded + object underneath that shows the closest legal position. When the menu is + dismissed, the gray object will be the actual one. + + - - - - - - - - - - - - - - - + | (Obstruction) +---+ | + - - - - - - - - | | - - - - + | | / + | | \ + | | / + | o | / + | b | (gray object) + | j | / + | e | + | c | / + | t | + / | | + | | + / | | + | | + / /| | + + now that I think of it, this might be a good way to do the collision + avoiding dragging as well. + + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-21 15:09:41
|
Revision: 130 http://pen.svn.sourceforge.net/pen/?rev=130&view=rev Author: mdgeorge Date: 2008-12-21 15:09:38 +0000 (Sun, 21 Dec 2008) Log Message: ----------- added pie menu to tech demos Modified Paths: -------------- src/demos/piemenu.py src/pen.py Property Changed: ---------------- src/ Property changes on: src ___________________________________________________________________ Modified: svn:ignore - *.pyc + *.pyc *.pyd Modified: src/demos/piemenu.py =================================================================== --- src/demos/piemenu.py 2008-12-20 06:04:20 UTC (rev 129) +++ src/demos/piemenu.py 2008-12-21 15:09:38 UTC (rev 130) @@ -36,6 +36,11 @@ from globals import paper, screen from pygame.locals import * + pygame.event.set_allowed(None) + pygame.event.set_allowed( QUIT ) + pygame.event.set_allowed( MOUSEBUTTONDOWN ) + pygame.event.set_allowed( KEYDOWN ) + w, h = paper.get_rect().size w += 500; h += 500 bg = pygame.Surface((w,h)) @@ -53,11 +58,14 @@ sprites = pygame.sprite.LayeredDirty() sprites.clear(surf, bg) + clock = pygame.time.Clock() + while True: sprites.update() sprites.draw(surf) screen.blit(surf, (xpos, ypos)) pygame.display.update() + clock.tick(30) events = pygame.event.get() mx, my = pygame.mouse.get_pos() Modified: src/pen.py =================================================================== --- src/pen.py 2008-12-20 06:04:20 UTC (rev 129) +++ src/pen.py 2008-12-21 15:09:38 UTC (rev 130) @@ -68,6 +68,8 @@ demos_menu.add_entry( "Dragging", dragdemo.rundemo ) from demos import circles demos_menu.add_entry( "Collision Avoiding Drag", circles.rundemo ) +from demos import piemenu +demos_menu.add_entry( "Pie Menus", piemenu.rundemo ) demos_menu.add_entry( "Back", menu_exit ) # TODO: render job titles, add minor credits This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-20 06:04:22
|
Revision: 129 http://pen.svn.sourceforge.net/pen/?rev=129&view=rev Author: mdgeorge Date: 2008-12-20 06:04:20 +0000 (Sat, 20 Dec 2008) Log Message: ----------- Added preliminary pie menu experiment. Added Paths: ----------- src/demos/piemenu.py Added: src/demos/piemenu.py =================================================================== --- src/demos/piemenu.py (rev 0) +++ src/demos/piemenu.py 2008-12-20 06:04:20 UTC (rev 129) @@ -0,0 +1,96 @@ +import pygame +import math + +class PieMenuEntry(object): + def __init__(self, action, weight, image, radius = None): + self.action = action + self.weight = weight + self.image = image + + if radius is None: + rect = image.get_rect() + radius = int(math.sqrt(rect.width ** 2 / 4 + rect.height ** 2 / 4)) + + self.radius = radius + +class PieSprite(pygame.sprite.DirtySprite): + def __init__(self, rect): + pygame.sprite.DirtySprite.__init__(self) + self.angle = math.pi + + self.image = pygame.Surface(rect.size) + self.image.fill((255,255,255)) + self.image.set_colorkey((255,255,255)) + + self.rect = rect + self.dirty = 0 + + def update(self): + if self.angle > -math.pi: + self.angle -= 1.1 + pygame.draw.arc(self.image, (0,0,255), self.image.get_rect(), self.angle, math.pi) + self.dirty = 1 + + +def rundemo(): + from globals import paper, screen + from pygame.locals import * + + w, h = paper.get_rect().size + w += 500; h += 500 + bg = pygame.Surface((w,h)) + surf = pygame.Surface((w,h)) + bg.blit(paper, (250,250)) + + paprect = paper.get_rect() + paprect.move_ip((250,250)) # relative to bg + + xpos, ypos = -250, -250 + xres, yres = -250, -250 + + displaying = None + + sprites = pygame.sprite.LayeredDirty() + sprites.clear(surf, bg) + + while True: + sprites.update() + sprites.draw(surf) + screen.blit(surf, (xpos, ypos)) + pygame.display.update() + + events = pygame.event.get() + mx, my = pygame.mouse.get_pos() + + xoff = (xres - xpos) / 2 + yoff = (yres - ypos) / 2 + xpos += xoff; ypos += yoff + if xoff or yoff: + mx += xoff; my += yoff + pygame.mouse.set_pos((mx,my)) + + for event in events: + if event.type == QUIT \ + or event.type == KEYDOWN and event.key == K_ESCAPE: + return + + elif event.type == MOUSEBUTTONDOWN and event.button == 3: + if displaying: + xres, yres = -250, -250 + displaying.kill() + displaying = None + else: + pierect = pygame.Rect(0,0,200,200) + pierect.center = event.pos # relative to screen + pierect.move_ip((-xpos, -ypos)) # relative to bg + clipped = pierect.clamp(paprect) + xres = -250 + clipped.left - pierect.left + yres = -250 + clipped.top - pierect.top + print pierect + + displaying = PieSprite(pierect) + sprites.add(displaying) + + +if __name__ == '__main__': + rundemo() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-06 02:52:33
|
Revision: 128 http://pen.svn.sourceforge.net/pen/?rev=128&view=rev Author: mdgeorge Date: 2008-12-06 02:52:29 +0000 (Sat, 06 Dec 2008) Log Message: ----------- Now crashes when you go to run the demo if maskutils isn't compiled, rather than when you run pen.py Modified Paths: -------------- src/demos/dragdemo.py Modified: src/demos/dragdemo.py =================================================================== --- src/demos/dragdemo.py 2008-12-05 23:56:40 UTC (rev 127) +++ src/demos/dragdemo.py 2008-12-06 02:52:29 UTC (rev 128) @@ -3,8 +3,6 @@ from pygame.sprite import DirtySprite, LayeredDirty from pygame.constants import * -from drag import * - def draw_mask(mask): import pygame result = pygame.Surface(mask.get_size()) @@ -17,6 +15,7 @@ def rundemo(): from globals import screen + from drag import DragManager pygame.event.set_blocked( None ) pygame.event.set_allowed( MOUSEBUTTONDOWN ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-05 23:56:44
|
Revision: 127 http://pen.svn.sourceforge.net/pen/?rev=127&view=rev Author: mdgeorge Date: 2008-12-05 23:56:40 +0000 (Fri, 05 Dec 2008) Log Message: ----------- Added a circle to demo by default. Modified Paths: -------------- src/demos/dragdemo.py Modified: src/demos/dragdemo.py =================================================================== --- src/demos/dragdemo.py 2008-12-05 23:52:47 UTC (rev 126) +++ src/demos/dragdemo.py 2008-12-05 23:56:40 UTC (rev 127) @@ -82,6 +82,16 @@ sprite.mask = pygame.mask.from_surface(surf) sprites.append(sprite) + # big circle + surf = pygame.Surface((100,100)) + surf.set_colorkey((0,0,0)) + draw.circle(surf, (255,255,255), surf.get_rect().center, 45) + sprite = DirtySprite() + sprite.base = surf + sprite.rect = surf.get_rect() + sprite.mask = pygame.mask.from_surface(surf) + sprites.append(sprite) + # draw highlighted versions for s in sprites: # fill contact with blue @@ -106,6 +116,7 @@ drawman = LayeredDirty(sprites) contact = [] circles = [] + while True: event = pygame.event.wait() if event.type == MOUSEBUTTONDOWN and event.button == 1: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-05 23:52:51
|
Revision: 126 http://pen.svn.sourceforge.net/pen/?rev=126&view=rev Author: mdgeorge Date: 2008-12-05 23:52:47 +0000 (Fri, 05 Dec 2008) Log Message: ----------- Split the dragging demo out of drag.py and added it to the menu under tech demos Modified Paths: -------------- src/drag.py src/pen.py Added Paths: ----------- src/demos/dragdemo.py Added: src/demos/dragdemo.py =================================================================== --- src/demos/dragdemo.py (rev 0) +++ src/demos/dragdemo.py 2008-12-05 23:52:47 UTC (rev 126) @@ -0,0 +1,184 @@ +import pygame +from pygame import draw +from pygame.sprite import DirtySprite, LayeredDirty +from pygame.constants import * + +from drag import * + +def draw_mask(mask): + import pygame + result = pygame.Surface(mask.get_size()) + result.set_colorkey((0,0,0)) + for y in range(result.get_size()[1]): + for x in range(result.get_size()[0]): + if mask.get_at((x,y)): + result.set_at((x,y), (127,127,127)) + return result + +def rundemo(): + from globals import screen + + pygame.event.set_blocked( None ) + pygame.event.set_allowed( MOUSEBUTTONDOWN ) + pygame.event.set_allowed( MOUSEBUTTONUP ) + pygame.event.set_allowed( QUIT ) + pygame.event.set_allowed( KEYDOWN ) + pygame.event.set_allowed( MOUSEMOTION ) + + sprites = [] + + # blocky barbell + surf = pygame.Surface((75,25)) + surf.set_colorkey((0,0,0)) + draw.rect(surf, (255,255,255), ((0,0),(25,25))) + draw.rect(surf, (255,255,255), ((50,0),(25,25))) + draw.rect(surf, (255,255,255), ((0,10),(75,5))) + sprite = DirtySprite() + sprite.base = surf + sprite.rect = surf.get_rect() + sprite.mask = pygame.mask.from_surface(surf) + sprites.append(sprite) + + # big L + surf = pygame.Surface((100,100)) + surf.set_colorkey((0,0,0)) + draw.rect(surf, (255,255,255), ((0,0),(100,25))) + draw.rect(surf, (255,255,255), ((75,0),(25,100))) + sprite = DirtySprite() + sprite.base = surf + sprite.rect = surf.get_rect() + sprite.mask = pygame.mask.from_surface(surf) + sprites.append(sprite) + + # conjoined circles + surf = pygame.Surface((100,20)) + surf.set_colorkey((0,0,0)) + draw.circle(surf, (255,255,255), (10,10), 10) + draw.circle(surf, (255,255,255), (90,10), 10) + sprite = DirtySprite() + sprite.base = surf + sprite.rect = surf.get_rect() + sprite.mask = pygame.mask.from_surface(surf) + sprites.append(sprite) + + # small rectangle + surf = pygame.Surface((10,10)) + surf.set_colorkey((0,0,0)) + surf.fill((255,255,255)) + sprite = DirtySprite() + sprite.base = surf + sprite.rect = surf.get_rect() + sprite.mask = pygame.mask.from_surface(surf) + sprites.append(sprite) + + # hole + surf = pygame.Surface((100,100)) + surf.set_colorkey((0,0,0)) + surf.fill((255,255,255)) + draw.rect(surf, (0,0,0), ((30,30), (40,40))) + sprite = DirtySprite() + sprite.base = surf + sprite.rect = surf.get_rect() + sprite.mask = pygame.mask.from_surface(surf) + sprites.append(sprite) + + # draw highlighted versions + for s in sprites: + # fill contact with blue + s.contact = s.base.copy() + s.contact.fill((0,0,255)) + + # mask out the holes + s.base.set_colorkey((255,255,255)) + s.contact.blit(s.base, (0,0)) + + # set the colorkeys + s.base.set_colorkey((0,0,0)) + s.contact.set_colorkey((0,0,0)) + + s.image = s.base + s.rect.move_ip((300,300)) + + bg = pygame.Surface((1024,768)) + debug = False + shadow = None + dragman = DragManager(sprites) + drawman = LayeredDirty(sprites) + contact = [] + circles = [] + while True: + event = pygame.event.wait() + if event.type == MOUSEBUTTONDOWN and event.button == 1: + if dragman.select( event.pos ) is not None and debug: + shadow = DirtySprite() + shadow.image = draw_mask(dragman._shadow) + shadow.rect = dragman._shrect + drawman.add(shadow, layer=-1) + elif event.type == MOUSEBUTTONUP and event.button == 1: + dragman.drop() + if shadow is not None: + shadow.kill() + shadow = None + for c in contact: + c.dirty = 1 + c.image = c.base + elif event.type == MOUSEMOTION: + dragman.drag( event.pos ) + if dragman.selected() is not None: + dragman.selected().dirty = 1 + for c in contact: + c.dirty = 1 + c.image = c.base + contact = dragman.contact() + for c in contact: + c.dirty = 1 + c.image = c.contact + + elif event.type == KEYDOWN and event.key == K_ESCAPE: + break + elif event.type == KEYDOWN and event.key == K_TAB: + debug = not debug + elif event.type == KEYDOWN and event.key == K_SPACE: + sprite = DirtySprite() + + surf = pygame.Surface((100,100)) + surf.set_colorkey((0,0,0)) + draw.circle(surf, (255,255,255), surf.get_rect().center, 45) + label = pygame.font.Font(None, 20).render(str(len(circles)+1), False, (0,0,0), (255,255,255)) + rect = label.get_rect() + rect.center = surf.get_rect().center + surf.blit(label, rect) + + sprite.base = surf + sprite.image = surf + sprite.rect = surf.get_rect() + sprite.mask = pygame.mask.from_surface(surf) + + surf = pygame.Surface((100,100)) + surf.set_colorkey((0,0,0)) + draw.circle(surf, (0,0,255), surf.get_rect().center, 45) + label = pygame.font.Font(None, 20).render(str(len(circles)+1), False, (255,255,255), (0,0,255)) + rect = label.get_rect() + rect.center = surf.get_rect().center + surf.blit(label, rect) + + sprite.contact = surf + + drawman.add(sprite) + dragman.add(sprite) + circles.append(sprite) + + elif event.type == KEYDOWN and event.key == K_BACKSPACE: + if circles: + c = circles[len(circles) - 1] + c.kill() + circles = circles[:-1] + + pygame.display.update(drawman.draw(screen, bg)) + +if __name__ == '__main__': + rundemo() + +# +# vim: ts=4 sw=4 ai +# Modified: src/drag.py =================================================================== --- src/drag.py 2008-12-04 16:07:46 UTC (rev 125) +++ src/drag.py 2008-12-05 23:52:47 UTC (rev 126) @@ -162,182 +162,10 @@ s.__shrect.top - self._shrect.top)) -## Testing ##################################################################### - -def draw_mask(mask): - import pygame - result = pygame.Surface(mask.get_size()) - result.set_colorkey((0,0,0)) - for y in range(result.get_size()[1]): - for x in range(result.get_size()[0]): - if mask.get_at((x,y)): - result.set_at((x,y), (127,127,127)) - return result - if __name__ == '__main__': - import pygame - from pygame import draw - from pygame.sprite import DirtySprite, LayeredDirty - from pygame.constants import * + import demos.dragdemo + demos.dragdemo.rundemo() - pygame.display.init() - pygame.font.init() - - sprites = [] - - # blocky barbell - surf = pygame.Surface((75,25)) - surf.set_colorkey((0,0,0)) - draw.rect(surf, (255,255,255), ((0,0),(25,25))) - draw.rect(surf, (255,255,255), ((50,0),(25,25))) - draw.rect(surf, (255,255,255), ((0,10),(75,5))) - sprite = DirtySprite() - sprite.base = surf - sprite.rect = surf.get_rect() - sprite.mask = pygame.mask.from_surface(surf) - sprites.append(sprite) - - # big L - surf = pygame.Surface((100,100)) - surf.set_colorkey((0,0,0)) - draw.rect(surf, (255,255,255), ((0,0),(100,25))) - draw.rect(surf, (255,255,255), ((75,0),(25,100))) - sprite = DirtySprite() - sprite.base = surf - sprite.rect = surf.get_rect() - sprite.mask = pygame.mask.from_surface(surf) - sprites.append(sprite) - - # conjoined circles - surf = pygame.Surface((100,20)) - surf.set_colorkey((0,0,0)) - draw.circle(surf, (255,255,255), (10,10), 10) - draw.circle(surf, (255,255,255), (90,10), 10) - sprite = DirtySprite() - sprite.base = surf - sprite.rect = surf.get_rect() - sprite.mask = pygame.mask.from_surface(surf) - sprites.append(sprite) - - # small rectangle - surf = pygame.Surface((10,10)) - surf.set_colorkey((0,0,0)) - surf.fill((255,255,255)) - sprite = DirtySprite() - sprite.base = surf - sprite.rect = surf.get_rect() - sprite.mask = pygame.mask.from_surface(surf) - sprites.append(sprite) - - # hole - surf = pygame.Surface((100,100)) - surf.set_colorkey((0,0,0)) - surf.fill((255,255,255)) - draw.rect(surf, (0,0,0), ((30,30), (40,40))) - sprite = DirtySprite() - sprite.base = surf - sprite.rect = surf.get_rect() - sprite.mask = pygame.mask.from_surface(surf) - sprites.append(sprite) - - # draw highlighted versions - for s in sprites: - # fill contact with blue - s.contact = s.base.copy() - s.contact.fill((0,0,255)) - - # mask out the holes - s.base.set_colorkey((255,255,255)) - s.contact.blit(s.base, (0,0)) - - # set the colorkeys - s.base.set_colorkey((0,0,0)) - s.contact.set_colorkey((0,0,0)) - - s.image = s.base - s.rect.move_ip((300,300)) - - - screen = pygame.display.set_mode((1024, 768)) - bg = pygame.Surface((1024,768)) - debug = False - shadow = None - dragman = DragManager(sprites) - drawman = LayeredDirty(sprites) - contact = [] - circles = [] - while True: - event = pygame.event.wait() - if event.type == MOUSEBUTTONDOWN and event.button == 1: - if dragman.select( event.pos ) is not None and debug: - shadow = DirtySprite() - shadow.image = draw_mask(dragman._shadow) - shadow.rect = dragman._shrect - drawman.add(shadow, layer=-1) - elif event.type == MOUSEBUTTONUP and event.button == 1: - dragman.drop() - if shadow is not None: - shadow.kill() - shadow = None - for c in contact: - c.dirty = 1 - c.image = c.base - elif event.type == MOUSEMOTION: - dragman.drag( event.pos ) - if dragman.selected() is not None: - dragman.selected().dirty = 1 - for c in contact: - c.dirty = 1 - c.image = c.base - contact = dragman.contact() - for c in contact: - c.dirty = 1 - c.image = c.contact - - elif event.type == KEYDOWN and event.key == K_ESCAPE: - break - elif event.type == KEYDOWN and event.key == K_TAB: - debug = not debug - elif event.type == KEYDOWN and event.key == K_SPACE: - sprite = DirtySprite() - - surf = pygame.Surface((100,100)) - surf.set_colorkey((0,0,0)) - draw.circle(surf, (255,255,255), surf.get_rect().center, 45) - label = pygame.font.Font(None, 20).render(str(len(circles)+1), False, (0,0,0), (255,255,255)) - rect = label.get_rect() - rect.center = surf.get_rect().center - surf.blit(label, rect) - - sprite.base = surf - sprite.image = surf - sprite.rect = surf.get_rect() - sprite.mask = pygame.mask.from_surface(surf) - - surf = pygame.Surface((100,100)) - surf.set_colorkey((0,0,0)) - draw.circle(surf, (0,0,255), surf.get_rect().center, 45) - label = pygame.font.Font(None, 20).render(str(len(circles)+1), False, (255,255,255), (0,0,255)) - rect = label.get_rect() - rect.center = surf.get_rect().center - surf.blit(label, rect) - - sprite.contact = surf - - drawman.add(sprite) - dragman.add(sprite) - circles.append(sprite) - - elif event.type == KEYDOWN and event.key == K_BACKSPACE: - if circles: - c = circles[len(circles) - 1] - c.kill() - circles = circles[:-1] - - pygame.display.update(drawman.draw(screen, bg)) - - - # # vim: ts=4 sw=4 ai # Modified: src/pen.py =================================================================== --- src/pen.py 2008-12-04 16:07:46 UTC (rev 125) +++ src/pen.py 2008-12-05 23:52:47 UTC (rev 126) @@ -64,8 +64,8 @@ import os from demos import penmunk demos_menu.add_entry( "Physics", penmunk.rundemo ) -# import drag -# demos_menu.add_entry( "Dragging", None ) +from demos import dragdemo +demos_menu.add_entry( "Dragging", dragdemo.rundemo ) from demos import circles demos_menu.add_entry( "Collision Avoiding Drag", circles.rundemo ) demos_menu.add_entry( "Back", menu_exit ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-04 16:07:49
|
Revision: 125 http://pen.svn.sourceforge.net/pen/?rev=125&view=rev Author: mdgeorge Date: 2008-12-04 16:07:46 +0000 (Thu, 04 Dec 2008) Log Message: ----------- Updated the credits. Modified Paths: -------------- AUTHORS src/pen.py Added Paths: ----------- data/images/jstrout.png Removed Paths: ------------- data/images/ksmith.png Modified: AUTHORS =================================================================== --- AUTHORS 2008-12-04 14:58:24 UTC (rev 124) +++ AUTHORS 2008-12-04 16:07:46 UTC (rev 125) @@ -1,6 +1,9 @@ -Written by Michael George (mdg...@cs...) with help from Valerie -George. +Project Lead, Development: Michael George <mdg...@cs...> +Artwork: Valerie George +Development: Joe Strout +Thanks to the python, pygame, pymunk developers! + Font: Handmedown by Brian Kent http://aenigma.cellosoft.com/ Temporary hacker image adapted from xkcd by Randall Munroe: http://xkcd.com/ Added: data/images/jstrout.png =================================================================== (Binary files differ) Property changes on: data/images/jstrout.png ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Deleted: data/images/ksmith.png =================================================================== (Binary files differ) Modified: src/pen.py =================================================================== --- src/pen.py 2008-12-04 14:58:24 UTC (rev 124) +++ src/pen.py 2008-12-04 16:07:46 UTC (rev 125) @@ -75,7 +75,7 @@ picturerect = pygame.Rect( 300, 100, 500, 500 ) credits_menu.add_entry( "Michael George" ).image( load_image( 'mdgeorge.png', -1 ), picturerect ).click_to_select() credits_menu.add_entry( "Valerie George" ).image( load_image( 'smidget.png', -1 ), picturerect ).click_to_select() -credits_menu.add_entry( "Kevin Smith" ).image( load_image( 'ksmith.png', -1 ), picturerect ).click_to_select() +credits_menu.add_entry( "Joe Strout" ).image( load_image( 'jstrout.png', -1 ), picturerect ).click_to_select() credits_menu.add_entry( "Others" ).click_to_select() credits_menu.add_entry( "Back", menu_exit ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-04 14:58:26
|
Revision: 124 http://pen.svn.sourceforge.net/pen/?rev=124&view=rev Author: mdgeorge Date: 2008-12-04 14:58:24 +0000 (Thu, 04 Dec 2008) Log Message: ----------- Fixed a problem with the color on an older pygame. Modified Paths: -------------- src/drag.py Modified: src/drag.py =================================================================== --- src/drag.py 2008-12-04 14:45:06 UTC (rev 123) +++ src/drag.py 2008-12-04 14:58:24 UTC (rev 124) @@ -231,8 +231,8 @@ # hole surf = pygame.Surface((100,100)) + surf.set_colorkey((0,0,0)) surf.fill((255,255,255)) - surf.set_colorkey((0,0,0)) draw.rect(surf, (0,0,0), ((30,30), (40,40))) sprite = DirtySprite() sprite.base = surf @@ -240,12 +240,24 @@ sprite.mask = pygame.mask.from_surface(surf) sprites.append(sprite) + # draw highlighted versions for s in sprites: + # fill contact with blue + s.contact = s.base.copy() + s.contact.fill((0,0,255)) + + # mask out the holes + s.base.set_colorkey((255,255,255)) + s.contact.blit(s.base, (0,0)) + + # set the colorkeys + s.base.set_colorkey((0,0,0)) + s.contact.set_colorkey((0,0,0)) + s.image = s.base - s.contact = s.base.copy() - s.contact.fill((0,0,255), None, BLEND_RGB_MULT) s.rect.move_ip((300,300)) + screen = pygame.display.set_mode((1024, 768)) bg = pygame.Surface((1024,768)) debug = False @@ -287,20 +299,31 @@ elif event.type == KEYDOWN and event.key == K_TAB: debug = not debug elif event.type == KEYDOWN and event.key == K_SPACE: + sprite = DirtySprite() + surf = pygame.Surface((100,100)) surf.set_colorkey((0,0,0)) draw.circle(surf, (255,255,255), surf.get_rect().center, 45) - label = pygame.font.Font(None, 20).render(str(len(circles)+1), False, (127,127,127), (255,255,255)) + label = pygame.font.Font(None, 20).render(str(len(circles)+1), False, (0,0,0), (255,255,255)) rect = label.get_rect() rect.center = surf.get_rect().center surf.blit(label, rect) - sprite = DirtySprite() - sprite.base = surf - sprite.contact = sprite.base.copy() - sprite.contact.fill((0,0,255), None, BLEND_RGB_MULT) - sprite.image = sprite.base - sprite.rect = surf.get_rect() - sprite.mask = pygame.mask.from_surface(surf) + + sprite.base = surf + sprite.image = surf + sprite.rect = surf.get_rect() + sprite.mask = pygame.mask.from_surface(surf) + + surf = pygame.Surface((100,100)) + surf.set_colorkey((0,0,0)) + draw.circle(surf, (0,0,255), surf.get_rect().center, 45) + label = pygame.font.Font(None, 20).render(str(len(circles)+1), False, (255,255,255), (0,0,255)) + rect = label.get_rect() + rect.center = surf.get_rect().center + surf.blit(label, rect) + + sprite.contact = surf + drawman.add(sprite) dragman.add(sprite) circles.append(sprite) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-04 14:45:16
|
Revision: 123 http://pen.svn.sourceforge.net/pen/?rev=123&view=rev Author: mdgeorge Date: 2008-12-04 14:45:06 +0000 (Thu, 04 Dec 2008) Log Message: ----------- Added another header file so that this can be built against the latest release of pygame, instead of needing svn. Added Paths: ----------- pygame/src/pygamedocs.h Added: pygame/src/pygamedocs.h =================================================================== --- pygame/src/pygamedocs.h (rev 0) +++ pygame/src/pygamedocs.h 2008-12-04 14:45:06 UTC (rev 123) @@ -0,0 +1,925 @@ +/* Auto generated file: with makeref.py . Docs go in src/ *.doc . */ +#define DOC_PYGAME "the top level pygame package" + +#define DOC_PYGAMEINIT "pygame.init(): return (numpass, numfail)\ninitialize all imported pygame modules" + +#define DOC_PYGAMEQUIT "pygame.quit(): return None\nuninitialize all pygame modules" + +#define DOC_PYGAMEERROR "raise pygame.error, message\nstandard pygame exception" + +#define DOC_PYGAMEGETERROR "pygame.get_error(): return errorstr\nget the current error message" + +#define DOC_PYGAMEGETSDLVERSION "pygame.get_sdl_version(): return major, minor, patch\nget the version number of SDL" + +#define DOC_PYGAMEGETSDLBYTEORDER "pygame.get_sdl_byteorder(): return int\nget the byte order of SDL" + +#define DOC_PYGAMEREGISTERQUIT "register_quit(callable): return None\nregister a function to be called when pygame quits" + +#define DOC_PYGAMEVERSION "module pygame.version\nsmall module containing version information" + +#define DOC_PYGAMEVERSIONVER "pygame.version.ver = '1.2'\nversion number as a string" + +#define DOC_PYGAMEVERSIONVERNUM "pygame.version.vernum = (1, 5, 3)\ntupled integers of the version" + +#define DOC_PYGAMECAMERA "pygame module for camera use" + +#define DOC_PYGAMECAMERACOLORSPACE "pygame.camera.colorspace(Surface, format, DestSurface = None): return Surface\nSurface colorspace conversion" + +#define DOC_PYGAMECAMERALISTCAMERAS "pygame.camera.list_cameras(): return [cameras]\nreturns a list of available cameras" + +#define DOC_PYGAMECAMERACAMERA "pygame.camera.Camera(device, (width, height), format): return Camera\nload a camera" + +#define DOC_CAMERASTART "Camera.start(): return None\nopens, initializes, and starts capturing" + +#define DOC_CAMERASTOP "Camera.stop(): return None\nstops, uninitializes, and closes the camera" + +#define DOC_CAMERAGETCONTROLS "Camera.get_controls(): return (hflip = bool, vflip = bool)\ngets current values of user controls" + +#define DOC_CAMERASETCONTROLS "Camera.set_controls(hflip = bool, vflip = bool): return (hflip = bool, vflip = bool)\nchanges camera settings if supported by the camera" + +#define DOC_CAMERAGETSIZE "Camera.get_size(): return (width, height)\nreturns the dimensions of the images being recorded" + +#define DOC_CAMERAQUERYIMAGE "Camera.query_image(): return bool\nchecks if a frame is ready" + +#define DOC_CAMERAGETIMAGE "Camera.get_image(Surface = None): return Surface\ncaptures an image as a Surface" + +#define DOC_CAMERAGETRAW "Camera.get_raw(): return string\nreturns an unmodified image as a string" + +#define DOC_PYGAMECDROM "pygame module for audio cdrom control" + +#define DOC_PYGAMECDROMINIT "pygame.cdrom.init(): return None\ninitialize the cdrom module" + +#define DOC_PYGAMECDROMQUIT "pygame.cdrom.quit(): return None\nuninitialize the cdrom module" + +#define DOC_PYGAMECDROMGETINIT "pygame.cdrom.get_init(): return bool\ntrue if the cdrom module is initialized" + +#define DOC_PYGAMECDROMGETCOUNT "pygame.cdrom.get_count(): return count\nnumber of cd drives on the system" + +#define DOC_PYGAMECDROMCD "pygame.cdrom.CD(id): return CD\nclass to manage a cdrom drive" + +#define DOC_CDINIT "CD.init(): return None\ninitialize a cdrom drive for use" + +#define DOC_CDQUIT "CD.quit(): return None\nuninitialize a cdrom drive for use" + +#define DOC_CDGETINIT "CD.get_init(): return bool\ntrue if this cd device initialized" + +#define DOC_CDPLAY "CD.play(track, start=None, end=None): return None\nstart playing audio" + +#define DOC_CDSTOP "CD.stop(): return None\nstop audio playback" + +#define DOC_CDPAUSE "CD.pause(): return None\ntemporarily stop audio playback" + +#define DOC_CDRESUME "CD.resume(): return None\nunpause audio playback" + +#define DOC_CDEJECT "CD.eject(): return None\neject or open the cdrom drive" + +#define DOC_CDGETID "CD.get_id(): return id\nthe index of the cdrom drive" + +#define DOC_CDGETNAME "CD.get_name(): return name\nthe system name of the cdrom drive" + +#define DOC_CDGETBUSY "CD.get_busy(): return bool\ntrue if the drive is playing audio" + +#define DOC_CDGETPAUSED "CD.get_paused(): return bool\ntrue if the drive is paused" + +#define DOC_CDGETCURRENT "CD.get_current(): return track, seconds\nthe current audio playback position" + +#define DOC_CDGETEMPTY "CD.get_empty(): return bool\nFalse if a cdrom is in the drive" + +#define DOC_CDGETNUMTRACKS "CD.get_numtracks(): return count\nthe number of tracks on the cdrom" + +#define DOC_CDGETTRACKAUDIO "CD.get_track_audio(track): return bool\ntrue if the cdrom track has audio data" + +#define DOC_CDGETALL "CD.get_all(): return [(audio, start, end, lenth), ...]\nget all track information" + +#define DOC_CDGETTRACKSTART "CD.get_track_start(track): return seconds\nstart time of a cdrom track" + +#define DOC_CDGETTRACKLENGTH "CD.get_track_length(track): return seconds\nlength of a cdrom track" + +#define DOC_PYGAMECOLOR "pygame.Color(name): Return Color\npygame.Color(r, g, b, a): Return Color\npygame.Color(rgbvalue): Return Color\npygame object for color representations" + +#define DOC_COLORR "Color.r: Return int\nGets or sets the red value of the Color." + +#define DOC_COLORG "Color.g: Return int\nGets or sets the green value of the Color." + +#define DOC_COLORB "Color.b: Return int\nGets or sets the blue value of the Color." + +#define DOC_COLORA "Color.a: Return int\nGets or sets the alpha value of the Color." + +#define DOC_COLORCMY "Color.cmy: Return tuple\nGets or sets the CMY representation of the Color." + +#define DOC_COLORHSVA "Color.hsva: Return tuple\nGets or sets the HSVA representation of the Color." + +#define DOC_COLORHSLA "Color.hsla: Return tuple\nGets or sets the HSLA representation of the Color." + +#define DOC_COLORI1I2I3 "Color.i1i2i3: Return tuple\nGets or sets the I1I2I3 representation of the Color." + +#define DOC_COLORNORMALIZE "Color.normalize(): Return tuple\nReturns the normalized RGBA values of the Color." + +#define DOC_COLORCORRECTGAMMA "Color.correct_gamma (gamma): Return Color\nApplies a certain gamma value to the Color." + +#define DOC_PYGAMECURSORS "pygame module for cursor resources" + +#define DOC_PYGAMECURSORSCOMPILE "pygame.cursor.compile(strings, black='X', white='.', xor='o'): return data, mask\ncreate binary cursor data from simple strings" + +#define DOC_PYGAMECURSORSLOADXBM "pygame.cursors.load_xbm(cursorfile, maskfile=None): return cursor_args\nload cursor data from an xbm file" + +#define DOC_PYGAMEDISPLAY "pygame module to control the display window and screen" + +#define DOC_PYGAMEDISPLAYINIT "pygame.display.init(): return None\ninitialize the display module" + +#define DOC_PYGAMEDISPLAYQUIT "pygame.display.quit(): return None\nuninitialize the display module" + +#define DOC_PYGAMEDISPLAYGETINIT "pygame.display.get_init(): return bool\ntrue if the display module is initialized" + +#define DOC_PYGAMEDISPLAYSETMODE "pygame.display.set_mode(resolution=(0,0), flags=0, depth=0): return Surface\ninitialize a window or screen for display" + +#define DOC_PYGAMEDISPLAYGETSURFACE "pygame.display.get_surface(): return Surface\nget a reference to the currently set display surface" + +#define DOC_PYGAMEDISPLAYFLIP "pygame.display.flip(): return None\nupdate the full display Surface to the screen" + +#define DOC_PYGAMEDISPLAYUPDATE "pygame.display.update(rectangle=None): return None\npygame.display.update(rectangle_list): return None\nupdate portions of the screen for software displays" + +#define DOC_PYGAMEDISPLAYGETDRIVER "pygame.display.get_driver(): return name\nget the name of the pygame display backend" + +#define DOC_PYGAMEDISPLAYINFO "pygame.display.Info(): return VideoInfo\nCreate a video display information object" + +#define DOC_PYGAMEDISPLAYGETWMINFO "pygame.display.get_wm_info(): return dict\nGet information about the current windowing system" + +#define DOC_PYGAMEDISPLAYLISTMODES "pygame.display.list_modes(depth=0, flags=pygame.FULLSCREEN): return list\nget list of available fullscreen modes" + +#define DOC_PYGAMEDISPLAYMODEOK "pygame.display.mode_ok(size, flags=0, depth=0): return depth\npick the best color depth for a display mode" + +#define DOC_PYGAMEDISPLAYGLGETATTRIBUTE "pygame.display.gl_get_attribute(flag): return value\nget the value for an opengl flag for the current display" + +#define DOC_PYGAMEDISPLAYGLSETATTRIBUTE "pygame.display.gl_set_attribute(flag, value): return None\nrequest an opengl display attribute for the display mode" + +#define DOC_PYGAMEDISPLAYGETACTIVE "pygame.display.get_active(): return bool\ntrue when the display is active on the display" + +#define DOC_PYGAMEDISPLAYICONIFY "pygame.display.iconify(): return bool\niconify the display surface" + +#define DOC_PYGAMEDISPLAYTOGGLEFULLSCREEN "pygame.display.toggle_fullscreen(): return bool\nswitch between fullscreen and windowed displays" + +#define DOC_PYGAMEDISPLAYSETGAMMA "pygame.display.set_gamma(red, green=None, blue=None): return bool\nchange the hardware gamma ramps" + +#define DOC_PYGAMEDISPLAYSETGAMMARAMP "change the hardware gamma ramps with a custom lookup\npygame.display.set_gamma_ramp(red, green, blue): return bool\nset_gamma_ramp(red, green, blue): return bool" + +#define DOC_PYGAMEDISPLAYSETICON "pygame.display.set_icon(Surface): return None\nchange the system image for the display window" + +#define DOC_PYGAMEDISPLAYSETCAPTION "pygame.display.set_caption(title, icontitle=None): return None\nset the current window caption" + +#define DOC_PYGAMEDISPLAYGETCAPTION "pygame.display.get_caption(): return (title, icontitle)\nget the current window caption" + +#define DOC_PYGAMEDISPLAYSETPALETTE "pygame.display.set_palette(palette=None): return None\nset the display color palette for indexed displays" + +#define DOC_PYGAMEDRAW "pygame module for drawing shapes" + +#define DOC_PYGAMEDRAWRECT "pygame.draw.rect(Surface, color, Rect, width=0): return Rect\ndraw a rectangle shape" + +#define DOC_PYGAMEDRAWPOLYGON "pygame.draw.polygon(Surface, color, pointlist, width=0): return Rect\ndraw a shape with any number of sides" + +#define DOC_PYGAMEDRAWCIRCLE "pygame.draw.circle(Surface, color, pos, radius, width=0): return Rect\ndraw a circle around a point" + +#define DOC_PYGAMEDRAWELLIPSE "pygame.draw.ellipse(Surface, color, Rect, width=0): return Rect\ndraw a round shape inside a rectangle" + +#define DOC_PYGAMEDRAWARC "pygame.draw.arc(Surface, color, Rect, start_angle, stop_angle, width=1): return Rect\ndraw a partial section of an ellipse" + +#define DOC_PYGAMEDRAWLINE "pygame.draw.line(Surface, color, start_pos, end_pos, width=1): return Rect\ndraw a straight line segment" + +#define DOC_PYGAMEDRAWLINES "pygame.draw.lines(Surface, color, closed, pointlist, width=1): return Rect\ndraw multiple contiguous line segments" + +#define DOC_PYGAMEDRAWAALINE "pygame.draw.aaline(Surface, color, startpos, endpos, blend=1): return Rect\ndraw fine antialiased lines" + +#define DOC_PYGAMEDRAWAALINES "pygame.draw.aalines(Surface, color, closed, pointlist, blend=1): return Rect" + +#define DOC_PYGAMEEVENT "pygame module for interacting with events and queues" + +#define DOC_PYGAMEEVENTPUMP "pygame.event.pump(): return None\ninternally process pygame event handlers" + +#define DOC_PYGAMEEVENTGET "pygame.event.get(): return Eventlist\npygame.event.get(type): return Eventlist\npygame.event.get(typelist): return Eventlist\nget events from the queue" + +#define DOC_PYGAMEEVENTPOLL "pygame.event.poll(): return Event\nget a single event from the queue" + +#define DOC_PYGAMEEVENTWAIT "pygame.event.wait(): return Event\nwait for a single event from the queue" + +#define DOC_PYGAMEEVENTPEEK "pygame.event.peek(type): return bool\npygame.event.peek(typelist): return bool\ntest if event types are waiting on the queue" + +#define DOC_PYGAMEEVENTCLEAR "pygame.event.clear(): return None\npygame.event.clear(type): return None\npygame.event.clear(typelist): return None\nremove all events from the queue" + +#define DOC_PYGAMEEVENTEVENTNAME "pygame.event.event_name(type): return string\nget the string name from and event id" + +#define DOC_PYGAMEEVENTSETBLOCKED "pygame.event.set_blocked(type): return None\npygame.event.set_blocked(typelist): return None\npygame.event.set_blocked(None): return None\ncontrol which events are allowed on the queue" + +#define DOC_PYGAMEEVENTSETALLOWED "pygame.event.set_allowed(type): return None\npygame.event.set_allowed(typelist): return None\npygame.event.set_allowed(None): return None\ncontrol which events are allowed on the queue" + +#define DOC_PYGAMEEVENTGETBLOCKED "pygame.event.get_blocked(type): return bool\ntest if a type of event is blocked from the queue" + +#define DOC_PYGAMEEVENTSETGRAB "pygame.event.set_grab(bool): return None\ncontrol the sharing of input devices with other applications" + +#define DOC_PYGAMEEVENTGETGRAB "pygame.event.get_grab(): return bool\ntest if the program is sharing input devices" + +#define DOC_PYGAMEEVENTPOST "pygame.event.post(Event): return None\nplace a new event on the queue" + +#define DOC_PYGAMEEVENTEVENT "pygame.event.Event(type, dict): return Event\npygame.event.Event(type, **attributes): return Event\ncreate a new event object" + +#define DOC_PYGAMEFONT "pygame module for loading and rendering fonts" + +#define DOC_PYGAMEFONTINIT "pygame.font.init(): return None\ninitialize the font module" + +#define DOC_PYGAMEFONTQUIT "pygame.font.quit(): return None\nuninitialize the font module" + +#define DOC_PYGAMEFONTGETINIT "pygame.font.get_init(): return bool\ntrue if the font module is initialized" + +#define DOC_PYGAMEFONTGETDEFAULTFONT "pygame.font.get_default_font(): return string\nget the filename of the default font" + +#define DOC_PYGAMEFONTGETFONTS "pygame.font.get_fonts(): return list of strings\nget all available fonts" + +#define DOC_PYGAMEFONTMATCHFONT "pygame.font.match_font(name, bold=False, italic=False): return path\nfind a specific font on the system" + +#define DOC_PYGAMEFONTSYSFONT "pygame.font.SysFont(name, size, bold=False, italic=False): return Font\ncreate a Font object from the system fonts" + +#define DOC_PYGAMEFONTFONT "pygame.font.Font(filename, size): return Font\npygame.font.Font(object, size): return Font\ncreate a new Font object from a file" + +#define DOC_FONTRENDER "Font.render(text, antialias, color, background=None): return Surface\ndraw text on a new Surface" + +#define DOC_FONTSIZE "Font.size(text): return (width, height)\ndetermine the amount of space needed to render text" + +#define DOC_FONTSETUNDERLINE "Font.set_underline(bool): return None\ncontrol if text is rendered with an underline" + +#define DOC_FONTGETUNDERLINE "Font.get_underline(): return bool\ncheck if text will be rendered with an underline" + +#define DOC_FONTSETBOLD "Font.set_bold(bool): return None\nenable fake rendering of bold text" + +#define DOC_FONTGETBOLD "Font.get_bold(): return bool\ncheck if text will be rendered bold" + +#define DOC_FONTSETITALIC "Font.set_bold(bool): return None\nenable fake rendering of italic text" + +#define DOC_FONTMETRICS "Font.metrics(text): return list\nGets the metrics for each character in the pased string." + +#define DOC_FONTGETITALIC "Font.get_italic(): return bool\ncheck if the text will be rendered italic" + +#define DOC_FONTGETLINESIZE "Font.get_linesize(): return int\nget the line space of the font text" + +#define DOC_FONTGETHEIGHT "Font.get_height(): return int\nget the height of the font" + +#define DOC_FONTGETASCENT "Font.get_ascent(): return int\nget the ascent of the font" + +#define DOC_FONTGETDESCENT "Font.get_descent(): return int\nget the descent of the font" + +#define DOC_PYGAMEIMAGE "pygame module for image transfer" + +#define DOC_PYGAMEIMAGELOAD "pygame.image.load(filename): return Surface\npygame.image.load(fileobj, namehint=""): return Surface\nload new image from a file" + +#define DOC_PYGAMEIMAGESAVE "pygame.image.save(Surface, filename): return None\nsave an image to disk" + +#define DOC_PYGAMEIMAGEGETEXTENDED "pygame.image.get_extended(): return bool\ntest if extended image formats can be loaded" + +#define DOC_PYGAMEIMAGETOSTRING "pygame.image.tostring(Surface, format, flipped=False): return string\ntransfer image to string buffer" + +#define DOC_PYGAMEIMAGEFROMSTRING "pygame.image.fromstring(string, size, format, flipped=False): return Surface\ncreate new Surface from a string buffer" + +#define DOC_PYGAMEIMAGEFROMBUFFER "pygame.image.frombuffer(string, size, format): return Surface\ncreate a new Surface that shares data inside a string buffer" + +#define DOC_PYGAMEJOYSTICK "pygame module for interacting with joystick devices" + +#define DOC_PYGAMEJOYSTICKINIT "pygame.joystick.init(): return None\ninitialize the joystick module" + +#define DOC_PYGAMEJOYSTICKQUIT "pygame.joystick.quit(): return None\nuninitialize the joystick module" + +#define DOC_PYGAMEJOYSTICKGETINIT "pygame.joystick.get_init(): return bool\ntrue if the joystick module is initialized" + +#define DOC_PYGAMEJOYSTICKGETCOUNT "pygame.joystick.get_count(): return count\nnumber of joysticks on the system" + +#define DOC_PYGAMEJOYSTICKJOYSTICK "pygame.joystick.Joystick(id): return Joystick\ncreate a new Joystick object" + +#define DOC_JOYSTICKINIT "Joystick.init(): return None\ninitialize the Joystick" + +#define DOC_JOYSTICKQUIT "Joystick.quit(): return None\nuninitialize the Joystick" + +#define DOC_JOYSTICKGETINIT "Joystick.get_init(): return bool\ncheck if the Joystick is initialized" + +#define DOC_JOYSTICKGETID "Joystick.get_id(): return int\nget the Joystick ID" + +#define DOC_JOYSTICKGETNAME "Joystick.get_name(): return string\nget the Joystick system name" + +#define DOC_JOYSTICKGETNUMAXES "Joystick.get_numaxes(): return int\nget the number of axes on a Joystick" + +#define DOC_JOYSTICKGETAXIS "Joystick.get_axis(axis_number): return float\nget the current position of an axis" + +#define DOC_JOYSTICKGETNUMBALLS "Joystick.get_numballs(): return int\nget the number of trackballs on a Joystick" + +#define DOC_JOYSTICKGETBALL "Joystick.get_ball(ball_number): return x, y\nget the relative position of a trackball" + +#define DOC_JOYSTICKGETNUMBUTTONS "Joystick.get_numbuttons(): return int\nget the number of buttons on a Joystick" + +#define DOC_JOYSTICKGETBUTTON "Joystick.get_button(button): return bool\nget the current button state" + +#define DOC_JOYSTICKGETNUMHATS "Joystick.get_numhats(): return int\nget the number of hat controls on a Joystick" + +#define DOC_JOYSTICKGETHAT "Joystick.get_hat(hat_number): return x, y\nget the position of a joystick hat" + +#define DOC_PYGAMEKEY "pygame module to work with the keyboard" + +#define DOC_PYGAMEKEYGETFOCUSED "pygame.key.get_focused(): return bool\ntrue if the display is receiving keyboard input from the system" + +#define DOC_PYGAMEKEYGETPRESSED "pygame.key.get_pressed(): return bools\nget the state of all keyboard buttons" + +#define DOC_PYGAMEKEYGETMODS "pygame.key.get_mods(): return int\ndetermine which modifier keys are being held" + +#define DOC_PYGAMEKEYSETMODS "pygame.key.set_mods(int): return None\ntemporarily set which modifier keys are pressed" + +#define DOC_PYGAMEKEYSETREPEAT "pygame.key.set_repeat(): return None\npygame.key.set_repeat(delay, interval): return None\ncontrol how held keys are repeated" + +#define DOC_PYGAMEKEYGETREPEAT "pygame.key.get_repeat(): return (delay, interval)\nsee how held keys are repeated" + +#define DOC_PYGAMEKEYNAME "pygame.key.name(key): return string\nget the name of a key identifier" + +#define DOC_PYGAMECONTANTS "Pygame constants" + +#define DOC_DISPLAY "The following constants are used by the display module and Surfaces" + +#define DOC_EVENTS "These constants define the various event types" + +#define DOC_KEYBOARD "These constants represent the keys on the keyboard." + +#define DOC_MODIFIERS "These constants represent the modifier keys on the keyboard." + +#define DOC_TIME "These constants define the various time constants" + +#define DOC_PYGAMEMASK "pygame module for image masks." + +#define DOC_PYGAMEMASKFROMSURFACE "pygame.mask.from_surface(Surface, threshold = 127) -> Mask\nReturns a Mask from the given surface." + +#define DOC_PYGAMEMASKFROMTHRESHOLD "pygame.mask.from_surface(Surface, color, threshold = (0,0,0,255), othersurface = None) -> Mask\nCreates a mask by thresholding Surfaces" + +#define DOC_PYGAMEMASKMASK "pygame.Mask((width, height)): return Mask\npygame object for representing 2d bitmasks" + +#define DOC_MASKGETSIZE "Mask.get_size() -> width,height\nReturns the size of the mask." + +#define DOC_MASKGETAT "Mask.get_at((x,y)) -> int\nReturns nonzero if the bit at (x,y) is set." + +#define DOC_MASKSETAT "Mask.set_at((x,y),value)\nSets the position in the mask given by x and y." + +#define DOC_MASKOVERLAP "Mask.overlap(othermask, offset) -> x,y\nReturns the point of intersection if the masks overlap with the given offset - or None if it does not overlap." + +#define DOC_MASKOVERLAPAREA "Mask.overlap_area(othermask, offset) -> numpixels\nReturns the number of overlapping 'pixels'." + +#define DOC_MASKOVERLAPMASK "Mask.overlap_mask(othermask, offset) -> Mask\nReturns a mask of the overlapping pixels" + +#define DOC_MASKFILL "Mask.fill()\nSets all bits to 1" + +#define DOC_MASKCLEAR "Mask.clear()\nSets all bits to 0" + +#define DOC_MASKINVERT "Mask.invert()\nFlips the bits in a Mask" + +#define DOC_MASKSCALE "Mask.scale((x, y)) -> Mask\nResizes a mask" + +#define DOC_MASKDRAW "Mask.draw(othermask, offset)\nDraws a mask onto another" + +#define DOC_MASKERASE "Mask.erase(othermask, offset)\nErases a mask from another" + +#define DOC_MASKCOUNT "Mask.count() -> pixels\nReturns the number of set pixels" + +#define DOC_MASKCENTROID "Mask.centroid() -> (x, y)\nReturns the centroid of the pixels in a Mask" + +#define DOC_MASKANGLE "Mask.angle() -> theta\nReturns the orientation of the pixels" + +#define DOC_MASKOUTLINE "Mask.outline(every = 1) -> [(x,y), (x,y) ...]\nlist of points outlining an object" + +#define DOC_MASKCONNECTEDCOMPONENT "Mask.connected_component((x,y) = None) -> Mask\nReturns a mask of a connected region of pixels." + +#define DOC_MASKCONNECTEDCOMPONENTS "Mask.connected_components(min = 0) -> [Masks]\nReturns a list of masks of connected regions of pixels." + +#define DOC_MASKGETBOUNDINGRECTS "Mask.get_bounding_rects() -> Rects\nReturns a list of bounding rects of regions of set pixels." + +#define DOC_PYGAMEMIXER "pygame module for loading and playing sounds" + +#define DOC_PYGAMEMIXERINIT "pygame.mixer.init(frequency=22050, size=-16, channels=2, buffer=3072): return None\ninitialize the mixer module" + +#define DOC_PYGAMEMIXERPREINIT "pygame.mixer.pre_init(frequency=0, size=0, channels=0, buffersize=0): return None\npreset the mixer init arguments" + +#define DOC_PYGAMEMIXERQUIT "pygame.mixer.quit(): return None\nuninitialize the mixer" + +#define DOC_PYGAMEMIXERGETINIT "pygame.mixer.get_init(): return (frequency, format, channels)\ntest if the mixer is initialized" + +#define DOC_PYGAMEMIXERSTOP "pygame.mixer.stop(): return None\nstop playback of all sound channels" + +#define DOC_PYGAMEMIXERPAUSE "pygame.mixer.pause(): return None\ntemporarily stop playback of all sound channels" + +#define DOC_PYGAMEMIXERUNPAUSE "pygame.mixer.unpause(): return None\nresume paused playback of sound channels" + +#define DOC_PYGAMEMIXERFADEOUT "pygame.mixer.fadeout(time): return None\nfade out the volume on all sounds before stopping" + +#define DOC_PYGAMEMIXERSETNUMCHANNELS "pygame.mixer.set_num_channels(count): return None\nset the total number of playback channels" + +#define DOC_PYGAMEMIXERGETNUMCHANNELS "get the total number of playback channels" + +#define DOC_PYGAMEMIXERSETRESERVED "pygame.mixer.set_reserved(count): return None\nreserve channels from being automatically used" + +#define DOC_PYGAMEMIXERFINDCHANNEL "pygame.mixer.find_channel(force=False): return Channel\nfind an unused channel" + +#define DOC_PYGAMEMIXERGETBUSY "pygame.mixer.get_busy(): return bool\ntest if any sound is being mixed" + +#define DOC_PYGAMEMIXERSOUND "pygame.mixer.Sound(filename): return Sound\npygame.mixer.Sound(buffer): return Sound\npygame.mixer.Sound(object): return Sound\nCreate a new Sound object from a file" + +#define DOC_SOUNDPLAY "Sound.play(loops=0, maxtime=0, fade_ms=0): return Channel\nbegin sound playback" + +#define DOC_SOUNDSTOP "Sound.stop(): return None\nstop sound playback" + +#define DOC_SOUNDFADEOUT "Sound.fadeout(time): return None\nstop sound playback after fading out" + +#define DOC_SOUNDSETVOLUME "Sound.set_volume(value): return None\nset the playback volume for this Sound" + +#define DOC_SOUNDGETVOLUME "Sound.get_volume(): return value\nget the playback volume" + +#define DOC_SOUNDGETNUMCHANNELS "Sound.get_num_channels(): return count\ncount how many times this Sound is playing" + +#define DOC_SOUNDGETLENGTH "Sound.get_length(): return seconds\nget the length of the Sound" + +#define DOC_SOUNDGETBUFFER "Sound.get_buffer(): return BufferProxy\nacquires a buffer object for the sameples of the Sound." + +#define DOC_PYGAMEMIXERCHANNEL "pygame.mixer.Channel(id): return Channel\nCreate a Channel object for controlling playback" + +#define DOC_CHANNELPLAY "Channel.play(Sound, loops=0, maxtime=0, fade_ms=0): return None\nplay a Sound on a specific Channel" + +#define DOC_CHANNELSTOP "Channel.stop(): return None\nstop playback on a Channel" + +#define DOC_CHANNELPAUSE "Channel.pause(): return None\ntemporarily stop playback of a channel" + +#define DOC_CHANNELUNPAUSE "Channel.unpause(): return None\nresume pause playback of a channel" + +#define DOC_CHANNELFADEOUT "Channel.fadeout(time): return None\nstop playback after fading channel out" + +#define DOC_CHANNELSETVOLUME "Channel.set_volume(value): return None\nChannel.set_volume(left, right): return None\nset the volume of a playing channel" + +#define DOC_CHANNELGETVOLUME "Channel.get_volume(): return value\nget the volume of the playing channel" + +#define DOC_CHANNELGETBUSY "Channel.get_busy(): return bool\ncheck if the channel is active" + +#define DOC_CHANNELGETSOUND "Channel.get_sound(): return Sound\nget the currently playing Sound" + +#define DOC_CHANNELQUEUE "Channel.queue(Sound): return None\nqueue a Sound object to follow the current" + +#define DOC_CHANNELGETQUEUE "Channel.get_queue(): return Sound\nreturn any Sound that is queued" + +#define DOC_CHANNELSETENDEVENT "Channel.set_endevent(): return None\nChannel.set_endevent(type): return None\nhave the channel send an event when playback stops" + +#define DOC_CHANNELGETENDEVENT "Channel.get_endevent(): return type\nget the event a channel sends when playback stops" + +#define DOC_PYGAMEMOUSE "pygame module to work with the mouse" + +#define DOC_PYGAMEMOUSEGETPRESSED "pygame.moouse.get_pressed(): return (button1, button2, button3)\nget the state of the mouse buttons" + +#define DOC_PYGAMEMOUSEGETPOS "pygame.mouse.get_pos(): return (x, y)\nget the mouse cursor position" + +#define DOC_PYGAMEMOUSEGETREL "pygame.mouse.get_rel(): return (x, y)\nget the amount of mouse movement" + +#define DOC_PYGAMEMOUSESETPOS "pygame.mouse.set_pos([x, y]): return None\nset the mouse cursor position" + +#define DOC_PYGAMEMOUSESETVISIBLE "pygame.mouse.set_visible(bool): return bool\nhide or show the mouse cursor" + +#define DOC_PYGAMEMOUSEGETFOCUSED "pygame.mouse.get_focused(): return bool\ncheck if the display is receiving mouse input" + +#define DOC_PYGAMEMOUSESETCURSOR "pygame.mouse.set_cursor(size, hotspot, xormasks, andmasks): return None\nset the image for the system mouse cursor" + +#define DOC_PYGAMEMOUSEGETCURSOR "pygame.mouse.get_cursor(): return (size, hotspot, xormasks, andmasks)\nget the image for the system mouse cursor" + +#define DOC_PYGAMEMOVIE "pygame module for playback of mpeg video" + +#define DOC_PYGAMEMOVIEMOVIE "pygame.movie.Movie(filename): return Movie\npygame.movie.Movie(object): return Movie\nload an mpeg movie file" + +#define DOC_MOVIEPLAY "Movie.play(loops=0): return None\nstart playback of a movie" + +#define DOC_MOVIESTOP "Movie.stop(): return None\nstop movie playback" + +#define DOC_MOVIEPAUSE "Movie.pause(): return None\ntemporarily stop and resume playback" + +#define DOC_MOVIESKIP "Movie.skip(seconds): return None\nadvance the movie playback position" + +#define DOC_MOVIEREWIND "Movie.rewind(): return None\nrestart the movie playback" + +#define DOC_MOVIERENDERFRAME "Movie.render_frame(frame_number): return frame_number\nset the current video frame" + +#define DOC_MOVIEGETFRAME "Movie.get_frame(): return frame_number\nget the current video frame" + +#define DOC_MOVIEGETTIME "Movie.get_time(): return seconds\nget the current vide playback time" + +#define DOC_MOVIEGETBUSY "Movie.get_busy(): return bool\ncheck if the movie is currently playing" + +#define DOC_MOVIEGETLENGTH "Movie.get_length(): return seconds\nthe total length of the movie in seconds" + +#define DOC_MOVIEGETSIZE "Movie.get_size(): return (width, height)\nget the resolution of the video" + +#define DOC_MOVIEHASVIDEO "Movie.get_video(): return bool\ncheck if the movie file contains video" + +#define DOC_MOVIEHASAUDIO "Movie.get_audio(): return bool\ncheck if the movie file contains audio" + +#define DOC_MOVIESETVOLUME "Movie.set_volume(value): return None\nset the audio playback volume" + +#define DOC_MOVIESETDISPLAY "Movie.set_display(Surface, rect=None): return None\nset the video target Surface" + +#define DOC_PYGAMEMIXERMUSIC "pygame module for controlling streamed audio" + +#define DOC_PYGAMEMIXERMUSICLOAD "pygame.mixer.music.load(filename): return None\nLoad a music file for playback" + +#define DOC_PYGAMEMIXERMUSICPLAY "pygame.mixer.music.play(loops=0, start=0.0): return None\nStart the playback of the music stream" + +#define DOC_PYGAMEMIXERMUSICREWIND "pygame.mixer.music.rewind(): return None\nrestart music" + +#define DOC_PYGAMEMIXERMUSICSTOP "pygame.mixer.music.stop(): return None\nstop the music playback" + +#define DOC_PYGAMEMIXERMUSICPAUSE "pygame.mixer.music.pause(): return None\ntemporarily stop music playback" + +#define DOC_PYGAMEMIXERMUSICUNPAUSE "pygame.mixer.music.unpause(): return None\nresume paused music" + +#define DOC_PYGAMEMIXERMUSICFADEOUT "pygame.mixer.music.fadeout(time): return None\nstop music playback after fading out" + +#define DOC_PYGAMEMIXERMUSICSETVOLUME "pygame.mixer.music.set_volume(value): return None\nset the music volume" + +#define DOC_PYGAMEMIXERMUSICGETVOLUME "pygame.mixer.music.get_volume(): return value\nget the music volume" + +#define DOC_PYGAMEMIXERMUSICGETBUSY "pygame.mixer.music.get_busy(): return bool\ncheck if the music stream is playing" + +#define DOC_PYGAMEMIXERMUSICGETPOS "pygame.mixer.music.get_pos(): return time\nget the music play time" + +#define DOC_PYGAMEMIXERMUSICQUEUE "pygame.mixer.music.queue(filename): return None\nqueue a music file to follow the current" + +#define DOC_PYGAMEMIXERMUSICSETENDEVENT "pygame.mixer.music.set_endevent(): return None\npygame.mixer.music.set_endevent(type): return None\nhave the music send an event when playback stops" + +#define DOC_PYGAMEMIXERMUSICGETENDEVENT "pygame.mixer.music.get_endevent(): return type\nget the event a channel sends when playback stops" + +#define DOC_PYGAMEOVERLAY "pygame.Overlay(format, (width, height)): return Overlay\npygame object for video overlay graphics" + +#define DOC_OVERLAYDISPLAY "Overlay.display((y, u, v)): return None\nOverlay.display(): return None\nset the overlay pixel data" + +#define DOC_OVERLAYSETLOCATION "Overlay.set_location(rect): return None\ncontrol where the overlay is displayed" + +#define DOC_OVERLAYGETHARDWARE "Overlay.get_hardware(rect): return int\ntest if the Overlay is hardware accelerated" + +#define DOC_PYGAMEPIXELARRAY "pygame.PixelArray(Surface): return PixelArray\npygame object for direct pixel access of surfaces" + +#define DOC_PIXELARRAYSURFACE "PixelArray.surface: Return Surface\nGets the Surface the PixelArray uses." + +#define DOC_PIXELARRAYMAKESURFACE "PixelArray.make_surface (): Return Surface\nCreates a new Surface from the current PixelArray." + +#define DOC_PIXELARRAYREPLACE "PixelArray.replace (color, repcolor, distance=0, weights=(0.299, 0.587, 0.114)): Return None\nReplaces the passed color in the PixelArray with another one." + +#define DOC_PIXELARRAYEXTRACT "PixelArray.extract (color, distance=0, weights=(0.299, 0.587, 0.114)): Return PixelArray\nExtracts the passed color from the PixelArray." + +#define DOC_PIXELARRAYCOMPARE "PixelArray.compare (array, distance=0, weights=(0.299, 0.587, 0.114)): Return PixelArray\nCompares the PixelArray with another one." + +#define DOC_PYGAMERECT "pygame.Rect(left, top, width, height): return Rect\npygame.Rect((left, top), (width, height)): return Rect\npygame.Rect(object): return Rect\npygame object for storing rectangular coordinates" + +#define DOC_RECTMOVE "Rect.move(x, y): return Rect\nmoves the rectangle" + +#define DOC_RECTMOVEIP "Rect.move_ip(x, y): return None\nmoves the rectangle, in place" + +#define DOC_RECTINFLATE "Rect.inflate(x, y): return Rect\ngrow or shrink the rectangle size" + +#define DOC_RECTINFLATEIP "Rect.inflate_ip(x, y): return None\ngrow or shrink the rectangle size, in place" + +#define DOC_RECTCLAMP "Rect.clamp(Rect): return Rect\nmoves the rectangle inside another" + +#define DOC_RECTCLAMPIP "Rect.clamp_ip(Rect): return None\nmoves the rectangle inside another, in place" + +#define DOC_RECTCLIP "Rect.clip(Rect): return Rect\ncrops a rectangle inside another" + +#define DOC_RECTUNION "Rect.union(Rect): return Rect\njoins two rectangles into one" + +#define DOC_RECTUNIONIP "Rect.union_ip(Rect): return None\njoins two rectangles into one, in place" + +#define DOC_RECTUNIONALL "Rect.unionall(Rect_sequence): return Rect\nthe union of many rectangles" + +#define DOC_RECTUNIONALLIP "Rect.unionall_ip(Rect_sequence): return None\nthe union of many rectangles, in place" + +#define DOC_RECTFIT "Rect.fit(Rect): return Rect\nresize and move a rectangle with aspect ratio" + +#define DOC_RECTNORMALIZE "Rect.normalize(): return None\ncorrect negative sizes" + +#define DOC_RECTCONTAINS "Rect.contains(Rect): return bool\ntest if one rectangle is inside another" + +#define DOC_RECTCOLLIDEPOINT "Rect.collidepoint(x, y): return bool\nRect.collidepoint((x,y)): return bool\ntest if a point is inside a rectangle" + +#define DOC_RECTCOLLIDERECT "Rect.colliderect(Rect): return bool\ntest if two rectangles overlap" + +#define DOC_RECTCOLLIDELIST "Rect.collidelist(list): return index\ntest if one rectangle in a list intersects" + +#define DOC_RECTCOLLIDELISTALL "Rect.collidelistall(list): return indices\ntest if all rectangles in a list intersect" + +#define DOC_RECTCOLLIDEDICT "Rect.collidedict(dict): return (key, value)\ntest if one rectangle in a dictionary intersects" + +#define DOC_RECTCOLLIDEDICTALL "Rect.collidedictall(dict): return [(key, value), ...]\ntest if all rectangles in a dictionary intersect" + +#define DOC_PYGAMESCRAP "pygame module for clipboard support." + +#define DOC_PYGAMESCRAPINIT "scrap.init () -> None\nInitializes the scrap module." + +#define DOC_PYGAMESCRAPGET "scrap.get (type) -> string\nGets the data for the specified type from the clipboard." + +#define DOC_PYGAMESCRAPGETTYPES "scrap.get_types () -> list\nGets a list of the available clipboard types." + +#define DOC_PYGAMESCRAPPUT "scrap.put(type, data) -> None\nPlaces data into the clipboard." + +#define DOC_PYGAMESCRAPCONTAINS "scrap.contains (type) -> bool\nChecks, whether a certain type is available in the clipboard." + +#define DOC_PYGAMESCRAPLOST "scrap.lost() -> bool\nChecks whether the clipboard is currently owned by the application." + +#define DOC_PYGAMESCRAPSETMODE "scrap.set_mode(mode) -> None\nSets the clipboard access mode." + +#define DOC_PYGAMESNDARRAY "pygame module for accessing sound sample data" + +#define DOC_PYGAMESNDARRAYARRAY "pygame.sndarray.array(Sound): return array\ncopy Sound samples into an array" + +#define DOC_PYGAMESNDARRAYSAMPLES "pygame.sndarray.samples(Sound): return array\nreference Sound samples into an array" + +#define DOC_PYGAMESNDARRAYMAKESOUND "pygame.sndarray.make_sound(array): return Sound\nconvert an array into a Sound object" + +#define DOC_PYGAMESNDARRAYUSEARRAYTYPE "pygame.sndarray.use_arraytype (arraytype): return None\nSets the array system to be used for sound arrays" + +#define DOC_PYGAMESNDARRAYGETARRAYTYPE "pygame.sndarray.get_arraytype (): return str\nGets the currently active array type." + +#define DOC_PYGAMESNDARRAYGETARRAYTYPES "pygame.sndarray.get_arraytypes (): return tuple\nGets the array system types currently supported." + +#define DOC_PYGAMESPRITE "pygame module with basic game object classes" + +#define DOC_PYGAMESPRITESPRITE "pygame.sprite.Sprite(*groups): return Sprite\nsimple base class for visible game objects" + +#define DOC_SPRITEUPDATE "Sprite.update(*args):\nmethod to control sprite behavior" + +#define DOC_SPRITEADD "Sprite.add(*groups): return None\nadd the sprite to groups" + +#define DOC_SPRITEREMOVE "Sprite.remove(*groups): return None\nremove the sprite from groups" + +#define DOC_SPRITEKILL "Sprite.kill(): return None\nremove the Sprite from all Groups" + +#define DOC_SPRITEALIVE "Sprite.alive(): return bool\ndoes the sprite belong to any groups" + +#define DOC_SPRITEGROUPS "Sprite.groups(): return group_list\nlist of Groups that contain this Sprite" + +#define DOC_PYGAMESPRITEDIRTYSPRITE "pygame.sprite.DirtySprite(*groups): return DirtySprite\na more featureful subclass of Sprite with more attributes" + +#define DOC_ "" + +#define DOC_PYGAMESPRITEGROUP "pygame.sprite.Group(*sprites): return Group\ncontainer class for many Sprites" + +#define DOC_GROUPSPRITES "Group.sprites(): return sprite_list\nlist of the Sprites this Group contains" + +#define DOC_GROUPCOPY "Group.copy(): return Group\nduplicate the Group" + +#define DOC_GROUPADD "Group.add(*sprites): return None\nadd Sprites to this Group" + +#define DOC_GROUPREMOVE "Group.remove(*sprites): return None\nremove Sprites from the Group" + +#define DOC_GROUPHAS "Group.has(*sprites): return None\ntest if a Group contains Sprites" + +#define DOC_GROUPUPDATE "Group.update(*args): return None\ncall the update method on contained Sprites" + +#define DOC_GROUPDRAW "Group.draw(Surface): return None\nblit the Sprite images" + +#define DOC_GROUPCLEAR "Group.clear(Surface_dest, background): return None\ndraw a background over the Sprites" + +#define DOC_GROUPEMPTY "Group.empty(): return None\nremove all Sprites" + +#define DOC_PYGAMESPRITERENDERUPDATES "pygame.sprite.RenderUpdates(*sprites): return RenderUpdates\nGroup class that tracks dirty updates" + +#define DOC_RENDERUPDATESDRAW "RenderUpdates.draw(surface): return Rect_list\nblit the Sprite images and track changed areas" + +#define DOC_PYGAMESPRITEORDEREDUPDATES "pygame.sprite.OrderedUpdates(*spites): return OrderedUpdates\nRenderUpdates class that draws Sprites in order of addition" + +#define DOC_PYGAMESPRITELAYEREDUPDATES "pygame.sprite.LayeredUpdates(*spites, **kwargs): return LayeredUpdates\nLayeredUpdates Group handles layers, that draws like OrderedUpdates." + +#define DOC_LAYEREDUPDATESADD "LayeredUpdates.add(*sprites, **kwargs): return None\nadd a sprite or sequence of sprites to a group" + +#define DOC_LAYEREDUPDATESSPRITES "LayeredUpdates.sprites(): return sprites\nreturns a ordered list of sprites (first back, last top)." + +#define DOC_LAYEREDUPDATESDRAW "LayeredUpdates.draw(surface): return Rect_list\ndraw all sprites in the right order onto the passed surface." + +#define DOC_LAYEREDUPDATESGETSPRITESAT "LayeredUpdates.get_sprites_at(pos): return colliding_sprites\nreturns a list with all sprites at that position." + +#define DOC_LAYEREDUPDATESGETSPRITE "LayeredUpdates.get_sprite(idx): return sprite\nreturns the sprite at the index idx from the groups sprites" + +#define DOC_LAYEREDUPDATESREMOVESPRITESOFLAYER "LayeredUpdates.remove_sprites_of_layer(layer_nr): return sprites\nremoves all sprites from a layer and returns them as a list." + +#define DOC_LAYEREDUPDATESLAYERS "LayeredUpdates.layers(): return layers\nreturns a list of layers defined (unique), sorted from botton up." + +#define DOC_LAYEREDUPDATESCHANGELAYER "LayeredUpdates.change_layer(sprite, new_layer): return None\nchanges the layer of the sprite" + +#define DOC_LAYEREDUPDATESGETLAYEROFSPRITE "LayeredUpdates.get_layer_of_sprite(sprite): return layer\nreturns the layer that sprite is currently in." + +#define DOC_LAYEREDUPDATESGETTOPLAYER "LayeredUpdates.get_top_layer(): return layer\nreturns the top layer" + +#define DOC_LAYEREDUPDATESGETBOTTOMLAYER "LayeredUpdates.get_bottom_layer(): return layer\nreturns the bottom layer" + +#define DOC_LAYEREDUPDATESMOVETOFRONT "LayeredUpdates.move_to_front(sprite): return None\nbrings the sprite to front layer" + +#define DOC_LAYEREDUPDATESMOVETOBACK "LayeredUpdates.move_to_back(sprite): return None\nmoves the sprite to the bottom layer" + +#define DOC_LAYEREDUPDATESGETTOPSPRITE "LayeredUpdates.get_top_sprite(): return Sprite\nreturns the topmost sprite" + +#define DOC_LAYEREDUPDATESGETSPRITESFROMLAYER "LayeredUpdates.get_sprites_from_layer(layer): return sprites\nreturns all sprites from a layer, ordered by how they where added" + +#define DOC_LAYEREDUPDATESSWITCHLAYER "LayeredUpdates.switch_layer(layer1_nr, layer2_nr): return None\nswitches the sprites from layer1 to layer2" + +#define DOC_PYGAMESPRITELAYEREDDIRTY "pygame.sprite.LayeredDirty(*spites, **kwargs): return LayeredDirty\nLayeredDirty Group is for DirtySprites. Subclasses LayeredUpdates." + +#define DOC_LAYEREDDIRTYDRAW "LayeredDirty.draw(surface, bgd=None): return Rect_list\ndraw all sprites in the right order onto the passed surface." + +#define DOC_LAYEREDDIRTYCLEAR "LayeredDirty.clear(surface, bgd): return None\nused to set background" + +#define DOC_LAYEREDDIRTYREPAINTRECT "LayeredDirty.repaint_rect(screen_rect): return None\nrepaints the given area" + +#define DOC_LAYEREDDIRTYSETCLIP "LayeredDirty.set_clip(screen_rect=None): return None\nclip the area where to draw. Just pass None (default) to reset the clip" + +#define DOC_LAYEREDDIRTYGETCLIP "LayeredDirty.get_clip(): return Rect\nclip the area where to draw. Just pass None (default) to reset the clip" + +#define DOC_LAYEREDDIRTYCHANGELAYER "change_layer(sprite, new_layer): return None\nchanges the layer of the sprite" + +#define DOC_LAYEREDDIRTYSETTIMINGTRESHOLD "set_timing_treshold(time_ms): return None\nsets the treshold in milliseconds" + +#define DOC_PYGAMESPRITEGROUPSINGLE "pygame.sprite.GroupSingle(sprite=None): return GroupSingle\nGroup container that holds a single Sprite" + +#define DOC_PYGAMESPRITESPRITECOLLIDE "pygame.sprite.spritecollide(sprite, group, dokill, collided = None): return Sprite_list\nfind Sprites in a Group that intersect another Sprite" + +#define DOC_PYGAMESPRITECOLLIDERECT "pygame.sprite.collide_rect(left, right): return bool\ncollision detection between two sprites, using rects." + +#define DOC_PYGAMESPRITECOLLIDERECTRATIO "pygame.sprite.collide_rect_ratio(ratio): return collided_callable\ncollision detection between two sprites, using rects scaled to a ratio." + +#define DOC_PYGAMESPRITECOLLIDECIRCLE "pygame.sprite.collide_circle(left, right): return bool\ncollision detection between two sprites, using circles." + +#define DOC_PYGAMESPRITECOLLIDECIRCLERATIO "pygame.sprite.collide_circle_ratio(ratio): return collided_callable\ncollision detection between two sprites, using circles scaled to a ratio." + +#define DOC_PYGAMESPRITECOLLIDEMASK "pygame.sprite.collide_mask(SpriteLeft, SpriteRight): return bool\ncollision detection between two sprites, using masks." + +#define DOC_PYGAMESPRITEGROUPCOLLIDE "pygame.sprite.groupcollide(group1, group2, dokill1, dokill2): return Sprite_dict\nfind all Sprites that collide between two Groups" + +#define DOC_PYGAMESPRITESPRITECOLLIDEANY "pygame.sprite.spritecollideany(sprite, group): return bool\nsimple test if a Sprite intersects anything in a Group" + +#define DOC_ "" + +#define DOC_PYGAMESURFACE "pygame.Surface((width, height), flags=0, depth=0, masks=None): return Surface\npygame.Surface((width, height), flags=0, Surface): return Surface\npygame object for representing images" + +#define DOC_SURFACEBLIT "Surface.blit(source, dest, area=None, special_flags = 0): return Rect\ndraw one image onto another" + +#define DOC_SURFACECONVERT "Surface.convert(Surface): return Surface\nSurface.convert(depth, flags=0): return Surface\nSurface.convert(masks, flags=0): return Surface\nSurface.convert(): return Surface\nchange the pixel format of an image" + +#define DOC_SURFACECONVERTALPHA "Surface.convert_alpha(Surface): return Surface\nSurface.convert_alpha(): return Surface\nchange the pixel format of an image including per pixel alphas" + +#define DOC_SURFACECOPY "Surface.copy(): return Surface\ncreate a new copy of a Surface" + +#define DOC_SURFACEFILL "Surface.fill(color, rect=None, special_flags=0): return Rect\nfill Surface with a solid color" + +#define DOC_SURFACESETCOLORKEY "Surface.set_colorkey(Color, flags=0): return None\nSurface.set_colorkey(None): return None\nSet the transparent colorkey" + +#define DOC_SURFACEGETCOLORKEY "Surface.get_colorkey(): return RGB or None\nGet the current transparent colorkey" + +#define DOC_SURFACESETALPHA "Surface.set_alpha(value, flags=0): return None\nSurface.set_alpha(None): return None\nset the alpha value for the full Surface image" + +#define DOC_SURFACEGETALPHA "Surface.get_alpha(): return int_value or None\nget the current Surface transparency value" + +#define DOC_SURFACELOCK "Surface.lock(): return None\nlock the Surface memory for pixel access" + +#define DOC_SURFACEUNLOCK "Surface.unlock(): return None\nunlock the Surface memory from pixel access" + +#define DOC_SURFACEMUSTLOCK "Surface.mustlock(): return bool\ntest if the Surface requires locking" + +#define DOC_SURFACEGETLOCKED "Surface.get_locked(): return bool\ntest if the Surface is current locked" + +#define DOC_SURFACEGETLOCKS "Surface.get_locks(): return tuple\nGets the locks for the Surface" + +#define DOC_SURFACEGETAT "Surface.get_at((x, y)): return Color\nget the color value at a single pixel" + +#define DOC_SURFACESETAT "Surface.set_at((x, y), Color): return None\nset the color value for a single pixel" + +#define DOC_SURFACEGETPALETTE "Surface.get_palette(): return [RGB, RGB, RGB, ...]\nget the color index palette for an 8bit Surface" + +#define DOC_SURFACEGETPALETTEAT "Surface.get_palette_at(index): return RGB\nget the color for a single entry in a palette" + +#define DOC_SURFACESETPALETTE "Surface.set_palette([RGB, RGB, RGB, ...]): return None\nset the color palette for an 8bit Surface" + +#define DOC_SURFACESETPALETTEAT "Surface.set_at(index, RGB): return None\nset the color for a single index in an 8bit Surface palette" + +#define DOC_SURFACEMAPRGB "Surface.map_rgb(Color): return mapped_int\nconvert a color into a mapped color value" + +#define DOC_SURFACEUNMAPRGB "Surface.map_rgb(mapped_int): return Color\nconvert a mapped integer color value into a Color" + +#define DOC_SURFACESETCLIP "Surface.set_clip(rect): return None\nSurface.set_clip(None): return None\nset the current clipping area of the Surface" + +#define DOC_SURFACEGETCLIP "Surface.get_clip(): return Rect\nget the current clipping area of the Surface" + +#define DOC_SURFACESUBSURFACE "Surface.subsurface(Rect): return Surface\ncreate a new surface that references its parent" + +#define DOC_SURFACEGETPARENT "Surface.get_parent(): return Surface\nfind the parent of a subsurface" + +#define DOC_SURFACEGETABSPARENT "Surface.get_abs_parent(): return Surface\nfind the top level parent of a subsurface" + +#define DOC_SURFACEGETOFFSET "Surface.get_offset(): return (x, y)\nfind the position of a child subsurface inside a parent" + +#define DOC_SURFACEGETABSOFFSET "Surface.get_abs_offset(): return (x, y)\nfind the absolute position of a child subsurface inside its top level parent" + +#define DOC_SURFACEGETSIZE "Surface.get_size(): return (width, height)\nget the dimensions of the Surface" + +#define DOC_SURFACEGETWIDTH "Surface.get_width(): return width\nget the width of the Surface" + +#define DOC_SURFACEGETHEIGHT "Surface.get_height(): return height\nget the height of the Surface" + +#define DOC_SURFACEGETRECT "Surface.get_rect(**kwargs): return Rect\nget the rectangular area of the Surface" + +#define DOC_SURFACEGETBITSIZE "Surface.get_bitsize(): return int\nget the bit depth of the Surface pixel format" + +#define DOC_SURFACEGETBYTESIZE "Surface.get_bytesize(): return int\nget the bytes used per Surface pixel" + +#define DOC_SURFACEGETFLAGS "Surface.get_flags(): return int\nget the additional flags used for the Surface" + +#define DOC_SURFACEGETPITCH "Surface.get_pitch(): return int\nget the number of bytes used per Surface row" + +#define DOC_SURFACEGETMASKS "Surface.get_masks(): return (R, G, B, A)\nthe bitmasks needed to convert between a color and a mapped integer" + +#define DOC_SURFACESETMASKS "Surface.set_masks((r,g,b,a)): return None\nset the bitmasks needed to convert between a color and a mapped integer" + +#define DOC_SURFACEGETSHIFTS "Surface.get_shifts(): return (R, G, B, A)\nthe bit shifts needed to convert between a color and a mapped integer" + +#define DOC_SURFACESETSHIFTS "Surface.get_shifts((r,g,b,a)): return None\nsets the bit shifts needed to convert between a color and a mapped integer" + +#define DOC_SURFACEGETLOSSES "Surface.get_losses(): return (R, G, B, A)\nthe significant bits used to convert between a color and a mapped integer" + +#define DOC_SURFACEGETBOUNDINGRECT "Surface.get_bounding_rect(min_alpha = 1): return Rect\nfind the smallest rect containing data" + +#define DOC_SURFACEGETBUFFER "Surface.get_buffer(): return BufferProxy\nacquires a buffer object for the pixels of the Surface." + +#define DOC_PYGAMESURFARRAY "pygame module for accessing surface pixel data using array interfaces" + +#define DOC_PYGAMESURFARRAYARRAY2D "pygame.surfarray.array2d(Surface): return array\nCopy pixels into a 2d array" + +#define DOC_PYGAMESURFARRAYPIXELS2D "pygame.surfarray.pixels2d(Surface): return array\nReference pixels into a 2d array" + +#define DOC_PYGAMESURFARRAYARRAY3D "pygame.surfarray.array3d(Surface): return array\nCopy pixels into a 3d array" + +#define DOC_PYGAMESURFARRAYPIXELS3D "pygame.surfarray.pixels3d(Surface): return array\nReference pixels into a 3d array" + +#define DOC_PYGAMESURFARRAYARRAYALPHA "pygame.surfarray.array_alpha(Surface): return array\nCopy pixel alphas into a 2d array" + +#define DOC_PYGAMESURFARRAYPIXELSALPHA "pygame.surfarray.pixels_alpha(Surface): return array\nReference pixel alphas into a 2d array" + +#define DOC_PYGAMESURFARRAYARRAYCOLORKEY "pygame.surfarray.array_colorkey(Surface): return array\nCopy the colorkey values into a 2d array" + +#define DOC_PYGAMESURFARRAYMAKESURFACE "pygame.surfarray.make_surface(array): return Surface\nCopy an array to a new surface" + +#define DOC_PYGAMESURFARRAYBLITARRAY "pygame.surfarray.blit_array(Surface, array): return None\nBlit directly from a array values" + +#define DOC_PYGAMESURFARRAYMAPARRAY "pygame.surfarray.map_array(Surface, array3d): return array2d\nMap a 3d array into a 2d array" + +#define DOC_PYGAMESURFARRAYUSEARRAYTYPE "pygame.surfarray.use_arraytype (arraytype): return None\nSets the array system to be used for surface arrays" + +#define DOC_PYGAMESURFARRAYGETARRAYTYPE "pygame.surfarray.get_arraytype (): return str\nGets the currently active array type." + +#define DOC_PYGAMESURFARRAYGETARRAYTYPES "pygame.surfarray.get_arraytypes (): return tuple\nGets the array system types currently supported." + +#define DOC_PYGAMETIME "pygame module for monitoring time" + +#define DOC_PYGAMETIMEGETTICKS "pygame.time.get_ticks(): return milliseconds\nget the time in milliseconds" + +#define DOC_PYGAMETIMEWAIT "pygame.time.wait(milliseconds): return time\npause the program for an amount of time" + +#define DOC_PYGAMETIMEDELAY "pygame.time.delay(milliseconds): return time\npause the program for an amount of time" + +#define DOC_PYGAMETIMESETTIMER "pygame.time.set_timer(eventid, milliseconds): return None\nrepeatedly create an event on the event queue" + +#define DOC_PYGAMETIMECLOCK "pygame.time.Clock(): return Clock\ncreate an object to help track time" + +#define DOC_CLOCKTICK "Clock.tick(framerate=0): return milliseconds\ncontrol timer events\nupdate the clock" + +#define DOC_CLOCKTICKBUSYLOOP "Clock.tick_busy_loop(framerate=0): return milliseconds\ncontrol timer events\nupdate the clock" + +#define DOC_CLOCKGETTIME "Clock.get_time(): return milliseconds\ntime used in the previous tick" + +#define DOC_CLOCKGETRAWTIME "Clock.get_rawtime(): return milliseconds\nactual time used in the previous tick" + +#define DOC_CLOCKGETFPS "Clock.get_fps(): return float\ncompute the clock framerate" + +#define DOC_PYGAMETRANSFORM "pygame module to transform surfaces" + +#define DOC_PYGAMETRANSFORMFLIP "pygame.transform.flip(Surface, xbool, ybool): return Surface\nflip vertically and horizontally" + +#define DOC_PYGAMETRANSFORMSCALE "pygame.transform.scale(Surface, (width, height), DestSurface = None): return Surface\nresize to new resolution" + +#define DOC_PYGAMETRANSFORMROTATE "pygame.transform.rotate(Surface, angle): return Surface\nrotate an image" + +#define DOC_PYGAMETRANSFORMROTOZOOM "pygame.transform.rotozoom(Surface, angle, scale): return Surface\nfiltered scale and rotation" + +#define DOC_PYGAMETRANSFORMSCALE2X "pygame.transform.scale2x(Surface, DestSurface = None): Surface\nspecialized image doubler" + +#define DOC_PYGAMETRANSFORMSMOOTHSCALE "pygame.transform.smoothscale(Surface, (width, height), DestSurface = None): return Surface\nscale a surface to an arbitrary size smoothly" + +#define DOC_PYGAMETRANSFORMGETSMOOTHSCALEBACKEND "pygame.transform.get_smoothscale_backend(): return String\nreturn smoothscale filter version in use: 'GENERIC', 'MMX', or 'SSE'" + +#define DOC_PYGAMETRANSFORMSETSMOOTHSCALEBACKEND "pygame.transform.get_smoothscale_backend(type): return None\nset smoothscale filter version to one of: 'GENERIC', 'MMX', or 'SSE'" + +#define DOC_PYGAMETRANSFORMCHOP "pygame.transform.chop(Surface, rect): return Surface\ngets a copy of an image with an interior area removed" + +#define DOC_PYGAMETRANSFORMLAPLACIAN "pygame.transform.laplacian(Surface, DestSurface = None): return Surface\nfind edges in a surface" + +#define DOC_PYGAMETRANSFORMAVERAGESURFACES "pygame.transform.average_surfaces(Surfaces, DestSurface = None): return Surface\nfind the average surface from many surfaces." + +#define DOC_PYGAMETRANSFORMAVERAGECOLOR "pygame.transform.average_color(Surface, Rect = None): return Color\nfinds the average color of a surface" + +#define DOC_PYGAMETRANSFORMTHRESHOLD "pygame.transform.threshold(DestSurface, Surface, color, threshold = (0,0,0,0), diff_color = (0,0,0,0), change_return = 1, Surface = None, inverse = False): return num_threshold_pixels\nfinds which, and how many pixels in a surface are within a threshold of a color." + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-04 14:36:35
|
Revision: 122 http://pen.svn.sourceforge.net/pen/?rev=122&view=rev Author: mdgeorge Date: 2008-12-04 14:36:32 +0000 (Thu, 04 Dec 2008) Log Message: ----------- removed ignores for all the autotools crud. Property Changed: ---------------- / Property changes on: ___________________________________________________________________ Modified: svn:ignore - configure Makefile.in config.log config.status libtool autom4te.cache Makefile aclocal.m4 build + build This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-04 04:21:53
|
Revision: 121 http://pen.svn.sourceforge.net/pen/?rev=121&view=rev Author: mdgeorge Date: 2008-12-04 04:21:51 +0000 (Thu, 04 Dec 2008) Log Message: ----------- Banished autotools. At some point maybe I'll reintroduce them. Removed Paths: ------------- COPYING INSTALL Makefile.am autogen.sh config/ configure.ac data/Makefile.am src/Makefile.am src/demos/Makefile.am Property Changed: ---------------- data/ src/ src/demos/ Deleted: COPYING =================================================================== --- COPYING 2008-12-04 04:16:18 UTC (rev 120) +++ COPYING 2008-12-04 04:21:51 UTC (rev 121) @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - <one line to give the program's name and a brief idea of what it does.> - Copyright (C) <year> <name of author> - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - <signature of Ty Coon>, 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. Deleted: INSTALL =================================================================== --- INSTALL 2008-12-04 04:16:18 UTC (rev 120) +++ INSTALL 2008-12-04 04:21:51 UTC (rev 121) @@ -1,236 +0,0 @@ -Installation Instructions -************************* - -Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free -Software Foundation, Inc. - -This file is free documentation; the Free Software Foundation gives -unlimited permission to copy, distribute and modify it. - -Basic Installation -================== - -These are generic installation instructions. - - The `configure' shell script attempts to guess correct values for -various system-dependent variables used during compilation. It uses -those values to create a `Makefile' in each directory of the package. -It may also create one or more `.h' files containing system-dependent -definitions. Finally, it creates a shell script `config.status' that -you can run in the future to recreate the current configuration, and a -file `config.log' containing compiler output (useful mainly for -debugging `configure'). - - It can also use an optional file (typically called `config.cache' -and enabled with `--cache-file=config.cache' or simply `-C') that saves -the results of its tests to speed up reconfiguring. (Caching is -disabled by default to prevent problems with accidental use of stale -cache files.) - - If you need to do unusual things to compile the package, please try -to figure out how `configure' could check whether to do them, and mail -diffs or instructions to the address given in the `README' so they can -be considered for the next release. If you are using the cache, and at -some point `config.cache' contains results you don't want to keep, you -may remove or edit it. - - The file `configure.ac' (or `configure.in') is used to create -`configure' by a program called `autoconf'. You only need -`configure.ac' if you want to change it or regenerate `configure' using -a newer version of `autoconf'. - -The simplest way to compile this package is: - - 1. `cd' to the directory containing the package's source code and type - `./configure' to configure the package for your system. If you're - using `csh' on an old version of System V, you might need to type - `sh ./configure' instead to prevent `csh' from trying to execute - `configure' itself. - - Running `configure' takes awhile. While running, it prints some - messages telling which features it is checking for. - - 2. Type `make' to compile the package. - - 3. Optionally, type `make check' to run any self-tests that come with - the package. - - 4. Type `make install' to install the programs and any data files and - documentation. - - 5. You can remove the program binaries and object files from the - source code directory by typing `make clean'. To also remove the - files that `configure' created (so you can compile the package for - a different kind of computer), type `make distclean'. There is - also a `make maintainer-clean' target, but that is intended mainly - for the package's developers. If you use it, you may have to get - all sorts of other programs in order to regenerate files that came - with the distribution. - -Compilers and Options -===================== - -Some systems require unusual options for compilation or linking that the -`configure' script does not know about. Run `./configure --help' for -details on some of the pertinent environment variables. - - You can give `configure' initial values for configuration parameters -by setting variables in the command line or in the environment. Here -is an example: - - ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix - - *Note Defining Variables::, for more details. - -Compiling For Multiple Architectures -==================================== - -You can compile the package for more than one kind of computer at the -same time, by placing the object files for each architecture in their -own directory. To do this, you must use a version of `make' that -supports the `VPATH' variable, such as GNU `make'. `cd' to the -directory where you want the object files and executables to go and run -the `configure' script. `configure' automatically checks for the -source code in the directory that `configure' is in and in `..'. - - If you have to use a `make' that does not support the `VPATH' -variable, you have to compile the package for one architecture at a -time in the source code directory. After you have installed the -package for one architecture, use `make distclean' before reconfiguring -for another architecture. - -Installation Names -================== - -By default, `make install' installs the package's commands under -`/usr/local/bin', include files under `/usr/local/include', etc. You -can specify an installation prefix other than `/usr/local' by giving -`configure' the option `--prefix=PREFIX'. - - You can specify separate installation prefixes for -architecture-specific files and architecture-independent files. If you -pass the option `--exec-prefix=PREFIX' to `configure', the package uses -PREFIX as the prefix for installing programs and libraries. -Documentation and other data files still use the regular prefix. - - In addition, if you use an unusual directory layout you can give -options like `--bindir=DIR' to specify different values for particular -kinds of files. Run `configure --help' for a list of the directories -you can set and what kinds of files go in them. - - If the package supports it, you can cause programs to be installed -with an extra prefix or suffix on their names by giving `configure' the -option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. - -Optional Features -================= - -Some packages pay attention to `--enable-FEATURE' options to -`configure', where FEATURE indicates an optional part of the package. -They may also pay attention to `--with-PACKAGE' options, where PACKAGE -is something like `gnu-as' or `x' (for the X Window System). The -`README' should mention any `--enable-' and `--with-' options that the -package recognizes. - - For packages that use the X Window System, `configure' can usually -find the X include and library files automatically, but if it doesn't, -you can use the `configure' options `--x-includes=DIR' and -`--x-libraries=DIR' to specify their locations. - -Specifying the System Type -========================== - -There may be some features `configure' cannot figure out automatically, -but needs to determine by the type of machine the package will run on. -Usually, assuming the package is built to be run on the _same_ -architectures, `configure' can figure that out, but if it prints a -message saying it cannot guess the machine type, give it the -`--build=TYPE' option. TYPE can either be a short name for the system -type, such as `sun4', or a canonical name which has the form: - - CPU-COMPANY-SYSTEM - -where SYSTEM can have one of these forms: - - OS KERNEL-OS - - See the file `config.sub' for the possible values of each field. If -`config.sub' isn't included in this package, then this package doesn't -need to know the machine type. - - If you are _building_ compiler tools for cross-compiling, you should -use the option `--target=TYPE' to select the type of system they will -produce code for. - - If you want to _use_ a cross compiler, that generates code for a -platform different from the build platform, you should specify the -"host" platform (i.e., that on which the generated programs will -eventually be run) with `--host=TYPE'. - -Sharing Defaults -================ - -If you want to set default values for `configure' scripts to share, you -can create a site shell script called `config.site' that gives default -values for variables like `CC', `cache_file', and `prefix'. -`configure' looks for `PREFIX/share/config.site' if it exists, then -`PREFIX/etc/config.site' if it exists. Or, you can set the -`CONFIG_SITE' environment variable to the location of the site script. -A warning: not all `configure' scripts look for a site script. - -Defining Variables -================== - -Variables not defined in a site shell script can be set in the -environment passed to `configure'. However, some packages may run -configure again during the build, and the customized values of these -variables may be lost. In order to avoid this problem, you should set -them in the `configure' command line, using `VAR=value'. For example: - - ./configure CC=/usr/local2/bin/gcc - -causes the specified `gcc' to be used as the C compiler (unless it is -overridden in the site shell script). Here is a another example: - - /bin/bash ./configure CONFIG_SHELL=/bin/bash - -Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent -configuration-related scripts to be executed by `/bin/bash'. - -`configure' Invocation -====================== - -`configure' recognizes the following options to control how it operates. - -`--help' -`-h' - Print a summary of the options to `configure', and exit. - -`--version' -`-V' - Print the version of Autoconf used to generate the `configure' - script, and exit. - -`--cache-file=FILE' - Enable the cache: use and save the results of the tests in FILE, - traditionally `config.cache'. FILE defaults to `/dev/null' to - disable caching. - -`--config-cache' -`-C' - Alias for `--cache-file=config.cache'. - -`--quiet' -`--silent' -`-q' - Do not print messages saying which checks are being made. To - suppress all normal output, redirect it to `/dev/null' (any error - messages will still be shown). - -`--srcdir=DIR' - Look for the package's source code in directory DIR. Usually - `configure' can determine that directory automatically. - -`configure' also accepts some other, not widely useful, options. Run -`configure --help' for more details. - Deleted: Makefile.am =================================================================== --- Makefile.am 2008-12-04 04:16:18 UTC (rev 120) +++ Makefile.am 2008-12-04 04:21:51 UTC (rev 121) @@ -1,4 +0,0 @@ - -SUBDIRS = data src - - Deleted: autogen.sh =================================================================== --- autogen.sh 2008-12-04 04:16:18 UTC (rev 120) +++ autogen.sh 2008-12-04 04:21:51 UTC (rev 121) @@ -1,9 +0,0 @@ -#!/bin/sh - -aclocal -I config/m4 && -autoconf && -libtoolize && -automake && -./configure && -make - Deleted: configure.ac =================================================================== --- configure.ac 2008-12-04 04:16:18 UTC (rev 120) +++ configure.ac 2008-12-04 04:21:51 UTC (rev 121) @@ -1,31 +0,0 @@ - -dnl Process this file with autoconf to produce a configure script - -AC_INIT([pen], [0.0], [mdg...@cs...]) -AC_CONFIG_SRCDIR([src/pen.py]) -AC_CONFIG_AUX_DIR([config]) -AM_INIT_AUTOMAKE - -# -# find Tools -# -AC_PROG_LIBTOOL() -AC_MSG_CHECKING([for bovinity]) -AC_MSG_RESULT([moo]) -AC_PROG_CC() -AM_PATH_PYTHON([2.4]) - -AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)]) - -# -# output configuration files -# -AC_CONFIG_FILES([ - Makefile - src/Makefile - src/demos/Makefile - data/Makefile -]) - -AC_OUTPUT - Property changes on: data ___________________________________________________________________ Deleted: svn:ignore - Makefile Makefile.in Deleted: data/Makefile.am =================================================================== --- data/Makefile.am 2008-12-04 04:16:18 UTC (rev 120) +++ data/Makefile.am 2008-12-04 04:21:51 UTC (rev 121) @@ -1,18 +0,0 @@ - -nobase_pkgdata_DATA = \ - levels/level1.lev \ - images/cannon-icon.png \ - images/anvil.png \ - images/soccerball.png \ - images/paper.png \ - images/antigrav.png \ - images/tennisball.png \ - images/cannon-base.png \ - images/cannon-barrel.png \ - parts/cannon.py \ - parts/balls.py \ - fonts/digiface.ttf \ - fonts/handmeds.ttf \ - fonts/Bminus.TTF \ - fonts/handmedo.ttf - Property changes on: src ___________________________________________________________________ Modified: svn:ignore - Makefile Makefile.in *.pyc .libs .deps + *.pyc Deleted: src/Makefile.am =================================================================== --- src/Makefile.am 2008-12-04 04:16:18 UTC (rev 120) +++ src/Makefile.am 2008-12-04 04:21:51 UTC (rev 121) @@ -1,23 +0,0 @@ - -SUBDIRS = demos -INCLUDES = ${PYTHON_INCLUDES} -I${top_srcdir}/include - -pkgpyexec_LTLIBRARIES = maskutils.la -maskutils_la_SOURCES = maskutils.c -maskutils_la_LDFLAGS = -avoid-version -module - -pkgpython_PYTHON = \ - drag.py \ - editor.py \ - files.py \ - globals.py \ - level.py \ - menu.py \ - parts.py \ - pen.py \ - physics.py \ - vector.py - -clean-local: - rm -f *.pyc - Property changes on: src/demos ___________________________________________________________________ Modified: svn:ignore - *.pyc Makefile Makefile.in + *.pyc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-04 04:16:20
|
Revision: 120 http://pen.svn.sourceforge.net/pen/?rev=120&view=rev Author: mdgeorge Date: 2008-12-04 04:16:18 +0000 (Thu, 04 Dec 2008) Log Message: ----------- Modified drag to use maskutils instead of patched pygame. It works. Modified Paths: -------------- src/drag.py Modified: src/drag.py =================================================================== --- src/drag.py 2008-12-04 04:13:55 UTC (rev 119) +++ src/drag.py 2008-12-04 04:16:18 UTC (rev 120) @@ -1,6 +1,7 @@ -from pygame import Rect -from pygame.mask import Mask +from pygame import Rect +from pygame.mask import Mask from pygame.sprite import Group, spritecollide, collide_mask +from maskutils import convolve, find_closest class DragManager(Group): def __init__(self, *sprites): @@ -40,7 +41,7 @@ shrect = None for s in self: if s is not sprite: - s.__shadow = s.mask.convolve(sprite.mask) + s.__shadow = convolve(s.mask, sprite.mask) s.__shrect = Rect((s.rect.left - sprect.right + 1, s.rect.top - sprect.bottom + 1), s.__shadow.get_size()) @@ -74,7 +75,7 @@ return pt pos = pt[0] - self._shrect.left, pt[1] - self._shrect.top - pos = self._shadow.find_closest(pos) + pos = find_closest(self._shadow, pos) pt = pos[0] + self._shrect.left, pos[1] + self._shrect.top self._selected.rect = self._sprect.move(pt) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-04 04:13:59
|
Revision: 119 http://pen.svn.sourceforge.net/pen/?rev=119&view=rev Author: mdgeorge Date: 2008-12-04 04:13:55 +0000 (Thu, 04 Dec 2008) Log Message: ----------- It seems to run! Modified Paths: -------------- pygame/src/mask.c pygame/src/mask.h src/maskutils.c Modified: pygame/src/mask.c =================================================================== --- pygame/src/mask.c 2008-12-04 01:24:33 UTC (rev 118) +++ pygame/src/mask.c 2008-12-04 04:13:55 UTC (rev 119) @@ -1383,13 +1383,24 @@ void initmask(void) { - PyObject *module, *dict; + PyObject *module, *dict, *apiobj; + static void* c_api[PYGAMEAPI_MASK_NUMSLOTS]; + + /* create the mask type */ PyType_Init(PyMask_Type); /* create the module */ module = Py_InitModule3("mask", mask_builtins, DOC_PYGAMEMASK); dict = PyModule_GetDict(module); PyDict_SetItemString(dict, "MaskType", (PyObject *)&PyMask_Type); + + /* export the c api */ + Py_INCREF((PyObject*) &PyMask_Type); + c_api[0] = &PyMask_Type; + apiobj = PyCObject_FromVoidPtr (c_api, NULL); + PyModule_AddObject (module, PYGAMEAPI_LOCAL_ENTRY, apiobj); + + /* import other modules */ import_pygame_base (); import_pygame_color (); import_pygame_surface (); Modified: pygame/src/mask.h =================================================================== --- pygame/src/mask.h 2008-12-04 01:24:33 UTC (rev 118) +++ pygame/src/mask.h 2008-12-04 04:13:55 UTC (rev 119) @@ -1,7 +1,7 @@ #include <Python.h> #include "bitmask.h" -#define PYGAMEAPI_MASK_NUMSLOTS +#define PYGAMEAPI_MASK_NUMSLOTS 1 #define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API" typedef struct { @@ -23,7 +23,7 @@ PyObject *c_api = PyDict_GetItemString(dict, PYGAMEAPI_LOCAL_ENTRY); \ if(PyCObject_Check(c_api)) { \ void** localptr = (void**) PyCObject_AsVoidPtr(c_api); \ - memcpy(PyMASK_C_API, localptr, sizeof(void*)*PYGAMEAPI_FONT_NUMSLOTS); \ + memcpy(PyMASK_C_API, localptr, sizeof(void*)*PYGAMEAPI_MASK_NUMSLOTS); \ } Py_DECREF(module); \ } \ } Modified: src/maskutils.c =================================================================== --- src/maskutils.c 2008-12-04 01:24:33 UTC (rev 118) +++ src/maskutils.c 2008-12-04 04:13:55 UTC (rev 119) @@ -6,10 +6,10 @@ */ static const char DOC_CONVOLVE[] = -"Return the convolution of self with another mask. \n" +"Return the convolution of two masks. \n" " \n" "convolve(a, b, outputmask = None, offset = (0,0)): return Mask \n" -" Returns a mask with the (i-offset[0],j-offset[1]) bit set if shifting a \n" +" Returns a mask with the (i-offset[0],j-offset[1]) bit set if shifting b \n" " so that it's lower right corner pixel is at (i,j) would cause it to overlap \n" " with a. \n" " \n" @@ -37,6 +37,7 @@ void initmaskutils(void) { + import_pygame_mask(); Py_InitModule ("maskutils", maskutils_methods); } @@ -148,7 +149,7 @@ if (!PyArg_ParseTuple (args, "O!(ii)", &PyMask_Type, &mobj, &x, &y)) return NULL; - mask = PyMask_AsBitmap (self); + mask = PyMask_AsBitmap (mobj); bitmask_find_closest (mask, &x, &y); return Py_BuildValue ("(ii)", x, y); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-04 01:24:38
|
Revision: 118 http://pen.svn.sourceforge.net/pen/?rev=118&view=rev Author: mdgeorge Date: 2008-12-04 01:24:33 +0000 (Thu, 04 Dec 2008) Log Message: ----------- Added a setup.py file. It works, although maskutils still doesn't work yet because I'm not done modifying mask.c in pygame. You can import it though! Added Paths: ----------- setup.py Property Changed: ---------------- / Property changes on: ___________________________________________________________________ Modified: svn:ignore - configure Makefile.in config.log config.status libtool autom4te.cache Makefile aclocal.m4 + configure Makefile.in config.log config.status libtool autom4te.cache Makefile aclocal.m4 build Added: setup.py =================================================================== --- setup.py (rev 0) +++ setup.py 2008-12-04 01:24:33 UTC (rev 118) @@ -0,0 +1,15 @@ +from distutils.core import setup, Extension + +maskutils_name = 'maskutils' +maskutils_sources = ['src/maskutils.c', 'pygame/src/bitmask.c'] +maskutils_includes = ['pygame/src'] +maskutils = Extension(name = maskutils_name, + sources = maskutils_sources, + include_dirs = maskutils_includes) + +setup(name = 'pen', + version = '0.0', + author = 'Michael George', + author_email = 'mdg...@cs...', + ext_modules = [maskutils]) + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-03 23:44:28
|
Revision: 117 http://pen.svn.sourceforge.net/pen/?rev=117&view=rev Author: mdgeorge Date: 2008-12-03 23:44:26 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Added in bitmask_convolve and bitmask_find_closest from history. Modified Paths: -------------- src/maskutils.c Modified: src/maskutils.c =================================================================== --- src/maskutils.c 2008-12-03 23:43:41 UTC (rev 116) +++ src/maskutils.c 2008-12-03 23:44:26 UTC (rev 117) @@ -1,6 +1,10 @@ #include <Python.h> #include <mask.h> +/* +** Declarations and python magic *********************************************** +*/ + static const char DOC_CONVOLVE[] = "Return the convolution of self with another mask. \n" " \n" @@ -31,16 +35,80 @@ }; void -initmaskutils() +initmaskutils(void) { - PyInitModule ("maskutils", maskutils_methods); + Py_InitModule ("maskutils", maskutils_methods); } /* -** Implementations ************************************************************* +** Python method implementations *********************************************** */ static +void +bitmask_convolve(const bitmask_t *a, const bitmask_t *b, bitmask_t *o, int xoffset, int yoffset) +{ + int x, y; + + xoffset += b->w - 1; + yoffset += b->h - 1; + for (y = 0; y < b->h; y++) + for (x = 0; x < b->w; x++) + if (bitmask_getbit(b, x, y)) + bitmask_draw(o, a, xoffset - x, yoffset - y); +} + +static inline +int +valid(const bitmask_t *mask, int x, int y) +{ + return x < 0 || y < 0 || + x >= mask->w || y >= mask->h || + !bitmask_getbit(mask,x,y); +} + +static +void +bitmask_find_closest(const bitmask_t *mask, int *x, int *y) +{ +#define SQ(x) (x)*(x) + + /* this method is either very elegant or very ugly. */ + int best_d = SQ(*x + 1), best_x = -1, best_y = *y; + int covered; + +#define check_point(dist,x,y) \ + if(dist < best_d) { \ + best_d = dist; \ + best_x = x; \ + best_y = y; \ + } + + if (valid(mask, *x, *y)) + check_point(0, *x, *y); + + /* loop invariant: I've at least looked at everything of distance less than less than covered */ + for (covered = 1; SQ(covered) <= best_d; covered++) + { + int sx, sy, i; + +#define check_row(xi, yi) \ + sx = *x - (xi)*covered + (yi)*covered; \ + sy = *y - (yi)*covered - (xi)*covered; \ + for (i = 0; i < 2*covered; i++, sx += xi, sy += yi) \ + if (valid(mask, sx, sy)) \ + check_point(SQ(*x-sx) + SQ(*y-sy), sx, sy); + + check_row(1,0); + check_row(-1,0); + check_row(0,1); + check_row(0,-1); + } + + *x = best_x; *y = best_y; +} + +static PyObject * maskutils_convolve(PyObject *self /* Not used */, PyObject *args) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-03 23:43:44
|
Revision: 116 http://pen.svn.sourceforge.net/pen/?rev=116&view=rev Author: mdgeorge Date: 2008-12-03 23:43:41 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Moved all of the pygame stuff into pygame. some of this is just copies of headers, some of it is patched. Added Paths: ----------- pygame/src/bitmask.c pygame/src/bitmask.h Removed Paths: ------------- include/ Added: pygame/src/bitmask.c =================================================================== --- pygame/src/bitmask.c (rev 0) +++ pygame/src/bitmask.c 2008-12-03 23:43:41 UTC (rev 116) @@ -0,0 +1,979 @@ +/* + Bitmask Collision Detection Library 1.5 + Copyright (C) 2002-2005 Ulf Ekstrom except for the bitcount function which + is copyright (C) Donald W. Gillies, 1992, and the other bitcount function + which was taken from Jorg Arndt's excellent "Algorithms for Programmers" + text. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include <stdlib.h> +#include <stddef.h> +#include <string.h> +#include "bitmask.h" + +#ifndef INLINE +#warning No INLINE definition in bitmask.h, performance may suffer. +#endif + +#define MIN(a,b) ((a) <= (b) ? (a) : (b)) +#define MAX(a,b) ((a) >= (b) ? (a) : (b)) + +/* The code by Gillies is slightly (1-3%) faster than the more + readable code below */ +#define GILLIES + +static INLINE unsigned int bitcount(BITMASK_W n) +{ + if (BITMASK_W_LEN == 32) + { +#ifdef GILLIES +/* (C) Donald W. Gillies, 1992. All rights reserved. You may reuse + this bitcount() function anywhere you please as long as you retain + this Copyright Notice. */ + register unsigned long tmp; + return (tmp = (n) - (((n) >> 1) & 033333333333) - + (((n) >> 2) & 011111111111), + tmp = ((tmp + (tmp >> 3)) & 030707070707), + tmp = (tmp + (tmp >> 6)), + tmp = (tmp + (tmp >> 12) + (tmp >> 24)) & 077); +/* End of Donald W. Gillies bitcount code */ +#else + /* This piece taken from Jorg Arndt's "Algorithms for Programmers" */ + n = ((n>>1) & 0x55555555) + (n & 0x55555555); // 0-2 in 2 bits + n = ((n>>2) & 0x33333333) + (n & 0x33333333); // 0-4 in 4 bits + n = ((n>>4) + n) & 0x0f0f0f0f; // 0-8 in 4 bits + n += n>> 8; // 0-16 in 8 bits + n += n>>16; // 0-32 in 8 bits + return n & 0xff; +#endif + } + else if (BITMASK_W_LEN == 64) + { + n = ((n>>1) & 0x5555555555555555) + (n & 0x5555555555555555); + n = ((n>>2) & 0x3333333333333333) + (n & 0x3333333333333333); + n = ((n>>4) + n) & 0x0f0f0f0f0f0f0f0f; + n += n>> 8; + n += n>>16; + n += n>>32; + return n & 0xff; + } + else + { + /* Handle non-32 or 64 bit case the slow way */ + unsigned int nbits = 0; + while (n) + { + if (n & 1) + nbits++; + n = n >> 1; + } + return nbits; + } +} + +bitmask_t *bitmask_create(int w, int h) +{ + bitmask_t *temp; + temp = malloc(offsetof(bitmask_t,bits) + h*((w - 1)/BITMASK_W_LEN + 1)*sizeof(BITMASK_W)); + if (!temp) + return 0; + temp->w = w; + temp->h = h; + bitmask_clear(temp); + return temp; +} + +void bitmask_free(bitmask_t *m) +{ + free(m); +} + +void bitmask_clear(bitmask_t *m) +{ + memset(m->bits,0,m->h*((m->w - 1)/BITMASK_W_LEN + 1)*sizeof(BITMASK_W)); +} + +void bitmask_fill(bitmask_t *m) +{ + int len, shift; + BITMASK_W *pixels, cmask, full; + + len = m->h*((m->w - 1)/BITMASK_W_LEN); + shift = BITMASK_W_LEN - (m->w % BITMASK_W_LEN); + full = ~(BITMASK_W)0; + cmask = (~(BITMASK_W)0) >> shift; + /* fill all the pixels that aren't in the rightmost BITMASK_Ws */ + for (pixels = m->bits; pixels < (m->bits + len); pixels++) { + *pixels = full; + } + /* for the rightmost BITMASK_Ws, use cmask to ensure we aren't setting + bits that are outside of the mask */ + for (pixels = m->bits + len; pixels < (m->bits + len + m->h); pixels++) { + *pixels = cmask; + } +} + +void bitmask_invert(bitmask_t *m) +{ + int len, shift; + BITMASK_W *pixels, cmask; + + len = m->h*((m->w - 1)/BITMASK_W_LEN); + shift = BITMASK_W_LEN - (m->w % BITMASK_W_LEN); + cmask = (~(BITMASK_W)0) >> shift; + /* flip all the pixels that aren't in the rightmost BITMASK_Ws */ + for (pixels = m->bits; pixels < (m->bits + len); pixels++) { + *pixels = ~(*pixels); + } + /* for the rightmost BITMASK_Ws, & with cmask to ensure we aren't setting + bits that are outside of the mask */ + for (pixels = m->bits + len; pixels < (m->bits + len + m->h); pixels++) { + *pixels = cmask & ~(*pixels); + } +} + +unsigned int bitmask_count(bitmask_t *m) +{ + BITMASK_W *pixels; + unsigned int tot = 0; + + for (pixels=m->bits; pixels<(m->bits+m->h*((m->w-1)/BITMASK_W_LEN + 1)); pixels++) { + tot += bitcount(*pixels); + } + + return tot; +} + +int bitmask_overlap(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset) +{ + const BITMASK_W *a_entry,*a_end; + const BITMASK_W *b_entry; + const BITMASK_W *ap,*app,*bp; + unsigned int shift,rshift,i,astripes,bstripes; + + if ((xoffset >= a->w) || (yoffset >= a->h) || (b->h + yoffset <= 0) || (b->w + xoffset <= 0)) + return 0; + + if (xoffset >= 0) + { + swapentry: + if (yoffset >= 0) + { + a_entry = a->bits + a->h*((unsigned int)xoffset/BITMASK_W_LEN) + yoffset; + a_end = a_entry + MIN(b->h,a->h - yoffset); + b_entry = b->bits; + } + else + { + a_entry = a->bits + a->h*((unsigned int)xoffset/BITMASK_W_LEN); + a_end = a_entry + MIN(b->h + yoffset,a->h); + b_entry = b->bits - yoffset; + } + shift = xoffset & BITMASK_W_MASK; + if (shift) + { + rshift = BITMASK_W_LEN - shift; + astripes = ((unsigned int)(a->w - 1))/BITMASK_W_LEN - (unsigned int)xoffset/BITMASK_W_LEN; + bstripes = ((unsigned int)(b->w - 1))/BITMASK_W_LEN + 1; + if (bstripes > astripes) /* zig-zag .. zig*/ + { + for (i=0;i<astripes;i++) + { + for (ap = a_entry, app = ap + a->h, bp = b_entry;ap < a_end;) + if ((*ap++ >> shift) & *bp || (*app++ << rshift) & *bp++) return 1; + a_entry += a->h; + a_end += a->h; + b_entry += b->h; + } + for (ap = a_entry,bp = b_entry;ap < a_end;) + if ((*ap++ >> shift) & *bp++) return 1; + return 0; + } + else /* zig-zag */ + { + for (i=0;i<bstripes;i++) + { + for (ap = a_entry, app = ap + a->h, bp = b_entry;ap < a_end;) + if ((*ap++ >> shift) & *bp || (*app++ << rshift) & *bp++) return 1; + a_entry += a->h; + a_end += a->h; + b_entry += b->h; + } + return 0; + } + } + else /* xoffset is a multiple of the stripe width, and the above routines wont work */ + { + astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; + for (i=0;i<astripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;) + if (*ap++ & *bp++) return 1; + a_entry += a->h; + a_end += a->h; + b_entry += b->h; + } + return 0; + } + } + else + { + const bitmask_t *c = a; + a = b; + b = c; + xoffset *= -1; + yoffset *= -1; + goto swapentry; + } +} + +/* Will hang if there are no bits set in w! */ +static INLINE int firstsetbit(BITMASK_W w) +{ + int i = 0; + while ((w & 1) == 0) + { + i++; + w/=2; + } + return i; +} + +/* x and y are given in the coordinates of mask a, and are untouched if there is no overlap */ +int bitmask_overlap_pos(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset, int *x, int *y) +{ + const BITMASK_W *a_entry,*a_end, *b_entry, *ap, *bp; + unsigned int shift,rshift,i,astripes,bstripes,xbase; + + if ((xoffset >= a->w) || (yoffset >= a->h) || (yoffset <= - b->h)) + return 0; + + if (xoffset >= 0) + { + xbase = xoffset/BITMASK_W_LEN; /* first stripe from mask a */ + if (yoffset >= 0) + { + a_entry = a->bits + a->h*xbase + yoffset; + a_end = a_entry + MIN(b->h,a->h - yoffset); + b_entry = b->bits; + } + else + { + a_entry = a->bits + a->h*xbase; + a_end = a_entry + MIN(b->h + yoffset,a->h); + b_entry = b->bits - yoffset; + yoffset = 0; /* relied on below */ + } + shift = xoffset & BITMASK_W_MASK; + if (shift) + { + rshift = BITMASK_W_LEN - shift; + astripes = (a->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; + bstripes = (b->w - 1)/BITMASK_W_LEN + 1; + if (bstripes > astripes) /* zig-zag .. zig*/ + { + for (i=0;i<astripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + if (*ap & (*bp << shift)) + { + *y = ap - a_entry + yoffset; + *x = (xbase + i)*BITMASK_W_LEN + firstsetbit(*ap & (*bp << shift)); + return 1; + } + a_entry += a->h; + a_end += a->h; + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + if (*ap & (*bp >> rshift)) + { + *y = ap - a_entry + yoffset; + *x = (xbase + i + 1)*BITMASK_W_LEN + firstsetbit(*ap & (*bp >> rshift)); + return 1; + } + b_entry += b->h; + } + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + if (*ap & (*bp << shift)) + { + *y = ap - a_entry + yoffset; + *x = (xbase + astripes)*BITMASK_W_LEN + firstsetbit(*ap & (*bp << shift)); + return 1; + } + return 0; + } + else /* zig-zag */ + { + for (i=0;i<bstripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + if (*ap & (*bp << shift)) + { + *y = ap - a_entry + yoffset; + *x = (xbase + i)*BITMASK_W_LEN + firstsetbit(*ap & (*bp << shift)); + return 1; + } + a_entry += a->h; + a_end += a->h; + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + if (*ap & (*bp >> rshift)) + { + *y = ap - a_entry + yoffset; + *x = (xbase + i + 1)*BITMASK_W_LEN + firstsetbit(*ap & (*bp >> rshift)); + return 1; + } + b_entry += b->h; + } + return 0; + } + } + else +/* xoffset is a multiple of the stripe width, and the above routines + won't work. This way is also slightly faster. */ + { + astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; + for (i=0;i<astripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + { + if (*ap & *bp) + { + *y = ap - a_entry + yoffset; + *x = (xbase + i)*BITMASK_W_LEN + firstsetbit(*ap & *bp); + return 1; + } + } + a_entry += a->h; + a_end += a->h; + b_entry += b->h; + } + return 0; + } + } + else + { + if (bitmask_overlap_pos(b,a,-xoffset,-yoffset,x,y)) + { + *x += xoffset; + *y += yoffset; + return 1; + } + else + return 0; + } +} + +int bitmask_overlap_area(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset) +{ + const BITMASK_W *a_entry,*a_end, *b_entry, *ap,*bp; + unsigned int shift,rshift,i,astripes,bstripes; + unsigned int count = 0; + + if ((xoffset >= a->w) || (yoffset >= a->h) || (b->h + yoffset <= 0) || (b->w + xoffset <= 0)) + return 0; + + if (xoffset >= 0) + { + swapentry: + if (yoffset >= 0) + { + a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN) + yoffset; + a_end = a_entry + MIN(b->h,a->h - yoffset); + b_entry = b->bits; + } + else + { + a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN); + a_end = a_entry + MIN(b->h + yoffset,a->h); + b_entry = b->bits - yoffset; + } + shift = xoffset & BITMASK_W_MASK; + if (shift) + { + rshift = BITMASK_W_LEN - shift; + astripes = (a->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; + bstripes = (b->w - 1)/BITMASK_W_LEN + 1; + if (bstripes > astripes) /* zig-zag .. zig*/ + { + for (i=0;i<astripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + count += bitcount(((*ap >> shift) | (*(ap + a->h) << rshift)) & *bp); + a_entry += a->h; + a_end += a->h; + b_entry += b->h; + } + for (ap = a_entry,bp = b_entry;ap < a_end;) + count += bitcount((*ap++ >> shift) & *bp++); + return count; + } + else /* zig-zag */ + { + for (i=0;i<bstripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + count += bitcount(((*ap >> shift) | (*(ap + a->h) << rshift)) & *bp); + a_entry += a->h; + a_end += a->h; + b_entry += b->h; + } + return count; + } + } + else /* xoffset is a multiple of the stripe width, and the above routines wont work */ + { + astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; + for (i=0;i<astripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;) + count += bitcount(*ap++ & *bp++); + + a_entry += a->h; + a_end += a->h; + b_entry += b->h; + } + return count; + } + } + else + { + const bitmask_t *c = a; + a = b; + b = c; + xoffset *= -1; + yoffset *= -1; + goto swapentry; + } +} + +/* Makes a mask of the overlap of two other masks */ +void bitmask_overlap_mask(const bitmask_t *a, const bitmask_t *b, bitmask_t *c, int xoffset, int yoffset) +{ + const BITMASK_W *a_entry,*a_end, *ap; + const BITMASK_W *b_entry, *b_end, *bp; + BITMASK_W *c_entry, *c_end, *cp; + int shift,rshift,i,astripes,bstripes; + + if ((xoffset >= a->w) || (yoffset >= a->h) || (yoffset <= - b->h)) + return; + + if (xoffset >= 0) + { + if (yoffset >= 0) + { + a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN) + yoffset; + c_entry = c->bits + c->h*(xoffset/BITMASK_W_LEN) + yoffset; + a_end = a_entry + MIN(b->h,a->h - yoffset); + b_entry = b->bits; + } + else + { + a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN); + c_entry = c->bits + c->h*(xoffset/BITMASK_W_LEN); + a_end = a_entry + MIN(b->h + yoffset,a->h); + b_entry = b->bits - yoffset; + } + shift = xoffset & BITMASK_W_MASK; + if (shift) + { + rshift = BITMASK_W_LEN - shift; + astripes = (a->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; + bstripes = (b->w - 1)/BITMASK_W_LEN + 1; + if (bstripes > astripes) /* zig-zag .. zig*/ + { + for (i=0;i<astripes;i++) + { + for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) + *cp = *ap & (*bp << shift); + a_entry += a->h; + c_entry += c->h; + a_end += a->h; + for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) + *cp = *ap & (*bp >> rshift); + b_entry += b->h; + } + for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) + *cp = *ap & (*bp << shift); + } + else /* zig-zag */ + { + for (i=0;i<bstripes;i++) + { + for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) + *cp = *ap & (*bp << shift); + a_entry += a->h; + c_entry += c->h; + a_end += a->h; + for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) + *cp = *ap & (*bp >> rshift); + b_entry += b->h; + } + } + } + else /* xoffset is a multiple of the stripe width, + and the above routines won't work. */ + { + astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; + for (i=0;i<astripes;i++) + { + for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) + { + *cp = *ap & *bp; + } + a_entry += a->h; + c_entry += c->h; + a_end += a->h; + b_entry += b->h; + } + } + } + else + { + xoffset *= -1; + yoffset *= -1; + + if (yoffset >= 0) + { + b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN) + yoffset; + b_end = b_entry + MIN(a->h,b->h - yoffset); + a_entry = a->bits; + c_entry = c->bits; + } + else + { + b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN); + b_end = b_entry + MIN(a->h + yoffset,b->h); + a_entry = a->bits - yoffset; + c_entry = c->bits - yoffset; + } + shift = xoffset & BITMASK_W_MASK; + if (shift) + { + rshift = BITMASK_W_LEN - shift; + astripes = (b->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; + bstripes = (a->w - 1)/BITMASK_W_LEN + 1; + if (bstripes > astripes) /* zig-zag .. zig*/ + { + for (i=0;i<astripes;i++) + { + for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) + *cp = *ap & (*bp >> shift); + b_entry += b->h; + b_end += b->h; + for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) + *cp = *ap & (*bp <<rshift); + a_entry += a->h; + c_entry += c->h; + } + for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) + *cp = *ap & (*bp >> shift); + } + else /* zig-zag */ + { + for (i=0;i<bstripes;i++) + { + for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) + *cp = *ap & (*bp >> shift); + b_entry += b->h; + b_end += b->h; + for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) + *cp = *ap & (*bp << rshift); + a_entry += a->h; + c_entry += c->h; + } + } + } + else /* xoffset is a multiple of the stripe width, and the above routines won't work. */ + { + astripes = (MIN(a->w,b->w - xoffset) - 1)/BITMASK_W_LEN + 1; + for (i=0;i<astripes;i++) + { + for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) + { + *cp = *ap & *bp; + } + b_entry += b->h; + b_end += b->h; + a_entry += a->h; + c_entry += c->h; + } + } + xoffset *= -1; + yoffset *= -1; + } + /* Zero out bits outside the mask rectangle (to the right), if there + is a chance we were drawing there. */ + if (xoffset + b->w > c->w) + { + BITMASK_W edgemask; + int n = c->w/BITMASK_W_LEN; + shift = (n + 1)*BITMASK_W_LEN - c->w; + edgemask = (~(BITMASK_W)0) >> shift; + c_end = c->bits + n*c->h + MIN(c->h,b->h + yoffset); + for (cp = c->bits + n*c->h + MAX(yoffset,0);cp<c_end;cp++) + *cp &= edgemask; + } +} + +/* Draws mask b onto mask a (bitwise OR) */ +void bitmask_draw(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset) +{ + BITMASK_W *a_entry,*a_end, *ap; + const BITMASK_W *b_entry, *b_end, *bp; + int shift,rshift,i,astripes,bstripes; + + if ((xoffset >= a->w) || (yoffset >= a->h) || (yoffset <= - b->h)) + return; + + if (xoffset >= 0) + { + if (yoffset >= 0) + { + a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN) + yoffset; + a_end = a_entry + MIN(b->h,a->h - yoffset); + b_entry = b->bits; + } + else + { + a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN); + a_end = a_entry + MIN(b->h + yoffset,a->h); + b_entry = b->bits - yoffset; + } + shift = xoffset & BITMASK_W_MASK; + if (shift) + { + rshift = BITMASK_W_LEN - shift; + astripes = (a->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; + bstripes = (b->w - 1)/BITMASK_W_LEN + 1; + if (bstripes > astripes) /* zig-zag .. zig*/ + { + for (i=0;i<astripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + *ap |= (*bp << shift); + a_entry += a->h; + a_end += a->h; + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + *ap |= (*bp >> rshift); + b_entry += b->h; + } + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + *ap |= (*bp << shift); + } + else /* zig-zag */ + { + for (i=0;i<bstripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + *ap |= (*bp << shift); + a_entry += a->h; + a_end += a->h; + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + *ap |= (*bp >> rshift); + b_entry += b->h; + } + } + } + else /* xoffset is a multiple of the stripe width, + and the above routines won't work. */ + { + astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; + for (i=0;i<astripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + { + *ap |= *bp; + } + a_entry += a->h; + a_end += a->h; + b_entry += b->h; + } + } + } + else + { + xoffset *= -1; + yoffset *= -1; + + if (yoffset >= 0) + { + b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN) + yoffset; + b_end = b_entry + MIN(a->h,b->h - yoffset); + a_entry = a->bits; + } + else + { + b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN); + b_end = b_entry + MIN(a->h + yoffset,b->h); + a_entry = a->bits - yoffset; + } + shift = xoffset & BITMASK_W_MASK; + if (shift) + { + rshift = BITMASK_W_LEN - shift; + astripes = (b->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; + bstripes = (a->w - 1)/BITMASK_W_LEN + 1; + if (bstripes > astripes) /* zig-zag .. zig*/ + { + for (i=0;i<astripes;i++) + { + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + *ap |= (*bp >> shift); + b_entry += b->h; + b_end += b->h; + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + *ap |= (*bp <<rshift); + a_entry += a->h; + } + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + *ap |= (*bp >> shift); + } + else /* zig-zag */ + { + for (i=0;i<bstripes;i++) + { + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + *ap |= (*bp >> shift); + b_entry += b->h; + b_end += b->h; + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + *ap |= (*bp << rshift); + a_entry += a->h; + } + } + } + else /* xoffset is a multiple of the stripe width, and the above routines won't work. */ + { + astripes = (MIN(a->w,b->w - xoffset) - 1)/BITMASK_W_LEN + 1; + for (i=0;i<astripes;i++) + { + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + { + *ap |= *bp; + } + b_entry += b->h; + b_end += b->h; + a_entry += a->h; + } + } + xoffset *= -1; + yoffset *= -1; + } + /* Zero out bits outside the mask rectangle (to the right), if there + is a chance we were drawing there. */ + if (xoffset + b->w > a->w) + { + BITMASK_W edgemask; + int n = a->w/BITMASK_W_LEN; + shift = (n + 1)*BITMASK_W_LEN - a->w; + edgemask = (~(BITMASK_W)0) >> shift; + a_end = a->bits + n*a->h + MIN(a->h,b->h + yoffset); + for (ap = a->bits + n*a->h + MAX(yoffset,0);ap<a_end;ap++) + *ap &= edgemask; + } +} + +/* Erases mask b from mask a (a &= ~b) */ +void bitmask_erase(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset) +{ + BITMASK_W *a_entry,*a_end, *ap; + const BITMASK_W *b_entry, *b_end, *bp; + int shift,rshift,i,astripes,bstripes; + + if ((xoffset >= a->w) || (yoffset >= a->h) || (yoffset <= - b->h)) + return; + + if (xoffset >= 0) + { + if (yoffset >= 0) + { + a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN) + yoffset; + a_end = a_entry + MIN(b->h,a->h - yoffset); + b_entry = b->bits; + } + else + { + a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN); + a_end = a_entry + MIN(b->h + yoffset,a->h); + b_entry = b->bits - yoffset; + } + shift = xoffset & BITMASK_W_MASK; + if (shift) + { + rshift = BITMASK_W_LEN - shift; + astripes = (a->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; + bstripes = (b->w - 1)/BITMASK_W_LEN + 1; + if (bstripes > astripes) /* zig-zag .. zig*/ + { + for (i=0;i<astripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + *ap &= ~(*bp << shift); + a_entry += a->h; + a_end += a->h; + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + *ap &= ~(*bp >> rshift); + b_entry += b->h; + } + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + *ap &= ~(*bp << shift); + } + else /* zig-zag */ + { + for (i=0;i<bstripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + *ap &= ~(*bp << shift); + a_entry += a->h; + a_end += a->h; + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + *ap &= ~(*bp >> rshift); + b_entry += b->h; + } + } + } + else /* xoffset is a multiple of the stripe width, + and the above routines won't work. */ + { + astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; + for (i=0;i<astripes;i++) + { + for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) + { + *ap &= ~*bp; + } + a_entry += a->h; + a_end += a->h; + b_entry += b->h; + } + } + } + else + { + xoffset *= -1; + yoffset *= -1; + + if (yoffset >= 0) + { + b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN) + yoffset; + b_end = b_entry + MIN(a->h,b->h - yoffset); + a_entry = a->bits; + } + else + { + b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN); + b_end = b_entry + MIN(a->h + yoffset,b->h); + a_entry = a->bits - yoffset; + } + shift = xoffset & BITMASK_W_MASK; + if (shift) + { + rshift = BITMASK_W_LEN - shift; + astripes = (b->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; + bstripes = (a->w - 1)/BITMASK_W_LEN + 1; + if (bstripes > astripes) /* zig-zag .. zig*/ + { + for (i=0;i<astripes;i++) + { + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + *ap &= ~(*bp >> shift); + b_entry += b->h; + b_end += b->h; + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + *ap &= ~(*bp <<rshift); + a_entry += a->h; + } + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + *ap |= (*bp >> shift); + } + else /* zig-zag */ + { + for (i=0;i<bstripes;i++) + { + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + *ap &= ~(*bp >> shift); + b_entry += b->h; + b_end += b->h; + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + *ap &= ~(*bp << rshift); + a_entry += a->h; + } + } + } + else /* xoffset is a multiple of the stripe width, and the above routines won't work. */ + { + astripes = (MIN(a->w,b->w - xoffset) - 1)/BITMASK_W_LEN + 1; + for (i=0;i<astripes;i++) + { + for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) + *ap &= ~*bp; + b_entry += b->h; + b_end += b->h; + a_entry += a->h; + } + } + } +} + + + +bitmask_t *bitmask_scale(const bitmask_t *m, int w, int h) +{ + bitmask_t *nm; + int x,y,nx,ny,dx,dy,dnx,dny; + + if (w < 1 || h < 1) + { + nm = bitmask_create(1,1); + return nm; + } + + nm = bitmask_create(w,h); + if (!nm) + return NULL; + ny = dny = 0; + for (y=0,dy=h; y<m->h; y++,dy+=h) + { + while (dny < dy) + { + nx = dnx = 0; + for (x=0,dx=w; x < m->w; x++, dx+=w) + { + if (bitmask_getbit(m,x,y)) + { + while (dnx < dx) + { + bitmask_setbit(nm,nx,ny); + nx++; + dnx += m->w; + } + } + else + { + while (dnx < dx) + { + nx++; + dnx += m->w; + } + } + } + ny++; + dny+=m->h; + } + } + return nm; +} + Added: pygame/src/bitmask.h =================================================================== --- pygame/src/bitmask.h (rev 0) +++ pygame/src/bitmask.h 2008-12-03 23:43:41 UTC (rev 116) @@ -0,0 +1,138 @@ +/* + Bitmask 1.7 - A pixel-perfect collision detection library. + + Copyright (C) 2002-2005 Ulf Ekstrom except for the bitcount + function which is copyright (C) Donald W. Gillies, 1992. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef BITMASK_H +#define BITMASK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <limits.h> +/* Define INLINE for different compilers. If your compiler does not + support inlining then there might be a performance hit in + bitmask_overlap_area(). +*/ +#ifndef INLINE +# ifdef __GNUC__ +# define INLINE inline +# else +# ifdef _MSC_VER +# define INLINE __inline +# else +# define INLINE +# endif +# endif +#endif + +#define BITMASK_W unsigned long int +#define BITMASK_W_LEN (sizeof(BITMASK_W)*CHAR_BIT) +#define BITMASK_W_MASK (BITMASK_W_LEN - 1) +#define BITMASK_N(n) ((BITMASK_W)1 << (n)) + +typedef struct bitmask +{ + int w,h; + BITMASK_W bits[1]; +} bitmask_t; + +/* Creates a bitmask of width w and height h, where + w and h must both be greater than 0. + The mask is automatically cleared when created. + */ +bitmask_t *bitmask_create(int w, int h); + +/* Frees all the memory allocated by bitmask_create for m. */ +void bitmask_free(bitmask_t *m); + +/* Clears all bits in the mask */ +void bitmask_clear(bitmask_t *m); + +/* Sets all bits in the mask */ +void bitmask_fill(bitmask_t *m); + +/* Flips all bits in the mask */ +void bitmask_invert(bitmask_t *m); + +/* Counts the bits in the mask */ +unsigned int bitmask_count(bitmask_t *m); + +/* Returns nonzero if the bit at (x,y) is set. Coordinates start at + (0,0) */ +static INLINE int bitmask_getbit(const bitmask_t *m, int x, int y) +{ + return (m->bits[x/BITMASK_W_LEN*m->h + y] & BITMASK_N(x & BITMASK_W_MASK)) != 0; +} + +/* Sets the bit at (x,y) */ +static INLINE void bitmask_setbit(bitmask_t *m, int x, int y) +{ + m->bits[x/BITMASK_W_LEN*m->h + y] |= BITMASK_N(x & BITMASK_W_MASK); +} + +/* Clears the bit at (x,y) */ +static INLINE void bitmask_clearbit(bitmask_t *m, int x, int y) +{ + m->bits[x/BITMASK_W_LEN*m->h + y] &= ~BITMASK_N(x & BITMASK_W_MASK); +} + +/* Returns nonzero if the masks overlap with the given offset. + The overlap tests uses the following offsets (which may be negative): + + +----+----------.. + |A | yoffset + | +-+----------.. + +--|B + |xoffset + | | + : : +*/ +int bitmask_overlap(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); + +/* Like bitmask_overlap(), but will also give a point of intersection. + x and y are given in the coordinates of mask a, and are untouched + if there is no overlap. */ +int bitmask_overlap_pos(const bitmask_t *a, const bitmask_t *b, + int xoffset, int yoffset, int *x, int *y); + +/* Returns the number of overlapping 'pixels' */ +int bitmask_overlap_area(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); + +/* Fills a mask with the overlap of two other masks. A bitwise AND. */ +void bitmask_overlap_mask (const bitmask_t *a, const bitmask_t *b, bitmask_t *c, int xoffset, int yoffset); + +/* Draws mask b onto mask a (bitwise OR). Can be used to compose large + (game background?) mask from several submasks, which may speed up + the testing. */ + +void bitmask_draw(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); + +void bitmask_erase(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); + +/* Return a new scaled bitmask, with dimensions w*h. The quality of the + scaling may not be perfect for all circumstances, but it should + be reasonable. If either w or h is 0 a clear 1x1 mask is returned. */ +bitmask_t *bitmask_scale(const bitmask_t *m, int w, int h); + +#ifdef __cplusplus +} /* End of extern "C" { */ +#endif + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-03 23:14:17
|
Revision: 115 http://pen.svn.sourceforge.net/pen/?rev=115&view=rev Author: mdgeorge Date: 2008-12-03 23:14:14 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Removed mask.h from includes/...will replace with symlink. Removed Paths: ------------- include/mask.h Deleted: include/mask.h =================================================================== --- include/mask.h 2008-12-03 21:17:57 UTC (rev 114) +++ include/mask.h 2008-12-03 23:14:14 UTC (rev 115) @@ -1,23 +0,0 @@ -#include <Python.h> -#include "bitmask.h" - -#define PYGAMEAPI_MASK_NUMSLOTS - -typedef struct { - PyObject_HEAD - bitmask_t *mask; -} PyMaskObject; - -#define PyMask_AsBitmap(x) (((PyMaskObject*)x)->mask) - -#ifndef PYGAMEAPI_MASK_INTERNAL - -#define PyMask_Type (*(PyTypeObject*)PyMASK_C_API[0]) -#define PyMask_Check(x) ((x)->ob_type == &PyMask_Type) - - - -#endif /* !defined(PYGAMEAPI_MASK_INTERNAL) */ - -static void* PyMASK_C_API[PYGAMEAPI_MASK_NUMSLOTS] = {NULL}; - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-03 21:17:59
|
Revision: 114 http://pen.svn.sourceforge.net/pen/?rev=114&view=rev Author: mdgeorge Date: 2008-12-03 21:17:57 +0000 (Wed, 03 Dec 2008) Log Message: ----------- removed some non-distributed files. Modified Paths: -------------- data/Makefile.am Modified: data/Makefile.am =================================================================== --- data/Makefile.am 2008-12-03 20:22:39 UTC (rev 113) +++ data/Makefile.am 2008-12-03 21:17:57 UTC (rev 114) @@ -5,8 +5,6 @@ images/anvil.png \ images/soccerball.png \ images/paper.png \ - images/original/page5.png \ - images/original/page6.png \ images/antigrav.png \ images/tennisball.png \ images/cannon-base.png \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-03 20:22:42
|
Revision: 113 http://pen.svn.sourceforge.net/pen/?rev=113&view=rev Author: mdgeorge Date: 2008-12-03 20:22:39 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Linked simulation stepping to real time for a smoother animation. Modified Paths: -------------- src/physics.py Modified: src/physics.py =================================================================== --- src/physics.py 2008-12-03 20:21:41 UTC (rev 112) +++ src/physics.py 2008-12-03 20:22:39 UTC (rev 113) @@ -172,10 +172,11 @@ elif event.type == pygame.constants.KEYUP: break - clock.tick() + delay = clock.tick() soundEngine.pre_update() dt = 0.02 - engine.update(dt) + for i in range(0, delay, 1000*dt): + engine.update(dt) soundEngine.post_update() screengroup.update( dt ) @@ -193,3 +194,6 @@ l = level.Level( 'level1' ) simulate(l) +# +# vim: ts=4 sw=4 ai +# This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-03 20:21:44
|
Revision: 112 http://pen.svn.sourceforge.net/pen/?rev=112&view=rev Author: mdgeorge Date: 2008-12-03 20:21:41 +0000 (Wed, 03 Dec 2008) Log Message: ----------- removed some debugging output. Modified Paths: -------------- src/demos/curseropes.py Modified: src/demos/curseropes.py =================================================================== --- src/demos/curseropes.py 2008-12-03 04:07:11 UTC (rev 111) +++ src/demos/curseropes.py 2008-12-03 20:21:41 UTC (rev 112) @@ -101,9 +101,7 @@ if c != ccw and angle * best_dist >= best_angle * dist: # unwind - print "unwinding", c, ccw self.sweep(best) - print "done unwinding" self.points.pop() self.points.append((ccw, best)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-03 04:07:13
|
Revision: 111 http://pen.svn.sourceforge.net/pen/?rev=111&view=rev Author: mdgeorge Date: 2008-12-03 04:07:11 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Added initmask macro to mask.h Modified Paths: -------------- pygame/src/mask.h Modified: pygame/src/mask.h =================================================================== --- pygame/src/mask.h 2008-12-03 03:09:49 UTC (rev 110) +++ pygame/src/mask.h 2008-12-03 04:07:11 UTC (rev 111) @@ -2,6 +2,7 @@ #include "bitmask.h" #define PYGAMEAPI_MASK_NUMSLOTS +#define PYGAMEAPI_LOCAL_ENTRY "_PYGAME_C_API" typedef struct { PyObject_HEAD @@ -15,8 +16,18 @@ #define PyMask_Type (*(PyTypeObject*)PyMASK_C_API[0]) #define PyMask_Check(x) ((x)->ob_type == &PyMask_Type) +#define import_pygame_mask() { \ + PyObject *module = PyImport_ImportModule("pygame.mask"); \ + if (module != NULL) { \ + PyObject *dict = PyModule_GetDict(module); \ + PyObject *c_api = PyDict_GetItemString(dict, PYGAMEAPI_LOCAL_ENTRY); \ + if(PyCObject_Check(c_api)) { \ + void** localptr = (void**) PyCObject_AsVoidPtr(c_api); \ + memcpy(PyMASK_C_API, localptr, sizeof(void*)*PYGAMEAPI_FONT_NUMSLOTS); \ + } Py_DECREF(module); \ + } \ +} - #endif /* !defined(PYGAMEAPI_MASK_INTERNAL) */ static void* PyMASK_C_API[PYGAMEAPI_MASK_NUMSLOTS] = {NULL}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-03 03:09:52
|
Revision: 110 http://pen.svn.sourceforge.net/pen/?rev=110&view=rev Author: mdgeorge Date: 2008-12-03 03:09:49 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Replaced my old pygame patch (which add custom functionality that has been moved into maskutils in src/) with my new pygame patch (which adds a C API object to the mask module). Modified Paths: -------------- pygame/src/mask.c Added Paths: ----------- pygame/src/mask.h Removed Paths: ------------- pygame/src/bitmask.c pygame/src/bitmask.h pygame/src/mask.doc pygame/src/pygamedocs.h pygame/test/ Deleted: pygame/src/bitmask.c =================================================================== --- pygame/src/bitmask.c 2008-12-03 03:00:27 UTC (rev 109) +++ pygame/src/bitmask.c 2008-12-03 03:09:49 UTC (rev 110) @@ -1,1038 +0,0 @@ -/* - Bitmask Collision Detection Library 1.5 - Copyright (C) 2002-2005 Ulf Ekstrom except for the bitcount function which - is copyright (C) Donald W. Gillies, 1992, and the other bitcount function - which was taken from Jorg Arndt's excellent "Algorithms for Programmers" - text. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <stdlib.h> -#include <stddef.h> -#include <string.h> -#include "bitmask.h" - -#ifndef INLINE -#warning No INLINE definition in bitmask.h, performance may suffer. -#endif - -#define MIN(a,b) ((a) <= (b) ? (a) : (b)) -#define MAX(a,b) ((a) >= (b) ? (a) : (b)) - -/* The code by Gillies is slightly (1-3%) faster than the more - readable code below */ -#define GILLIES - -static INLINE unsigned int bitcount(BITMASK_W n) -{ - if (BITMASK_W_LEN == 32) - { -#ifdef GILLIES -/* (C) Donald W. Gillies, 1992. All rights reserved. You may reuse - this bitcount() function anywhere you please as long as you retain - this Copyright Notice. */ - register unsigned long tmp; - return (tmp = (n) - (((n) >> 1) & 033333333333) - - (((n) >> 2) & 011111111111), - tmp = ((tmp + (tmp >> 3)) & 030707070707), - tmp = (tmp + (tmp >> 6)), - tmp = (tmp + (tmp >> 12) + (tmp >> 24)) & 077); -/* End of Donald W. Gillies bitcount code */ -#else - /* This piece taken from Jorg Arndt's "Algorithms for Programmers" */ - n = ((n>>1) & 0x55555555) + (n & 0x55555555); // 0-2 in 2 bits - n = ((n>>2) & 0x33333333) + (n & 0x33333333); // 0-4 in 4 bits - n = ((n>>4) + n) & 0x0f0f0f0f; // 0-8 in 4 bits - n += n>> 8; // 0-16 in 8 bits - n += n>>16; // 0-32 in 8 bits - return n & 0xff; -#endif - } - else if (BITMASK_W_LEN == 64) - { - n = ((n>>1) & 0x5555555555555555) + (n & 0x5555555555555555); - n = ((n>>2) & 0x3333333333333333) + (n & 0x3333333333333333); - n = ((n>>4) + n) & 0x0f0f0f0f0f0f0f0f; - n += n>> 8; - n += n>>16; - n += n>>32; - return n & 0xff; - } - else - { - /* Handle non-32 or 64 bit case the slow way */ - unsigned int nbits = 0; - while (n) - { - if (n & 1) - nbits++; - n = n >> 1; - } - return nbits; - } -} - -bitmask_t *bitmask_create(int w, int h) -{ - bitmask_t *temp; - temp = malloc(offsetof(bitmask_t,bits) + h*((w - 1)/BITMASK_W_LEN + 1)*sizeof(BITMASK_W)); - if (!temp) - return 0; - temp->w = w; - temp->h = h; - bitmask_clear(temp); - return temp; -} - -void bitmask_free(bitmask_t *m) -{ - free(m); -} - -void bitmask_clear(bitmask_t *m) -{ - memset(m->bits,0,m->h*((m->w - 1)/BITMASK_W_LEN + 1)*sizeof(BITMASK_W)); -} - -void bitmask_fill(bitmask_t *m) -{ - int len, shift; - BITMASK_W *pixels, cmask, full; - - len = m->h*((m->w - 1)/BITMASK_W_LEN); - shift = BITMASK_W_LEN - (m->w % BITMASK_W_LEN); - full = ~(BITMASK_W)0; - cmask = (~(BITMASK_W)0) >> shift; - /* fill all the pixels that aren't in the rightmost BITMASK_Ws */ - for (pixels = m->bits; pixels < (m->bits + len); pixels++) { - *pixels = full; - } - /* for the rightmost BITMASK_Ws, use cmask to ensure we aren't setting - bits that are outside of the mask */ - for (pixels = m->bits + len; pixels < (m->bits + len + m->h); pixels++) { - *pixels = cmask; - } -} - -void bitmask_invert(bitmask_t *m) -{ - int len, shift; - BITMASK_W *pixels, cmask; - - len = m->h*((m->w - 1)/BITMASK_W_LEN); - shift = BITMASK_W_LEN - (m->w % BITMASK_W_LEN); - cmask = (~(BITMASK_W)0) >> shift; - /* flip all the pixels that aren't in the rightmost BITMASK_Ws */ - for (pixels = m->bits; pixels < (m->bits + len); pixels++) { - *pixels = ~(*pixels); - } - /* for the rightmost BITMASK_Ws, & with cmask to ensure we aren't setting - bits that are outside of the mask */ - for (pixels = m->bits + len; pixels < (m->bits + len + m->h); pixels++) { - *pixels = cmask & ~(*pixels); - } -} - -unsigned int bitmask_count(bitmask_t *m) -{ - BITMASK_W *pixels; - unsigned int tot = 0; - - for (pixels=m->bits; pixels<(m->bits+m->h*((m->w-1)/BITMASK_W_LEN + 1)); pixels++) { - tot += bitcount(*pixels); - } - - return tot; -} - -int bitmask_overlap(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset) -{ - const BITMASK_W *a_entry,*a_end; - const BITMASK_W *b_entry; - const BITMASK_W *ap,*app,*bp; - unsigned int shift,rshift,i,astripes,bstripes; - - if ((xoffset >= a->w) || (yoffset >= a->h) || (b->h + yoffset <= 0) || (b->w + xoffset <= 0)) - return 0; - - if (xoffset >= 0) - { - swapentry: - if (yoffset >= 0) - { - a_entry = a->bits + a->h*((unsigned int)xoffset/BITMASK_W_LEN) + yoffset; - a_end = a_entry + MIN(b->h,a->h - yoffset); - b_entry = b->bits; - } - else - { - a_entry = a->bits + a->h*((unsigned int)xoffset/BITMASK_W_LEN); - a_end = a_entry + MIN(b->h + yoffset,a->h); - b_entry = b->bits - yoffset; - } - shift = xoffset & BITMASK_W_MASK; - if (shift) - { - rshift = BITMASK_W_LEN - shift; - astripes = ((unsigned int)(a->w - 1))/BITMASK_W_LEN - (unsigned int)xoffset/BITMASK_W_LEN; - bstripes = ((unsigned int)(b->w - 1))/BITMASK_W_LEN + 1; - if (bstripes > astripes) /* zig-zag .. zig*/ - { - for (i=0;i<astripes;i++) - { - for (ap = a_entry, app = ap + a->h, bp = b_entry;ap < a_end;) - if ((*ap++ >> shift) & *bp || (*app++ << rshift) & *bp++) return 1; - a_entry += a->h; - a_end += a->h; - b_entry += b->h; - } - for (ap = a_entry,bp = b_entry;ap < a_end;) - if ((*ap++ >> shift) & *bp++) return 1; - return 0; - } - else /* zig-zag */ - { - for (i=0;i<bstripes;i++) - { - for (ap = a_entry, app = ap + a->h, bp = b_entry;ap < a_end;) - if ((*ap++ >> shift) & *bp || (*app++ << rshift) & *bp++) return 1; - a_entry += a->h; - a_end += a->h; - b_entry += b->h; - } - return 0; - } - } - else /* xoffset is a multiple of the stripe width, and the above routines wont work */ - { - astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; - for (i=0;i<astripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;) - if (*ap++ & *bp++) return 1; - a_entry += a->h; - a_end += a->h; - b_entry += b->h; - } - return 0; - } - } - else - { - const bitmask_t *c = a; - a = b; - b = c; - xoffset *= -1; - yoffset *= -1; - goto swapentry; - } -} - -/* Will hang if there are no bits set in w! */ -static INLINE int firstsetbit(BITMASK_W w) -{ - int i = 0; - while ((w & 1) == 0) - { - i++; - w/=2; - } - return i; -} - -/* x and y are given in the coordinates of mask a, and are untouched if there is no overlap */ -int bitmask_overlap_pos(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset, int *x, int *y) -{ - const BITMASK_W *a_entry,*a_end, *b_entry, *ap, *bp; - unsigned int shift,rshift,i,astripes,bstripes,xbase; - - if ((xoffset >= a->w) || (yoffset >= a->h) || (yoffset <= - b->h)) - return 0; - - if (xoffset >= 0) - { - xbase = xoffset/BITMASK_W_LEN; /* first stripe from mask a */ - if (yoffset >= 0) - { - a_entry = a->bits + a->h*xbase + yoffset; - a_end = a_entry + MIN(b->h,a->h - yoffset); - b_entry = b->bits; - } - else - { - a_entry = a->bits + a->h*xbase; - a_end = a_entry + MIN(b->h + yoffset,a->h); - b_entry = b->bits - yoffset; - yoffset = 0; /* relied on below */ - } - shift = xoffset & BITMASK_W_MASK; - if (shift) - { - rshift = BITMASK_W_LEN - shift; - astripes = (a->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; - bstripes = (b->w - 1)/BITMASK_W_LEN + 1; - if (bstripes > astripes) /* zig-zag .. zig*/ - { - for (i=0;i<astripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - if (*ap & (*bp << shift)) - { - *y = ap - a_entry + yoffset; - *x = (xbase + i)*BITMASK_W_LEN + firstsetbit(*ap & (*bp << shift)); - return 1; - } - a_entry += a->h; - a_end += a->h; - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - if (*ap & (*bp >> rshift)) - { - *y = ap - a_entry + yoffset; - *x = (xbase + i + 1)*BITMASK_W_LEN + firstsetbit(*ap & (*bp >> rshift)); - return 1; - } - b_entry += b->h; - } - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - if (*ap & (*bp << shift)) - { - *y = ap - a_entry + yoffset; - *x = (xbase + astripes)*BITMASK_W_LEN + firstsetbit(*ap & (*bp << shift)); - return 1; - } - return 0; - } - else /* zig-zag */ - { - for (i=0;i<bstripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - if (*ap & (*bp << shift)) - { - *y = ap - a_entry + yoffset; - *x = (xbase + i)*BITMASK_W_LEN + firstsetbit(*ap & (*bp << shift)); - return 1; - } - a_entry += a->h; - a_end += a->h; - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - if (*ap & (*bp >> rshift)) - { - *y = ap - a_entry + yoffset; - *x = (xbase + i + 1)*BITMASK_W_LEN + firstsetbit(*ap & (*bp >> rshift)); - return 1; - } - b_entry += b->h; - } - return 0; - } - } - else -/* xoffset is a multiple of the stripe width, and the above routines - won't work. This way is also slightly faster. */ - { - astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; - for (i=0;i<astripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - { - if (*ap & *bp) - { - *y = ap - a_entry + yoffset; - *x = (xbase + i)*BITMASK_W_LEN + firstsetbit(*ap & *bp); - return 1; - } - } - a_entry += a->h; - a_end += a->h; - b_entry += b->h; - } - return 0; - } - } - else - { - if (bitmask_overlap_pos(b,a,-xoffset,-yoffset,x,y)) - { - *x += xoffset; - *y += yoffset; - return 1; - } - else - return 0; - } -} - -int bitmask_overlap_area(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset) -{ - const BITMASK_W *a_entry,*a_end, *b_entry, *ap,*bp; - unsigned int shift,rshift,i,astripes,bstripes; - unsigned int count = 0; - - if ((xoffset >= a->w) || (yoffset >= a->h) || (b->h + yoffset <= 0) || (b->w + xoffset <= 0)) - return 0; - - if (xoffset >= 0) - { - swapentry: - if (yoffset >= 0) - { - a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN) + yoffset; - a_end = a_entry + MIN(b->h,a->h - yoffset); - b_entry = b->bits; - } - else - { - a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN); - a_end = a_entry + MIN(b->h + yoffset,a->h); - b_entry = b->bits - yoffset; - } - shift = xoffset & BITMASK_W_MASK; - if (shift) - { - rshift = BITMASK_W_LEN - shift; - astripes = (a->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; - bstripes = (b->w - 1)/BITMASK_W_LEN + 1; - if (bstripes > astripes) /* zig-zag .. zig*/ - { - for (i=0;i<astripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - count += bitcount(((*ap >> shift) | (*(ap + a->h) << rshift)) & *bp); - a_entry += a->h; - a_end += a->h; - b_entry += b->h; - } - for (ap = a_entry,bp = b_entry;ap < a_end;) - count += bitcount((*ap++ >> shift) & *bp++); - return count; - } - else /* zig-zag */ - { - for (i=0;i<bstripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - count += bitcount(((*ap >> shift) | (*(ap + a->h) << rshift)) & *bp); - a_entry += a->h; - a_end += a->h; - b_entry += b->h; - } - return count; - } - } - else /* xoffset is a multiple of the stripe width, and the above routines wont work */ - { - astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; - for (i=0;i<astripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;) - count += bitcount(*ap++ & *bp++); - - a_entry += a->h; - a_end += a->h; - b_entry += b->h; - } - return count; - } - } - else - { - const bitmask_t *c = a; - a = b; - b = c; - xoffset *= -1; - yoffset *= -1; - goto swapentry; - } -} - -/* Makes a mask of the overlap of two other masks */ -void bitmask_overlap_mask(const bitmask_t *a, const bitmask_t *b, bitmask_t *c, int xoffset, int yoffset) -{ - const BITMASK_W *a_entry,*a_end, *ap; - const BITMASK_W *b_entry, *b_end, *bp; - BITMASK_W *c_entry, *c_end, *cp; - int shift,rshift,i,astripes,bstripes; - - if ((xoffset >= a->w) || (yoffset >= a->h) || (yoffset <= - b->h)) - return; - - if (xoffset >= 0) - { - if (yoffset >= 0) - { - a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN) + yoffset; - c_entry = c->bits + c->h*(xoffset/BITMASK_W_LEN) + yoffset; - a_end = a_entry + MIN(b->h,a->h - yoffset); - b_entry = b->bits; - } - else - { - a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN); - c_entry = c->bits + c->h*(xoffset/BITMASK_W_LEN); - a_end = a_entry + MIN(b->h + yoffset,a->h); - b_entry = b->bits - yoffset; - } - shift = xoffset & BITMASK_W_MASK; - if (shift) - { - rshift = BITMASK_W_LEN - shift; - astripes = (a->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; - bstripes = (b->w - 1)/BITMASK_W_LEN + 1; - if (bstripes > astripes) /* zig-zag .. zig*/ - { - for (i=0;i<astripes;i++) - { - for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) - *cp = *ap & (*bp << shift); - a_entry += a->h; - c_entry += c->h; - a_end += a->h; - for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) - *cp = *ap & (*bp >> rshift); - b_entry += b->h; - } - for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) - *cp = *ap & (*bp << shift); - } - else /* zig-zag */ - { - for (i=0;i<bstripes;i++) - { - for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) - *cp = *ap & (*bp << shift); - a_entry += a->h; - c_entry += c->h; - a_end += a->h; - for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) - *cp = *ap & (*bp >> rshift); - b_entry += b->h; - } - } - } - else /* xoffset is a multiple of the stripe width, - and the above routines won't work. */ - { - astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; - for (i=0;i<astripes;i++) - { - for (ap = a_entry,bp = b_entry,cp = c_entry;ap < a_end;ap++,bp++,cp++) - { - *cp = *ap & *bp; - } - a_entry += a->h; - c_entry += c->h; - a_end += a->h; - b_entry += b->h; - } - } - } - else - { - xoffset *= -1; - yoffset *= -1; - - if (yoffset >= 0) - { - b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN) + yoffset; - b_end = b_entry + MIN(a->h,b->h - yoffset); - a_entry = a->bits; - c_entry = c->bits; - } - else - { - b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN); - b_end = b_entry + MIN(a->h + yoffset,b->h); - a_entry = a->bits - yoffset; - c_entry = c->bits - yoffset; - } - shift = xoffset & BITMASK_W_MASK; - if (shift) - { - rshift = BITMASK_W_LEN - shift; - astripes = (b->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; - bstripes = (a->w - 1)/BITMASK_W_LEN + 1; - if (bstripes > astripes) /* zig-zag .. zig*/ - { - for (i=0;i<astripes;i++) - { - for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) - *cp = *ap & (*bp >> shift); - b_entry += b->h; - b_end += b->h; - for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) - *cp = *ap & (*bp <<rshift); - a_entry += a->h; - c_entry += c->h; - } - for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) - *cp = *ap & (*bp >> shift); - } - else /* zig-zag */ - { - for (i=0;i<bstripes;i++) - { - for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) - *cp = *ap & (*bp >> shift); - b_entry += b->h; - b_end += b->h; - for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) - *cp = *ap & (*bp << rshift); - a_entry += a->h; - c_entry += c->h; - } - } - } - else /* xoffset is a multiple of the stripe width, and the above routines won't work. */ - { - astripes = (MIN(a->w,b->w - xoffset) - 1)/BITMASK_W_LEN + 1; - for (i=0;i<astripes;i++) - { - for (bp = b_entry,ap = a_entry,cp = c_entry;bp < b_end;bp++,ap++,cp++) - { - *cp = *ap & *bp; - } - b_entry += b->h; - b_end += b->h; - a_entry += a->h; - c_entry += c->h; - } - } - xoffset *= -1; - yoffset *= -1; - } - /* Zero out bits outside the mask rectangle (to the right), if there - is a chance we were drawing there. */ - if (xoffset + b->w > c->w) - { - BITMASK_W edgemask; - int n = c->w/BITMASK_W_LEN; - shift = (n + 1)*BITMASK_W_LEN - c->w; - edgemask = (~(BITMASK_W)0) >> shift; - c_end = c->bits + n*c->h + MIN(c->h,b->h + yoffset); - for (cp = c->bits + n*c->h + MAX(yoffset,0);cp<c_end;cp++) - *cp &= edgemask; - } -} - -/* Draws mask b onto mask a (bitwise OR) */ -void bitmask_draw(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset) -{ - BITMASK_W *a_entry,*a_end, *ap; - const BITMASK_W *b_entry, *b_end, *bp; - int shift,rshift,i,astripes,bstripes; - - if ((xoffset >= a->w) || (yoffset >= a->h) || (yoffset <= - b->h)) - return; - - if (xoffset >= 0) - { - if (yoffset >= 0) - { - a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN) + yoffset; - a_end = a_entry + MIN(b->h,a->h - yoffset); - b_entry = b->bits; - } - else - { - a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN); - a_end = a_entry + MIN(b->h + yoffset,a->h); - b_entry = b->bits - yoffset; - } - shift = xoffset & BITMASK_W_MASK; - if (shift) - { - rshift = BITMASK_W_LEN - shift; - astripes = (a->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; - bstripes = (b->w - 1)/BITMASK_W_LEN + 1; - if (bstripes > astripes) /* zig-zag .. zig*/ - { - for (i=0;i<astripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - *ap |= (*bp << shift); - a_entry += a->h; - a_end += a->h; - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - *ap |= (*bp >> rshift); - b_entry += b->h; - } - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - *ap |= (*bp << shift); - } - else /* zig-zag */ - { - for (i=0;i<bstripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - *ap |= (*bp << shift); - a_entry += a->h; - a_end += a->h; - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - *ap |= (*bp >> rshift); - b_entry += b->h; - } - } - } - else /* xoffset is a multiple of the stripe width, - and the above routines won't work. */ - { - astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; - for (i=0;i<astripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - { - *ap |= *bp; - } - a_entry += a->h; - a_end += a->h; - b_entry += b->h; - } - } - } - else - { - xoffset *= -1; - yoffset *= -1; - - if (yoffset >= 0) - { - b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN) + yoffset; - b_end = b_entry + MIN(a->h,b->h - yoffset); - a_entry = a->bits; - } - else - { - b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN); - b_end = b_entry + MIN(a->h + yoffset,b->h); - a_entry = a->bits - yoffset; - } - shift = xoffset & BITMASK_W_MASK; - if (shift) - { - rshift = BITMASK_W_LEN - shift; - astripes = (b->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; - bstripes = (a->w - 1)/BITMASK_W_LEN + 1; - if (bstripes > astripes) /* zig-zag .. zig*/ - { - for (i=0;i<astripes;i++) - { - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - *ap |= (*bp >> shift); - b_entry += b->h; - b_end += b->h; - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - *ap |= (*bp <<rshift); - a_entry += a->h; - } - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - *ap |= (*bp >> shift); - } - else /* zig-zag */ - { - for (i=0;i<bstripes;i++) - { - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - *ap |= (*bp >> shift); - b_entry += b->h; - b_end += b->h; - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - *ap |= (*bp << rshift); - a_entry += a->h; - } - } - } - else /* xoffset is a multiple of the stripe width, and the above routines won't work. */ - { - astripes = (MIN(a->w,b->w - xoffset) - 1)/BITMASK_W_LEN + 1; - for (i=0;i<astripes;i++) - { - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - { - *ap |= *bp; - } - b_entry += b->h; - b_end += b->h; - a_entry += a->h; - } - } - xoffset *= -1; - yoffset *= -1; - } - /* Zero out bits outside the mask rectangle (to the right), if there - is a chance we were drawing there. */ - if (xoffset + b->w > a->w) - { - BITMASK_W edgemask; - int n = a->w/BITMASK_W_LEN; - shift = (n + 1)*BITMASK_W_LEN - a->w; - edgemask = (~(BITMASK_W)0) >> shift; - a_end = a->bits + n*a->h + MIN(a->h,b->h + yoffset); - for (ap = a->bits + n*a->h + MAX(yoffset,0);ap<a_end;ap++) - *ap &= edgemask; - } -} - -/* Erases mask b from mask a (a &= ~b) */ -void bitmask_erase(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset) -{ - BITMASK_W *a_entry,*a_end, *ap; - const BITMASK_W *b_entry, *b_end, *bp; - int shift,rshift,i,astripes,bstripes; - - if ((xoffset >= a->w) || (yoffset >= a->h) || (yoffset <= - b->h)) - return; - - if (xoffset >= 0) - { - if (yoffset >= 0) - { - a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN) + yoffset; - a_end = a_entry + MIN(b->h,a->h - yoffset); - b_entry = b->bits; - } - else - { - a_entry = a->bits + a->h*(xoffset/BITMASK_W_LEN); - a_end = a_entry + MIN(b->h + yoffset,a->h); - b_entry = b->bits - yoffset; - } - shift = xoffset & BITMASK_W_MASK; - if (shift) - { - rshift = BITMASK_W_LEN - shift; - astripes = (a->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; - bstripes = (b->w - 1)/BITMASK_W_LEN + 1; - if (bstripes > astripes) /* zig-zag .. zig*/ - { - for (i=0;i<astripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - *ap &= ~(*bp << shift); - a_entry += a->h; - a_end += a->h; - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - *ap &= ~(*bp >> rshift); - b_entry += b->h; - } - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - *ap &= ~(*bp << shift); - } - else /* zig-zag */ - { - for (i=0;i<bstripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - *ap &= ~(*bp << shift); - a_entry += a->h; - a_end += a->h; - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - *ap &= ~(*bp >> rshift); - b_entry += b->h; - } - } - } - else /* xoffset is a multiple of the stripe width, - and the above routines won't work. */ - { - astripes = (MIN(b->w,a->w - xoffset) - 1)/BITMASK_W_LEN + 1; - for (i=0;i<astripes;i++) - { - for (ap = a_entry,bp = b_entry;ap < a_end;ap++,bp++) - { - *ap &= ~*bp; - } - a_entry += a->h; - a_end += a->h; - b_entry += b->h; - } - } - } - else - { - xoffset *= -1; - yoffset *= -1; - - if (yoffset >= 0) - { - b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN) + yoffset; - b_end = b_entry + MIN(a->h,b->h - yoffset); - a_entry = a->bits; - } - else - { - b_entry = b->bits + b->h*(xoffset/BITMASK_W_LEN); - b_end = b_entry + MIN(a->h + yoffset,b->h); - a_entry = a->bits - yoffset; - } - shift = xoffset & BITMASK_W_MASK; - if (shift) - { - rshift = BITMASK_W_LEN - shift; - astripes = (b->w - 1)/BITMASK_W_LEN - xoffset/BITMASK_W_LEN; - bstripes = (a->w - 1)/BITMASK_W_LEN + 1; - if (bstripes > astripes) /* zig-zag .. zig*/ - { - for (i=0;i<astripes;i++) - { - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - *ap &= ~(*bp >> shift); - b_entry += b->h; - b_end += b->h; - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - *ap &= ~(*bp <<rshift); - a_entry += a->h; - } - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - *ap |= (*bp >> shift); - } - else /* zig-zag */ - { - for (i=0;i<bstripes;i++) - { - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - *ap &= ~(*bp >> shift); - b_entry += b->h; - b_end += b->h; - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - *ap &= ~(*bp << rshift); - a_entry += a->h; - } - } - } - else /* xoffset is a multiple of the stripe width, and the above routines won't work. */ - { - astripes = (MIN(a->w,b->w - xoffset) - 1)/BITMASK_W_LEN + 1; - for (i=0;i<astripes;i++) - { - for (bp = b_entry,ap = a_entry;bp < b_end;bp++,ap++) - *ap &= ~*bp; - b_entry += b->h; - b_end += b->h; - a_entry += a->h; - } - } - } -} - - - -bitmask_t *bitmask_scale(const bitmask_t *m, int w, int h) -{ - bitmask_t *nm; - int x,y,nx,ny,dx,dy,dnx,dny; - - if (w < 1 || h < 1) - { - nm = bitmask_create(1,1); - return nm; - } - - nm = bitmask_create(w,h); - if (!nm) - return NULL; - ny = dny = 0; - for (y=0,dy=h; y<m->h; y++,dy+=h) - { - while (dny < dy) - { - nx = dnx = 0; - for (x=0,dx=w; x < m->w; x++, dx+=w) - { - if (bitmask_getbit(m,x,y)) - { - while (dnx < dx) - { - bitmask_setbit(nm,nx,ny); - nx++; - dnx += m->w; - } - } - else - { - while (dnx < dx) - { - nx++; - dnx += m->w; - } - } - } - ny++; - dny+=m->h; - } - } - return nm; -} - -void bitmask_convolve(const bitmask_t *a, const bitmask_t *b, bitmask_t *o, int xoffset, int yoffset) -{ - int x, y; - - xoffset += b->w - 1; - yoffset += b->h - 1; - for (y = 0; y < b->h; y++) - for (x = 0; x < b->w; x++) - if (bitmask_getbit(b, x, y)) - bitmask_draw(o, a, xoffset - x, yoffset - y); -} - -static inline int valid(const bitmask_t *mask, int x, int y) -{ - return x < 0 || y < 0 || - x >= mask->w || y >= mask->h || - !bitmask_getbit(mask,x,y); -} - -void bitmask_find_closest(const bitmask_t *mask, int *x, int *y) -{ -#define SQ(x) (x)*(x) - - /* this method is either very elegant or very ugly. */ - int best_d = SQ(*x + 1), best_x = -1, best_y = *y; - int covered; - -#define check_point(dist,x,y) \ - if(dist < best_d) { \ - best_d = dist; \ - best_x = x; \ - best_y = y; \ - } - - if (valid(mask, *x, *y)) - check_point(0, *x, *y); - - /* loop invariant: I've at least looked at everything of distance less than less than covered */ - for (covered = 1; SQ(covered) <= best_d; covered++) - { - int sx, sy, i; - -#define check_row(xi, yi) \ - sx = *x - (xi)*covered + (yi)*covered; \ - sy = *y - (yi)*covered - (xi)*covered; \ - for (i = 0; i < 2*covered; i++, sx += xi, sy += yi) \ - if (valid(mask, sx, sy)) \ - check_point(SQ(*x-sx) + SQ(*y-sy), sx, sy); - - check_row(1,0); - check_row(-1,0); - check_row(0,1); - check_row(0,-1); - } - - *x = best_x; *y = best_y; -} - - Deleted: pygame/src/bitmask.h =================================================================== --- pygame/src/bitmask.h 2008-12-03 03:00:27 UTC (rev 109) +++ pygame/src/bitmask.h 2008-12-03 03:09:49 UTC (rev 110) @@ -1,149 +0,0 @@ -/* - Bitmask 1.7 - A pixel-perfect collision detection library. - - Copyright (C) 2002-2005 Ulf Ekstrom except for the bitcount - function which is copyright (C) Donald W. Gillies, 1992. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef BITMASK_H -#define BITMASK_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <limits.h> -/* Define INLINE for different compilers. If your compiler does not - support inlining then there might be a performance hit in - bitmask_overlap_area(). -*/ -#ifndef INLINE -# ifdef __GNUC__ -# define INLINE inline -# else -# ifdef _MSC_VER -# define INLINE __inline -# else -# define INLINE -# endif -# endif -#endif - -#define BITMASK_W unsigned long int -#define BITMASK_W_LEN (sizeof(BITMASK_W)*CHAR_BIT) -#define BITMASK_W_MASK (BITMASK_W_LEN - 1) -#define BITMASK_N(n) ((BITMASK_W)1 << (n)) - -typedef struct bitmask -{ - int w,h; - BITMASK_W bits[1]; -} bitmask_t; - -/* Creates a bitmask of width w and height h, where - w and h must both be greater than 0. - The mask is automatically cleared when created. - */ -bitmask_t *bitmask_create(int w, int h); - -/* Frees all the memory allocated by bitmask_create for m. */ -void bitmask_free(bitmask_t *m); - -/* Clears all bits in the mask */ -void bitmask_clear(bitmask_t *m); - -/* Sets all bits in the mask */ -void bitmask_fill(bitmask_t *m); - -/* Flips all bits in the mask */ -void bitmask_invert(bitmask_t *m); - -/* Counts the bits in the mask */ -unsigned int bitmask_count(bitmask_t *m); - -/* Returns nonzero if the bit at (x,y) is set. Coordinates start at - (0,0) */ -static INLINE int bitmask_getbit(const bitmask_t *m, int x, int y) -{ - return (m->bits[x/BITMASK_W_LEN*m->h + y] & BITMASK_N(x & BITMASK_W_MASK)) != 0; -} - -/* Sets the bit at (x,y) */ -static INLINE void bitmask_setbit(bitmask_t *m, int x, int y) -{ - m->bits[x/BITMASK_W_LEN*m->h + y] |= BITMASK_N(x & BITMASK_W_MASK); -} - -/* Clears the bit at (x,y) */ -static INLINE void bitmask_clearbit(bitmask_t *m, int x, int y) -{ - m->bits[x/BITMASK_W_LEN*m->h + y] &= ~BITMASK_N(x & BITMASK_W_MASK); -} - -/* Returns nonzero if the masks overlap with the given offset. - The overlap tests uses the following offsets (which may be negative): - - +----+----------.. - |A | yoffset - | +-+----------.. - +--|B - |xoffset - | | - : : -*/ -int bitmask_overlap(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); - -/* Like bitmask_overlap(), but will also give a point of intersection. - x and y are given in the coordinates of mask a, and are untouched - if there is no overlap. */ -int bitmask_overlap_pos(const bitmask_t *a, const bitmask_t *b, - int xoffset, int yoffset, int *x, int *y); - -/* Returns the number of overlapping 'pixels' */ -int bitmask_overlap_area(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); - -/* Fills a mask with the overlap of two other masks. A bitwise AND. */ -void bitmask_overlap_mask (const bitmask_t *a, const bitmask_t *b, bitmask_t *c, int xoffset, int yoffset); - -/* Draws mask b onto mask a (bitwise OR). Can be used to compose large - (game background?) mask from several submasks, which may speed up - the testing. */ - -void bitmask_draw(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); - -void bitmask_erase(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); - -/* Return a new scaled bitmask, with dimensions w*h. The quality of the - scaling may not be perfect for all circumstances, but it should - be reasonable. If either w or h is 0 a clear 1x1 mask is returned. */ -bitmask_t *bitmask_scale(const bitmask_t *m, int w, int h); - -/* Convolve b into a, drawing the output into o, shifted by offset. If offset - * is 0, then the (x,y) bit will be set if and only if - * bitmask_overlap(a, b, x - b->w - 1, y - b->h - 1) returns true. - * - * Modifies bits o[xoffset ... xoffset + a->w + b->w - 1) - * [yoffset ... yoffset + a->h + b->h - 1). */ -void bitmask_convolve(const bitmask_t *a, const bitmask_t *b, bitmask_t *o, int xoffset, int yoffset); - -/* Find the closest point to (x,y) with mask[x,y] not set */ -void bitmask_find_closest(const bitmask_t *mask, int * x, int * y); - -#ifdef __cplusplus -} /* End of extern "C" { */ -#endif - -#endif Modified: pygame/src/mask.c =================================================================== --- pygame/src/mask.c 2008-12-03 03:00:27 UTC (rev 109) +++ pygame/src/mask.c 2008-12-03 03:09:49 UTC (rev 110) @@ -26,6 +26,8 @@ #define CALLLOG(x) fprintf(stderr, (x)); */ +#define PYGAMEAPI_MASK_INTERNAL 1 +#include "mask.h" #include "pygame.h" #include "pygamedocs.h" #include "structmember.h" @@ -36,16 +38,8 @@ #define M_PI 3.14159265358979323846 #endif -typedef struct { - PyObject_HEAD - bitmask_t *mask; -} PyMaskObject; - staticforward PyTypeObject PyMask_Type; -#define PyMask_Check(x) ((x)->ob_type == &PyMask_Type) -#define PyMask_AsBitmap(x) (((PyMaskObject*)x)->mask) - /* mask object methods */ static PyObject* mask_get_size(PyObject* self, PyObject* args) @@ -379,7 +373,7 @@ bitmask_free(m); return plist; } - + /* the outline tracing loop */ for (;;) { /* look around the pixel, it has to have a neighbor */ @@ -395,11 +389,11 @@ } value = Py_BuildValue("(ii)", nextx-1, nexty-1); PyList_Append(plist, value); - Py_DECREF(value); + Py_DECREF(value); } break; } - } + } /* if we are back at the first pixel, and the next one will be the second one we visited, we are done */ if ((curry == firsty && currx == firstx) && (secx == nextx && secy == nexty)) { @@ -409,52 +403,12 @@ curry = nexty; currx = nextx; } - + bitmask_free(m); - + return plist; } -static PyObject* mask_convolve(PyObject* aobj, PyObject* args) -{ - PyObject *bobj, *oobj = Py_None; - bitmask_t *a, *b, *o; - int xoffset = 0, yoffset = 0; - - if (!PyArg_ParseTuple (args, "O!|O(ii)", &PyMask_Type, &bobj, &oobj, &xoffset, &yoffset)) - return NULL; - - a = PyMask_AsBitmap(aobj); - b = PyMask_AsBitmap(bobj); - - if (oobj == Py_None) { - PyMaskObject *result = PyObject_New(PyMaskObject, &PyMask_Type); - - result->mask = bitmask_create(a->w + b->w - 1, a->h + b->h - 1); - oobj = (PyObject*) result; - } - else - Py_INCREF(oobj); - - o = PyMask_AsBitmap(oobj); - - bitmask_convolve(a, b, o, xoffset, yoffset); - return oobj; -} - -static PyObject * mask_find_closest(PyObject* self, PyObject* args) -{ - bitmask_t * mask = PyMask_AsBitmap(self); - int x, y; - - if (!PyArg_ParseTuple(args, "(ii)", &x, &y)) - return NULL; - - bitmask_find_closest(mask, &x, &y); - - return Py_BuildValue("(ii)", x, y); -} - static PyObject* mask_from_surface(PyObject* self, PyObject* args) { bitmask_t *mask; @@ -558,7 +512,7 @@ */ PySurface_Unlock (surfobj); - /*create the new python object from mask*/ + /*create the new python object from mask*/ maskobj = PyObject_New(PyMaskObject, &PyMask_Type); if(maskobj) maskobj->mask = mask; @@ -567,7 +521,7 @@ return (PyObject*)maskobj; } -void bitmask_threshold (bitmask_t *m, SDL_Surface *surf, SDL_Surface *surf2, +void bitmask_threshold (bitmask_t *m, SDL_Surface *surf, SDL_Surface *surf2, Uint32 color, Uint32 threshold) { int x, y, rshift, gshift, bshift, rshift2, gshift2, bshift2; @@ -578,7 +532,9 @@ Uint8 *pix; Uint8 r, g, b, a; Uint8 tr, tg, tb, ta; + int bpp1, bpp2; + pixels = (Uint8 *) surf->pixels; format = surf->format; rmask = format->Rmask; @@ -590,6 +546,7 @@ rloss = format->Rloss; gloss = format->Gloss; bloss = format->Bloss; + bpp1 = surf->format->BytesPerPixel; if(surf2) { format2 = surf2->format; @@ -603,14 +560,17 @@ gloss2 = format2->Gloss; bloss2 = format2->Bloss; pixels2 = (Uint8 *) surf2->pixels; + bpp2 = surf->format->BytesPerPixel; } else { /* make gcc stop complaining */ rmask2 = gmask2 = bmask2 = 0; rshift2 = gshift2 = bshift2 = 0; rloss2 = gloss2 = bloss2 = 0; format2 = NULL; pixels2 = NULL; + bpp2 = 0; } + SDL_GetRGBA (color, format, &r, &g, &b, &a); SDL_GetRGBA (threshold, format, &tr, &tg, &tb, &ta); @@ -621,7 +581,7 @@ } for(x=0; x < surf->w; x++) { /* the_color = surf->get_at(x,y) */ - switch (format->BytesPerPixel) + switch (bpp1) { case 1: the_color = (Uint32)*((Uint8 *) pixels); @@ -647,7 +607,7 @@ } if (surf2) { - switch (format2->BytesPerPixel) { + switch (bpp2) { case 1: the_color2 = (Uint32)*((Uint8 *) pixels2); pixels2++; @@ -669,15 +629,15 @@ the_color2 = *((Uint32 *) pixels2); pixels2 += 4; break; - } - if ((abs((((the_color2 & rmask2) >> rshift2) << rloss2) - (((the_color & rmask) >> rshift) << rloss)) < tr) & - (abs((((the_color2 & gmask2) >> gshift2) << gloss2) - (((the_color & gmask) >> gshift) << gloss)) < tg) & + } + if ((abs((((the_color2 & rmask2) >> rshift2) << rloss2) - (((the_color & rmask) >> rshift) << rloss)) < tr) & + (abs((((the_color2 & gmask2) >> gshift2) << gloss2) - (((the_color & gmask) >> gshift) << gloss)) < tg) & (abs((((the_color2 & bmask2) >> bshift2) << bloss2) - (((the_color & bmask) >> bshift) << bloss)) < tb)) { /* this pixel is within the threshold of othersurface. */ bitmask_setbit(m, x, y); } - } else if ((abs((((the_color & rmask) >> rshift) << rloss) - r) < tr) & - (abs((((the_color & gmask) >> gshift) << gloss) - g) < tg) & + } else if ((abs((((the_color & rmask) >> rshift) << rloss) - r) < tr) & + (abs((((the_color & gmask) >> gshift) << gloss) - g) < tg) & (abs((((the_color & bmask) >> bshift) << bloss) - b) < tb)) { /* this pixel is within the threshold of the color. */ bitmask_setbit(m, x, y); @@ -741,12 +701,12 @@ bpp = surf->format->BytesPerPixel; m = bitmask_create(surf->w, surf->h); - + PySurface_Lock(surfobj); if(surfobj2) { PySurface_Lock(surfobj2); } - + Py_BEGIN_ALLOW_THREADS; bitmask_threshold (m, surf, surf2, color, color_threshold); Py_END_ALLOW_THREADS; @@ -766,7 +726,7 @@ -/* the initial labelling phase of the connected components algorithm +/* the initial labelling phase of the connected components algorithm Returns: The highest label in the labelled image @@ -779,7 +739,7 @@ unsigned int cc_label(bitmask_t *input, unsigned int* image, unsigned int* ufind, unsigned int* largest) { unsigned int *buf; unsigned int x, y, w, h, root, aroot, croot, temp, label; - + label = 0; w = input->w; h = input->h; @@ -800,9 +760,9 @@ - /* special case for first row. - Go over the first row except the first pixel. - */ + /* special case for first row. + Go over the first row except the first pixel. + */ for(x = 1; x < w; x++) { if (bitmask_getbit(input, x, 0)) { if (*(buf-1)) { /* d label */ @@ -938,7 +898,7 @@ buf++; } } - + return label; } @@ -952,7 +912,7 @@ checked. It stores equivalence information in an array based union-find. This implementation also has a final step of finding bounding boxes. */ -/* +/* returns -2 on memory allocation error, otherwise 0 on success. input - the input mask. @@ -983,8 +943,8 @@ largest = (unsigned int *) malloc(sizeof(int)*(w/2 + 1)*(h/2 + 1)); if(!largest) { return -2; } - - + + /* do the initial labelling */ label = cc_label(input, image, ufind, largest); @@ -996,7 +956,7 @@ if (ufind[x] < x) { /* is it a union find root? */ ufind[x] = ufind[ufind[x]]; /* relabel it to its root */ } else { /* its a root */ - relabel++; + relabel++; ufind[x] = relabel; /* assign the lowest label available */ } } @@ -1015,7 +975,7 @@ /* the bounding rects, need enough space for the number of labels */ rects = (GAME_Rect *) malloc(sizeof(GAME_Rect) * (relabel +1)); if(!rects) { return -2; } - + for (temp = 0; temp <= relabel; temp++) { rects[temp].h = 0; /* so we know if its a new rect or not */ } @@ -1040,8 +1000,8 @@ } buf++; } - } - + } + free(image); free(ufind); free(largest); @@ -1057,8 +1017,8 @@ int num_bounding_boxes, i, r; PyObject* ret; PyObject* rect; - + bitmask_t *mask = PyMask_AsBitmap(self); ret = NULL; @@ -1118,10 +1078,10 @@ largest = (unsigned int *) malloc(sizeof(int)*(w/2 + 1)*(h/2 + 1)); if(!largest) { return -2; } - + /* do the initial labelling */ label = cc_label(mask, image, ufind, largest); - + for (x = 1; x <= label; x++) { if (ufind[x] < x) { largest[ufind[x]] += largest[x]; @@ -1137,7 +1097,7 @@ ufind[x] = ufind[ufind[x]]; /* relabel it to its root */ } else { /* its a root */ if (largest[x] >= min) { - relabel++; + relabel++; ufind[x] = relabel; /* assign the lowest label available */ } else { ufind[x] = 0; @@ -1156,7 +1116,7 @@ /* allocate space for the mask array */ comps = (bitmask_t **) malloc(sizeof(bitmask_t *) * (relabel +1)); if(!comps) { return -2; } - + /* create the empty masks */ for (x = 1; x <= relabel; x++) { comps[x] = bitmask_create(w, h); @@ -1172,7 +1132,7 @@ buf++; } } - + free(image); free(ufind); free(largest); @@ -1180,7 +1140,7 @@ *components = comps; return relabel; -} +} static PyObject* mask_connected_components(PyObject* self, PyObject* args) { @@ -1189,25 +1149,25 @@ bitmask_t **components; bitmask_t *mask = PyMask_AsBitmap(self); int i, num_components, min; - + min = 0; components = NULL; - + if(!PyArg_ParseTuple(args, "|i", &min)) { return NULL; } - + Py_BEGIN_ALLOW_THREADS; num_components = get_connected_components(mask, &components, min); Py_END_ALLOW_THREADS; - + if (num_components == -2) return RAISE (PyExc_MemoryError, "Not enough memory to get components. \n"); - + ret = PyList_New(0); if (!ret) - return NULL; - + return NULL; + for (i=1; i <= num_components; i++) { maskobj = PyObject_New(PyMaskObject, &PyMask_Type); if(maskobj) { @@ -1216,7 +1176,7 @@ Py_DECREF((PyObject *) maskobj); } } - + free(components); return ret; } @@ -1227,14 +1187,14 @@ summary, it is a very efficient two pass method for 8-connected components. It uses a decision tree to minimize the number of neighbors that need to be checked. It stores equivalence information in an array based union-find. - This implementation also tracks the number of pixels in each label, finding - the biggest one while flattening the union-find equivalence array. It then + This implementation also tracks the number of pixels in each label, finding + the biggest one while flattening the union-find equivalence array. It then writes an output mask containing only the largest connected component. */ static int largest_connected_comp(bitmask_t* input, bitmask_t* output, int ccx, int ccy) { unsigned int *image, *ufind, *largest, *buf; unsigned int max, x, y, w, h, label; - + w = input->w; h = input->h; @@ -1244,11 +1204,18 @@ /* allocate enough space for the maximum possible connected components */ /* the union-find array. see wikipedia for info on union find */ ufind = (unsigned int *) malloc(sizeof(int)*(w/2 + 1)*(h/2 + 1)); - if(!ufind) { return -2; } + if(!ufind) { + free(image); + return -2; + } /* an array to track the number of pixels associated with each label */ largest = (unsigned int *) malloc(sizeof(int)*(w/2 + 1)*(h/2 + 1)); - if(!largest) { return -2; } - + if(!largest) { + free(image); + free(ufind); + return -2; + } + /* do the initial labelling */ label = cc_label(input, image, ufind, largest); @@ -1263,7 +1230,7 @@ max = ufind[x]; } } - + /* write out the final image */ buf = image; if (ccx >= 0) @@ -1276,11 +1243,11 @@ buf++; } } - + free(image); free(ufind); free(largest); - + return 0; } @@ -1288,28 +1255,29 @@ { bitmask_t *input = PyMask_AsBitmap(self); bitmask_t *output = bitmask_create(input->w, input->h); - PyMaskObject *maskobj = PyObject_New(PyMaskObject, &PyMask_Type); + PyMaskObject *maskobj = PyObject_New(PyMaskObject, &PyMask_Type); int x, y; - + x = -1; if(!PyArg_ParseTuple(args, "|(ii)", &x, &y)) { return NULL; } - + /* if a coordinate is specified, make the pixel there is actually set */ if (x == -1 || bitmask_getbit(input, x, y)) { if (largest_connected_comp(input, output, x, y) == -2) { return RAISE (PyExc_MemoryError, "Not enough memory to get bounding rects. \n"); } } - + if(maskobj) maskobj->mask = output; return (PyObject*)maskobj; } + static PyMethodDef maskobj_builtins[] = { { "get_size", mask_get_size, METH_VARARGS, DOC_MASKGETSIZE}, @@ -1328,8 +1296,6 @@ { "centroid", mask_centroid, METH_NOARGS, DOC_MASKCENTROID }, { "angle", mask_angle, METH_NOARGS, DOC_MASKANGLE }, { "outline", mask_outline, METH_VARARGS, DOC_MASKOUTLINE }, - { "convolve", mask_convolve, METH_VARARGS, DOC_MASKCONVOLVE }, - { "find_closest", mask_find_closest, METH_VARARGS, DOC_MASKFINDCLOSEST }, { "connected_component", mask_connected_component, METH_VARARGS, DOC_MASKCONNECTEDCOMPONENT }, { "connected_components", mask_connected_components, METH_VARARGS, @@ -1358,7 +1324,7 @@ } -static PyTypeObject PyMask_Type = +static PyTypeObject PyMask_Type = { PyObject_HEAD_INIT(NULL) 0, @@ -1373,7 +1339,7 @@ 0, 0, NULL, - 0, + 0, (hashfunc)NULL, (ternaryfunc)NULL, (reprfunc)NULL, @@ -1395,8 +1361,8 @@ if(!mask) return NULL; /*RAISE(PyExc_Error, "cannot create bitmask");*/ - - /*create the new python object from mask*/ + + /*create the new python object from mask*/ maskobj = PyObject_New(PyMaskObject, &PyMask_Type); if(maskobj) maskobj->mask = mask; @@ -1419,7 +1385,7 @@ { PyObject *module, *dict; PyType_Init(PyMask_Type); - + /* create the module */ module = Py_InitModule3("mask", mask_builtins, DOC_PYGAMEMASK); dict = PyModule_GetDict(module); Deleted: pygame/src/mask.doc =================================================================== --- pygame/src/mask.doc 2008-12-03 03:00:27 UTC (rev 109) +++ pygame/src/mask.doc 2008-12-03 03:09:49 UTC (rev 110) @@ -1,212 +0,0 @@ -pygame.mask -pygame module for image masks. - -Useful for fast pixel perfect collision detection. A Mask uses 1bit per -pixel to store which parts collide. - -New in pygame 1.8. -<SECTION> - -from_surface -Returns a Mask from the given surface. -pygame.mask.from_surface(Surface, threshold = 127) -> Mask - -Makes the transparent parts of the Surface not set, and the opaque parts set. - -The alpha of each pixel is checked to see if it is greater than the -given threshold. - -If the Surface is color keyed, then threshold is not used. -<END> - -from_threshold -Creates a mask by thresholding Surfaces -pygame.mask.from_surface(Surface, color, threshold = (0,0,0,255), othersurface = None) -> Mask - -This is a more featureful method of getting a Mask from a Surface. If supplied -with only one Surface, all pixels within the threshold of the supplied color are -set in the Mask. If given the optional othersurface, all pixels in Surface that -are within the threshold of the corresponding pixel in othersurface are set in -the Mask. -<END> - -Mask -pygame object for representing 2d bitmasks -pygame.Mask((width, height)): return Mask -<SECTION> - -get_size -Returns the size of the mask. -Mask.get_size() -> width,height -<END> - -get_at -Returns nonzero if the bit at (x,y) is set. -Mask.get_at((x,y)) -> int - -Coordinates start at (0,0) is top left - just like Surfaces. -<END> - -set_at -Sets the position in the mask given by x and y. -Mask.set_at((x,y),value) -<END> - -overlap -Returns the point of intersection if the masks overlap with the given offset - or None if it does not overlap. -Mask.overlap(othermask, offset) -> x,y - -The overlap tests uses the following offsets (which may be negative): - - +----+----------.. - |A | yoffset - | +-+----------.. - +--|B - |xoffset - | | - : : -<END> - -overlap_area -Returns the number of overlapping 'pixels'. -Mask.overlap_area(othermask, offset) -> numpixels - -You can see how many pixels overlap with the other mask given. This can -be used to see in which direction things collide, or to see how much the -two masks collide. An approximate collision normal can be found by calculating -the gradient of the overlap area through the finite difference. - - dx = Mask.overlap_area(othermask,(x+1,y)) - Mask.overlap_area(othermask,(x-1,y)) - dy = Mask.overlap_area(othermask,(x,y+1)) - Mask.overlap_area(othermask,(x,y-1)) -<END> - -overlap_mask -Returns a mask of the overlapping pixels -Mask.overlap_mask(othermask, offset) -> Mask - -Returns a Mask the size of the original Mask containing only the overlapping -pixels between Mask and othermask. -<END> - -fill -Sets all bits to 1 -Mask.fill() - -Sets all bits in a Mask to 1. -<END> - -clear -Sets all bits to 0 -Mask.clear() - -Sets all bits in a Mask to 0. -<END> - -invert -Flips the bits in a Mask -Mask.invert() - -Flips all of the bits in a Mask, so that the set pixels turn to unset pixels and -the unset pixels turn to set pixels. -<END> - -scale -Resizes a mask -Mask.scale((x, y)) -> Mask - -Returns a new Mask of the Mask scaled to the requested size. -<END> - -draw -Draws a mask onto another -Mask.draw(othermask, offset) - -Performs a bitwise OR, drawing othermask onto Mask. -<END> - -erase -Erases a mask from another -Mask.erase(othermask, offset) - -Erases all pixels set in othermask from Mask. -<END> - -count -Returns the number of set pixels -Mask.count() -> pixels - -Returns the number of set pixels in the Mask. -<END> - -centroid -Returns the centroid of the pixels in a Mask -Mask.centroid() -> (x, y) - -Finds the centroid, the center of pixel mass, of a Mask. Returns a coordinate -tuple for the centroid of the Mask. In the event the Mask is empty, it will -return (0,0). -<END> - -angle -Returns the orientation of the pixels -Mask.angle() -> theta - -Finds the approximate orientation of the pixels in the image from -90 to 90 -degrees. This works best if performed on one connected component of pixels. It -will return 0.0 on an empty Mask. -<END> - -outline -list of points outlining an object -Mask.outline(every = 1) -> [(x,y), (x,y) ...] - -Returns a list of points of the outline of the first object it comes across in a -Mask. For this to be useful, there should probably only be one connected -component of pixels in the Mask. The every option allows you to skip pixels in -the outline. For example, setting it to 10 would return a list of every 10th -pixel in the outline. -<END> - -connected_component -Returns a mask of a connected region of pixels. -Mask.connected_component((x,y) = None) -> Mask - -This uses the SAUF algorithm to find a connected component in the -Mask. It checks 8 point connectivity. By default, it will return the largest -connected component in the image. Optionally, a coordinate pair of a pixel can -be specified, and the connected component containing it will be returned. In -the event the pixel at that location is not set, the returned Mask will be -empty. The Mask returned is the same size as the original Mask. -<END> - -connected_components -Returns a list of masks of connected regions of pixels. -Mask.connected_components(min = 0) -> [Masks] - -Returns a list of masks of connected regions of pixels. An optional minimum -number of pixels per connected region can be specified to filter out noise. -<END> - -get_bounding_rects -Returns a list of bounding rects of regions of set pixels. -Mask.get_bounding_rects() -> Rects - -This gets a bounding rect of connected regions of set pixels. A -bounding rect is one for which each of the connected pixels is inside -the rect. -<END> - -convolve -Return the convolution of self with another mask. -Mask.convolve(othermask, outputmask = None, offset = (0,0)): return Mask -Returns a mask with the (i-offset[0],j-offset[1]) bit set if shifting othermask -so that it's lower right corner pixel is at (i,j) would cause it to overlap -with self. - -If outputmask is not None, then the output is drawn onto outputmask and -outputmask is returned. Otherwise a mask of size self.size() + -othermask.getsize() - (1,1) is created. -<END> - - -<END> Added: pygame/src/mask.h =================================================================== --- pygame/src/mask.h (rev 0) +++ pygame/src/mask.h 2008-12-03 03:09:49 UTC (rev 110) @@ -0,0 +1,23 @@ +#include <Python.h> +#include "bitmask.h" + +#define PYGAMEAPI_MASK_NUMSLOTS + +typedef struct { + PyObject_HEAD + bitmask_t *mask; +} PyMaskObject; + +#define PyMask_AsBitmap(x) (((PyMaskObject*)x)->mask) + +#ifndef PYGAMEAPI_MASK_INTERNAL + +#define PyMask_Type (*(PyTypeObject*)PyMASK_C_API[0]) +#define PyMask_Check(x) ((x)->ob_type == &PyMask_Type) + + + +#endif /* !defined(PYGAMEAPI_MASK_INTERNAL) */ + +static void* PyMASK_C_API[PYGAMEAPI_MASK_NUMSLOTS] = {NULL}; + Deleted: pygame/src/pygamedocs.h =================================================================== --- pygame/src/pygamedocs.h 2008-12-03 03:00:27 UTC (rev 109) +++ pygame/src/pygamedocs.h 2008-12-03 03:09:49 UTC (rev 110) @@ -1,915 +0,0 @@ -/* Auto generated file: with makeref.py . Docs go in src/ *.doc . */ -#define DOC_PYGAME "the top level pygame package" - -#define DOC_PYGAMEINIT "pygame.init(): return (numpass, numfail)\ninitialize all imported pygame modules" - -#define DOC_PYGAMEQUIT "pygame.quit(): return None\nuninitialize all pygame modules" - -#define DOC_PYGAMEERROR "raise pygame.error, message\nstandard pygame exception" - -#define DOC_PYGAMEGETERROR "pygame.get_error(): return errorstr\nget the current error message" - -#define DOC_PYGAMEGETSDLVERSION "pygame.get_sdl_version(): return major, minor, patch\nget the version number of SDL" - -#define DOC_PYGAMEGETSDLBYTEORDER "pygame.get_sdl_byteorder(): return int\nget the byte order of SDL" - -#define DOC_PYGAMEREGISTERQUIT "register_quit(callable): return None\nregister a function to be called when pygame quits" - -#define DOC_PYGAMEVERSION "module pygame.version\nsmall module containing version information" - -#define DOC_PYGAMEVERSIONVER "pygame.version.ver = '1.2'\nversion number as a string" - -#define DOC_PYGAMEVERSIONVERNUM "pygame.version.vernum = (1, 5, 3)\ntupled integers of the version" - -#define DOC_PYGAMECAMERA "pygame module for camera use" - -#define DOC_PYGAMECAMERACOLORSPACE "pygame.camera.colorspace(Surface, format, DestSurface = None): return Surface\nSurface colorspace conversion" - -#define DOC_PYGAMECAMERALISTCAMERAS "pygame.camera.list_cameras(): return [cameras]\nreturns a list of available cameras" - -#define DOC_PYGAMECAMERACAMERA "pygame.camera.Camera(device, (width, height), format): return Camera\nload a camera" - -#define DOC_CAMERASTART "Camera.start(): return None\nopens, initializes, and starts capturing" - -#define DOC_CAMERASTOP "Camera.stop(): return None\nstops, uninitializes, and closes the camera" - -#define DOC_CAMERAGETCONTROLS "Camera.get_controls(): return (hflip = bool, vflip = bool)\ngets current values of user controls" - -#define DOC_CAMERASETCONTROLS "Camera.set_controls(hflip = bool, vflip = bool): return (hflip = bool, vflip = bool)\nchanges camera settings if supported by the camera" - -#define DOC_CAMERAGETSIZE "Camera.get_size(): return (width, height)\nreturns the dimensions of the images being recorded" - -#define DOC_CAMERAQUERYIMAGE "Camera.query_image(): return bool\nchecks if a frame is ready" - -#define DOC_CAMERAGETIMAGE "Camera.get_image(Surface = None): return Surface\ncaptures an image as a Surface" - -#define DOC_CAMERAGETRAW "Camera.get_raw(): return string\nreturns an unmodified image as a string" - -#define DOC_PYGAMECDROM "pygame module for audio cdrom control" - -#define DOC_PYGAMECDROMINIT "pygame.cdrom.init(): return None\ninitialize the cdrom module" - -#define DOC_PYGAMECDROMQUIT "pygame.cdrom.quit(): return None\nuninitialize the cdrom module" - -#define DOC_PYGAMECDROMGETINIT "pygame.cdrom.get_init(): return bool\ntrue if the cdrom module is initialized" - -#define DOC_PYGAMECDROMGETCOUNT "pygame.cdrom.get_count(): return count\nnu... [truncated message content] |
From: <mdg...@us...> - 2008-12-03 03:00:31
|
Revision: 109 http://pen.svn.sourceforge.net/pen/?rev=109&view=rev Author: mdgeorge Date: 2008-12-03 03:00:27 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Cleaned out some of the old CGAL stuff from the source tree and the build system. Updated the build scripts. Factored my mask extensions into a separate maskutils module. Modified Paths: -------------- autogen.sh configure.ac src/Makefile.am Added Paths: ----------- config/m4/python.m4 include/bitmask.h include/mask.h src/demos/Makefile.am src/maskutils.c Removed Paths: ------------- config/m4/CGAL.m4 config/m4/ax_boost_base.m4 config/m4/ax_boost_python.m4 config/m4/ax_python.m4 include/CGAL/ Property Changed: ---------------- src/ src/demos/ Modified: autogen.sh =================================================================== --- autogen.sh 2008-12-03 01:41:53 UTC (rev 108) +++ autogen.sh 2008-12-03 03:00:27 UTC (rev 109) @@ -1,9 +1,9 @@ #!/bin/sh aclocal -I config/m4 && -autoconf && -libtoolize && -automake && -./configure --with-cgalmakefile=/home/mike/download/cgal/CGAL-3.2.1/make/Makefile/makefile_i586_Linux-2.6_g++-4.1.2 && +autoconf && +libtoolize && +automake && +./configure && make Deleted: config/m4/CGAL.m4 =================================================================== --- config/m4/CGAL.m4 2008-12-03 01:41:53 UTC (rev 108) +++ config/m4/CGAL.m4 2008-12-03 03:00:27 UTC (rev 109) @@ -1,99 +0,0 @@ -dnl CHECK CGAL BEGIN -dnl This script takes two arguments, the action on success and the action on failure. -dnl It first checks if CGAL_MAKEFILE is defined (or a --with-cgalmakefile) value is passed. -dnl If that fails, it seaches for CGAL in the standard places. -dnl CGAL_CXXFLAGS, CGAL_CPPFLAGS, CGAL_LDFLAGS and CGAL_LIBS are all defined. -dnl -dnl Modified from http://graphics.stanford.edu/~drussel/autotest/CGAL.m4 -AC_DEFUN([ACX_CGAL], -[ -acx_cgal_found=no -AC_ARG_WITH(cgalmakefile, - [AC_HELP_STRING([--with-cgalmakefile=makefile], [Use the following CGAL makefile])]) -case $with_cgalmakefile in - yes | "") ;; - no) acx_cgal_found=disable ;; - -* | */* | *.a | *.so | *.so.* | *.o) CGAL_MAKEFILE="$with_cgalmakefile" ;; - *) CGAL_MAKEFILE="$with_cgalmakefile" ;; -esac - -if test "$acx_cgal_found" == no; then - AC_MSG_CHECKING(CGAL_MAKEFILE) - - if test \! -z "$CGAL_MAKEFILE"; then - - if test -e "$CGAL_MAKEFILE"; then - tname=`mktemp /tmp/cgal_makefile_dsrXXXXXX` - -cat > $tname << _ACEOF -include $CGAL_MAKEFILE - -cppflags: - @echo \$(CGAL_CXXFLAGS) - -cxxflags: - @echo -ldflags: - @echo \$(CGAL_LDFLAGS) -_ACEOF - CGAL_CPPFLAGS="`make -s -f $tname cppflags`" - CGAL_CXXFLAGS="`make -s -f $tname cxxflags`" - CGAL_LDFLAGST="`make -s -f $tname ldflags`" - for i in $CGAL_LDFLAGST; do - if test `echo $i| grep -c ^-l`; then - CGAL_LIBS="$CGAL_LIBS $i" - else - CGAL_LDFLAGS="$CGAL_LDFLAGS $i" - fi - done - rm -f $tname - AC_MSG_RESULT(yes) - acx_cgal_found=yes - dnl echo CGAL_CPPFLAGS are $CGAL_CPPFLAGS - dnl echo CGAL_LDFLAGS are $CGAL_LDFLAGS - dnl echo CGAL_LIBS are $CGAL_LIBS - else - AC_MSG_RESULT(invalid) - AC_ERROR([CGAL_MAKEFILE defined, but the makefile does not exist.]) - fi - else - AC_MSG_RESULT(not defined) - fi -fi - -if test "$acx_cgal_found" == no; then - AC_CHECK_HEADER(CGAL/Exact_predicates_inexact_constructions_kernel.h, cgal_have_header=yes, cgal_have_header=no) - if test "$cgal_have_header" == yes; then - AC_CHECK_LIB(CGAL, main, cgal_have_lib=yes, cgal_have_lib=no) - if test "$cgal_have_lib" == no; then - save_LIBS="$LIBS"; LIBS="$LIBS -lgmp -lmpfr -lm" - AC_CHECK_LIB(CGAL, main, [CGAL_LIBS="-lCGAL -lgmp -lmpfr" - cgal_have_lib=yes], cgal_have_lib=no) - LIBS="$save_LIBS" - else - CGAL_LIBS="-lCGAL" - AC_CHECK_LIB(mpfr, main, [CGAL_LIBS="$CGAL_LIBS -lmpfr"]) - AC_CHECK_LIB(gmp, main, [CGAL_LIBS="$CGAL_LIBS -lgmp"]) - AC_CHECK_LIB(gmpxx, main, [CGAL_LIBS="$CGAL_LIBS -lgmpxx"]) - fi - - if test "$cgal_have_lib" == yes; then - acx_cgal_found=yes - fi - fi - if test "$acx_cgal_found" == yes; then - AC_CHECK_LIB(Core, main, [CGAL_LIBS="$CGAL_LIBS -lCore"]) - fi -fi - - - -AC_MSG_CHECKING(CGAL) -if test "$acx_cgal_found" == yes; then - AC_MSG_RESULT(yes); - $1 -else - AC_MSG_RESULT(no) - $2 -fi]) - Deleted: config/m4/ax_boost_base.m4 =================================================================== --- config/m4/ax_boost_base.m4 2008-12-03 01:41:53 UTC (rev 108) +++ config/m4/ax_boost_base.m4 2008-12-03 03:00:27 UTC (rev 109) @@ -1,198 +0,0 @@ -##### http://autoconf-archive.cryp.to/ax_boost_base.html -# -# SYNOPSIS -# -# AX_BOOST_BASE([MINIMUM-VERSION]) -# -# DESCRIPTION -# -# Test for the Boost C++ libraries of a particular version (or newer) -# -# If no path to the installed boost library is given the macro -# searchs under /usr, /usr/local, and /opt, and evaluates the -# $BOOST_ROOT environment variable. Further documentation is -# available at <http://randspringer.de/boost/index.html>. -# -# This macro calls: -# -# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS) -# -# And sets: -# -# HAVE_BOOST -# -# LAST MODIFICATION -# -# 2006-06-15 -# -# COPYLEFT -# -# Copyright (c) 2006 Thomas Porschberg <th...@ra...> -# -# Copying and distribution of this file, with or without -# modification, are permitted in any medium without royalty provided -# the copyright notice and this notice are preserved. - -AC_DEFUN([AX_BOOST_BASE], -[ -AC_ARG_WITH([boost], - AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is No) - it is possible to specify the root directory for boost (optional)]), - [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ac_boost_path="" - else - want_boost="yes" - ac_boost_path="$withval" - fi - ], - [want_boost="no"]) - -if test "x$want_boost" = "xyes"; then - boost_lib_version_req=ifelse([$1], ,1.20.0,$1) - boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` - boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` - boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` - boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` - if test "x$boost_lib_version_req_sub_minor" = "x" ; then - boost_lib_version_req_sub_minor="0" - fi - WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` - AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) - succeeded=no - - dnl first we check the system location for boost libraries - dnl this location ist chosen if boost libraries are installed with the --layout=system option - dnl or if you install boost with RPM - if test "$ac_boost_path" != ""; then - BOOST_LDFLAGS="-L$ac_boost_path/lib" - BOOST_CPPFLAGS="-I$ac_boost_path/include" - else - for ac_boost_path_tmp in /usr /usr/local /opt ; do - if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then - BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib" - BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" - break; - fi - done - fi - - CPPFLAGS_SAVED="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - - LDFLAGS_SAVED="$LDFLAGS" - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include <boost/version.hpp> - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ - AC_MSG_RESULT(yes) - succeeded=yes - found_system=yes - ],[ - ]) - AC_LANG_POP([C++]) - - - - dnl if we found no boost with system layout we search for boost libraries - dnl built and installed without the --layout=system option or for a staged(not installed) version - if test "x$succeeded" != "xyes"; then - _version=0 - if test "$ac_boost_path" != ""; then - BOOST_LDFLAGS="-L$ac_boost_path/lib" - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` - V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then - _version=$_version_tmp - fi - VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" - done - fi - else - for ac_boost_path in /usr /usr/local /opt ; do - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` - V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then - _version=$_version_tmp - best_path=$ac_boost_path - fi - done - fi - done - - VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" - BOOST_LDFLAGS="-L$best_path/lib" - - if test "x$BOOST_ROOT" != "x"; then - if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then - version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` - stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` - stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` - V_CHECK=`expr $stage_version_shorten \>\= $_version` - if test "$V_CHECK" = "1" ; then - AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) - BOOST_CPPFLAGS="-I$BOOST_ROOT" - BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib" - fi - fi - fi - fi - - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include <boost/version.hpp> - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ - AC_MSG_RESULT(yes) - succeeded=yes - found_system=yes - ],[ - ]) - AC_LANG_POP([C++]) - fi - - if test "$succeeded" != "yes" ; then - if test "$_version" = "0" ; then - AC_MSG_ERROR([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]]) - else - AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).]) - fi - else - AC_SUBST(BOOST_CPPFLAGS) - AC_SUBST(BOOST_LDFLAGS) - AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) - fi - - CPPFLAGS="$CPPFLAGS_SAVED" - LDFLAGS="$LDFLAGS_SAVED" -fi - -]) Deleted: config/m4/ax_boost_python.m4 =================================================================== --- config/m4/ax_boost_python.m4 2008-12-03 01:41:53 UTC (rev 108) +++ config/m4/ax_boost_python.m4 2008-12-03 03:00:27 UTC (rev 109) @@ -1,92 +0,0 @@ -##### http://autoconf-archive.cryp.to/ax_boost_python.html -# -# SYNOPSIS -# -# AX_BOOST_PYTHON -# -# DESCRIPTION -# -# This macro checks to see if the Boost.Python library is installed. -# It also attempts to guess the currect library name using several -# attempts. It tries to build the library name using a user supplied -# name or suffix and then just the raw library. -# -# If the library is found, HAVE_BOOST_PYTHON is defined and -# BOOST_PYTHON_LIB is set to the name of the library. -# -# This macro calls AC_SUBST(BOOST_PYTHON_LIB). -# -# In order to ensure that the Python headers are specified on the -# include path, this macro requires AX_PYTHON to be called. -# -# LAST MODIFICATION -# -# 2005-05-20 -# -# COPYLEFT -# -# Copyright (c) 2005 Michael Tindal <mt...@pa...> -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. -# -# As a special exception, the respective Autoconf Macro's copyright -# owner gives unlimited permission to copy, distribute and modify the -# configure scripts that are the output of Autoconf when processing -# the Macro. You need not follow the terms of the GNU General Public -# License when using or distributing such scripts, even though -# portions of the text of the Macro appear in them. The GNU General -# Public License (GPL) does govern all other use of the material that -# constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the -# Autoconf Macro released by the Autoconf Macro Archive. When you -# make and distribute a modified version of the Autoconf Macro, you -# may extend this special exception to the GPL to apply to your -# modified version as well. - -AC_DEFUN([AX_BOOST_PYTHON], -[AC_REQUIRE([AX_PYTHON])dnl -AC_CACHE_CHECK(whether the Boost::Python library is available, -ac_cv_boost_python, -[AC_LANG_SAVE - AC_LANG_CPLUSPLUS - CPPFLAGS_SAVE=$CPPFLAGS - if test x$PYTHON_INCLUDE_DIR != x; then - CPPFLAGS=-I$PYTHON_INCLUDE_DIR $CPPFLAGS - fi - AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[ - #include <boost/python/module.hpp> - using namespace boost::python; - BOOST_PYTHON_MODULE(test) { throw "Boost::Python test."; }]], - [[return 0;]]), - ac_cv_boost_python=yes, ac_cv_boost_python=no) - AC_LANG_RESTORE - CPPFLAGS=$CPPFLAGS_SAVE -]) -if test "$ac_cv_boost_python" = "yes"; then - AC_DEFINE(HAVE_BOOST_PYTHON,,[define if the Boost::Python library is available]) - ax_python_lib=boost_python - AC_ARG_WITH([boost-python],AS_HELP_STRING([--with-boost-python],[specify the boost python library or suffix to use]), - [if test "x$with_boost_python" != "xno"; then - ax_python_lib=$with_boost_python - ax_boost_python_lib=boost_python-$with_boost_python - fi]) - for ax_lib in $ax_python_lib $ax_boost_python_lib boost_python; do - AC_CHECK_LIB($ax_lib, main, [BOOST_PYTHON_LIB=$ax_lib break]) - done - AC_SUBST(BOOST_PYTHON_LIB) -fi -])dnl Deleted: config/m4/ax_python.m4 =================================================================== --- config/m4/ax_python.m4 2008-12-03 01:41:53 UTC (rev 108) +++ config/m4/ax_python.m4 2008-12-03 03:00:27 UTC (rev 109) @@ -1,101 +0,0 @@ -##### http://autoconf-archive.cryp.to/ax_python.html -# -# SYNOPSIS -# -# AX_PYTHON -# -# DESCRIPTION -# -# This macro does a complete Python development environment check. -# -# It recurses through several python versions (from 2.1 to 2.4 in -# this version), looking for an executable. When it finds an -# executable, it looks to find the header files and library. -# -# It sets PYTHON_BIN to the name of the python executable, -# PYTHON_INCLUDE_DIR to the directory holding the header files, and -# PYTHON_LIB to the name of the Python library. -# -# This macro calls AC_SUBST on PYTHON_BIN (via AC_CHECK_PROG), -# PYTHON_INCLUDE_DIR and PYTHON_LIB. -# -# LAST MODIFICATION -# -# 2004-09-20 -# -# COPYLEFT -# -# Copyright (c) 2004 Michael Tindal <mt...@pa...> -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. -# -# As a special exception, the respective Autoconf Macro's copyright -# owner gives unlimited permission to copy, distribute and modify the -# configure scripts that are the output of Autoconf when processing -# the Macro. You need not follow the terms of the GNU General Public -# License when using or distributing such scripts, even though -# portions of the text of the Macro appear in them. The GNU General -# Public License (GPL) does govern all other use of the material that -# constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the -# Autoconf Macro released by the Autoconf Macro Archive. When you -# make and distribute a modified version of the Autoconf Macro, you -# may extend this special exception to the GPL to apply to your -# modified version as well. - -AC_DEFUN([AX_PYTHON], -[AC_MSG_CHECKING(for python build information) -AC_MSG_RESULT([]) -for python in python2.4 python2.3 python2.2 python2.1 python; do -AC_CHECK_PROGS(PYTHON_BIN, [$python]) -ax_python_bin=$PYTHON_BIN -if test x$ax_python_bin != x; then - AC_CHECK_LIB($ax_python_bin, main, ax_python_lib=$ax_python_bin, ax_python_lib=no) - AC_CHECK_HEADER([$ax_python_bin/Python.h], - [[ax_python_header=`locate $ax_python_bin/Python.h | sed -e s,/Python.h,,`]], - ax_python_header=no) - if test $ax_python_lib != no; then - if test $ax_python_header != no; then - break; - fi - fi -fi -done -if test x$ax_python_bin = x; then - ax_python_bin=no -fi -if test x$ax_python_header = x; then - ax_python_header=no -fi -if test x$ax_python_lib = x; then - ax_python_lib=no -fi - -AC_MSG_RESULT([ results of the Python check:]) -AC_MSG_RESULT([ Binary: $ax_python_bin]) -AC_MSG_RESULT([ Library: $ax_python_lib]) -AC_MSG_RESULT([ Include Dir: $ax_python_header]) - -if test x$ax_python_header != xno; then - PYTHON_INCLUDE_DIR=$ax_python_header - AC_SUBST(PYTHON_INCLUDE_DIR) -fi -if test x$ax_python_lib != xno; then - PYTHON_LIB=$ax_python_lib - AC_SUBST(PYTHON_LIB) -fi -])dnl Added: config/m4/python.m4 =================================================================== --- config/m4/python.m4 (rev 0) +++ config/m4/python.m4 2008-12-03 03:00:27 UTC (rev 109) @@ -0,0 +1,62 @@ +## this one is commonly used with AM_PATH_PYTHONDIR ... +dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]]) +dnl Check if a module containing a given symbol is visible to python. +AC_DEFUN([AM_CHECK_PYMOD], +[AC_REQUIRE([AM_PATH_PYTHON]) +py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'` +AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1) +AC_CACHE_VAL(py_cv_mod_$py_mod_var, [ +ifelse([$2],[], [prog=" +import sys +try: + import $1 +except ImportError: + sys.exit(1) +except: + sys.exit(0) +sys.exit(0)"], [prog=" +import $1 +$1.$2"]) +if $PYTHON -c "$prog" 1>&AC_FD_CC 2>&AC_FD_CC + then + eval "py_cv_mod_$py_mod_var=yes" + else + eval "py_cv_mod_$py_mod_var=no" + fi +]) +py_val=`eval "echo \`echo '$py_cv_mod_'$py_mod_var\`"` +if test "x$py_val" != xno; then + AC_MSG_RESULT(yes) + ifelse([$3], [],, [$3 +])dnl +else + AC_MSG_RESULT(no) + ifelse([$4], [],, [$4 +])dnl +fi +]) + +dnl a macro to check for ability to create python extensions +dnl AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE]) +dnl function also defines PYTHON_INCLUDES +AC_DEFUN([AM_CHECK_PYTHON_HEADERS], +[AC_REQUIRE([AM_PATH_PYTHON]) +AC_MSG_CHECKING(for headers required to compile python extensions) +dnl deduce PYTHON_INCLUDES +py_prefix=`$PYTHON -c "import sys; print sys.prefix"` +py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"` +PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}" +if test "$py_prefix" != "$py_exec_prefix"; then + PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}" +fi +AC_SUBST(PYTHON_INCLUDES) +dnl check if the headers exist: +save_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES" +AC_TRY_CPP([#include <Python.h>],dnl +[AC_MSG_RESULT(found) +$1],dnl +[AC_MSG_RESULT(not found) +$2]) +CPPFLAGS="$save_CPPFLAGS" +]) Modified: configure.ac =================================================================== --- configure.ac 2008-12-03 01:41:53 UTC (rev 108) +++ configure.ac 2008-12-03 03:00:27 UTC (rev 109) @@ -12,33 +12,18 @@ AC_PROG_LIBTOOL() AC_MSG_CHECKING([for bovinity]) AC_MSG_RESULT([moo]) -AC_PROG_CXX() +AC_PROG_CC() AM_PATH_PYTHON([2.4]) -# -# find Libraries -# -ACX_CGAL([],[AC_MSG_ERROR([you need to have CGAL installed])]) -AC_SUBST(CGAL_CXXFLAGS) -AC_SUBST(CGAL_CPPFLAGS) -AC_SUBST(CGAL_LDFLAGS) -AC_SUBST(CGAL_LIBS) +AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)]) -PKG_CHECK_MODULES(GTKMM, gtkmm-2.4) -AC_SUBST(GTKMM_CFLAGS) -AC_SUBST(GTKMM_LIBS) - -AX_PYTHON() -AX_BOOST_BASE() -AX_BOOST_PYTHON() - # # output configuration files # AC_CONFIG_FILES([ Makefile src/Makefile - src/shapes/Makefile + src/demos/Makefile data/Makefile ]) Added: include/bitmask.h =================================================================== --- include/bitmask.h (rev 0) +++ include/bitmask.h 2008-12-03 03:00:27 UTC (rev 109) @@ -0,0 +1,149 @@ +/* + Bitmask 1.7 - A pixel-perfect collision detection library. + + Copyright (C) 2002-2005 Ulf Ekstrom except for the bitcount + function which is copyright (C) Donald W. Gillies, 1992. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef BITMASK_H +#define BITMASK_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <limits.h> +/* Define INLINE for different compilers. If your compiler does not + support inlining then there might be a performance hit in + bitmask_overlap_area(). +*/ +#ifndef INLINE +# ifdef __GNUC__ +# define INLINE inline +# else +# ifdef _MSC_VER +# define INLINE __inline +# else +# define INLINE +# endif +# endif +#endif + +#define BITMASK_W unsigned long int +#define BITMASK_W_LEN (sizeof(BITMASK_W)*CHAR_BIT) +#define BITMASK_W_MASK (BITMASK_W_LEN - 1) +#define BITMASK_N(n) ((BITMASK_W)1 << (n)) + +typedef struct bitmask +{ + int w,h; + BITMASK_W bits[1]; +} bitmask_t; + +/* Creates a bitmask of width w and height h, where + w and h must both be greater than 0. + The mask is automatically cleared when created. + */ +bitmask_t *bitmask_create(int w, int h); + +/* Frees all the memory allocated by bitmask_create for m. */ +void bitmask_free(bitmask_t *m); + +/* Clears all bits in the mask */ +void bitmask_clear(bitmask_t *m); + +/* Sets all bits in the mask */ +void bitmask_fill(bitmask_t *m); + +/* Flips all bits in the mask */ +void bitmask_invert(bitmask_t *m); + +/* Counts the bits in the mask */ +unsigned int bitmask_count(bitmask_t *m); + +/* Returns nonzero if the bit at (x,y) is set. Coordinates start at + (0,0) */ +static INLINE int bitmask_getbit(const bitmask_t *m, int x, int y) +{ + return (m->bits[x/BITMASK_W_LEN*m->h + y] & BITMASK_N(x & BITMASK_W_MASK)) != 0; +} + +/* Sets the bit at (x,y) */ +static INLINE void bitmask_setbit(bitmask_t *m, int x, int y) +{ + m->bits[x/BITMASK_W_LEN*m->h + y] |= BITMASK_N(x & BITMASK_W_MASK); +} + +/* Clears the bit at (x,y) */ +static INLINE void bitmask_clearbit(bitmask_t *m, int x, int y) +{ + m->bits[x/BITMASK_W_LEN*m->h + y] &= ~BITMASK_N(x & BITMASK_W_MASK); +} + +/* Returns nonzero if the masks overlap with the given offset. + The overlap tests uses the following offsets (which may be negative): + + +----+----------.. + |A | yoffset + | +-+----------.. + +--|B + |xoffset + | | + : : +*/ +int bitmask_overlap(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); + +/* Like bitmask_overlap(), but will also give a point of intersection. + x and y are given in the coordinates of mask a, and are untouched + if there is no overlap. */ +int bitmask_overlap_pos(const bitmask_t *a, const bitmask_t *b, + int xoffset, int yoffset, int *x, int *y); + +/* Returns the number of overlapping 'pixels' */ +int bitmask_overlap_area(const bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); + +/* Fills a mask with the overlap of two other masks. A bitwise AND. */ +void bitmask_overlap_mask (const bitmask_t *a, const bitmask_t *b, bitmask_t *c, int xoffset, int yoffset); + +/* Draws mask b onto mask a (bitwise OR). Can be used to compose large + (game background?) mask from several submasks, which may speed up + the testing. */ + +void bitmask_draw(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); + +void bitmask_erase(bitmask_t *a, const bitmask_t *b, int xoffset, int yoffset); + +/* Return a new scaled bitmask, with dimensions w*h. The quality of the + scaling may not be perfect for all circumstances, but it should + be reasonable. If either w or h is 0 a clear 1x1 mask is returned. */ +bitmask_t *bitmask_scale(const bitmask_t *m, int w, int h); + +/* Convolve b into a, drawing the output into o, shifted by offset. If offset + * is 0, then the (x,y) bit will be set if and only if + * bitmask_overlap(a, b, x - b->w - 1, y - b->h - 1) returns true. + * + * Modifies bits o[xoffset ... xoffset + a->w + b->w - 1) + * [yoffset ... yoffset + a->h + b->h - 1). */ +void bitmask_convolve(const bitmask_t *a, const bitmask_t *b, bitmask_t *o, int xoffset, int yoffset); + +/* Find the closest point to (x,y) with mask[x,y] not set */ +void bitmask_find_closest(const bitmask_t *mask, int * x, int * y); + +#ifdef __cplusplus +} /* End of extern "C" { */ +#endif + +#endif Added: include/mask.h =================================================================== --- include/mask.h (rev 0) +++ include/mask.h 2008-12-03 03:00:27 UTC (rev 109) @@ -0,0 +1,23 @@ +#include <Python.h> +#include "bitmask.h" + +#define PYGAMEAPI_MASK_NUMSLOTS + +typedef struct { + PyObject_HEAD + bitmask_t *mask; +} PyMaskObject; + +#define PyMask_AsBitmap(x) (((PyMaskObject*)x)->mask) + +#ifndef PYGAMEAPI_MASK_INTERNAL + +#define PyMask_Type (*(PyTypeObject*)PyMASK_C_API[0]) +#define PyMask_Check(x) ((x)->ob_type == &PyMask_Type) + + + +#endif /* !defined(PYGAMEAPI_MASK_INTERNAL) */ + +static void* PyMASK_C_API[PYGAMEAPI_MASK_NUMSLOTS] = {NULL}; + Property changes on: src ___________________________________________________________________ Modified: svn:ignore - Makefile Makefile.in *.pyc + Makefile Makefile.in *.pyc .libs .deps Modified: src/Makefile.am =================================================================== --- src/Makefile.am 2008-12-03 01:41:53 UTC (rev 108) +++ src/Makefile.am 2008-12-03 03:00:27 UTC (rev 109) @@ -1,24 +1,23 @@ -SUBDIRS = shapes +SUBDIRS = demos +INCLUDES = ${PYTHON_INCLUDES} -I${top_srcdir}/include +pkgpyexec_LTLIBRARIES = maskutils.la +maskutils_la_SOURCES = maskutils.c +maskutils_la_LDFLAGS = -avoid-version -module + pkgpython_PYTHON = \ - circles.py \ - collision.py \ drag.py \ - draw.py \ editor.py \ - event.py \ files.py \ globals.py \ level.py \ menu.py \ parts.py \ - penode.py \ pen.py \ physics.py \ vector.py - clean-local: rm -f *.pyc Property changes on: src/demos ___________________________________________________________________ Modified: svn:ignore - *.pyc + *.pyc Makefile Makefile.in Added: src/maskutils.c =================================================================== --- src/maskutils.c (rev 0) +++ src/maskutils.c 2008-12-03 03:00:27 UTC (rev 109) @@ -0,0 +1,91 @@ +#include <Python.h> +#include <mask.h> + +static const char DOC_CONVOLVE[] = +"Return the convolution of self with another mask. \n" +" \n" +"convolve(a, b, outputmask = None, offset = (0,0)): return Mask \n" +" Returns a mask with the (i-offset[0],j-offset[1]) bit set if shifting a \n" +" so that it's lower right corner pixel is at (i,j) would cause it to overlap \n" +" with a. \n" +" \n" +" If outputmask is not None, then the output is drawn onto outputmask and \n" +" outputmask is returned. Otherwise a mask of size a.size() + b.size() - (1,1)\n" +" is created. "; + +static const char DOC_FINDCLOSEST[] = +"Find the closest cleared position to a given bit. \n" +" \n" +"find_closest(mask, (x,y)): return point \n" +" Returns (x',y') closest to (x,y) such that either (x',y') is outside of the \n" +" bounds of mask, or mask.get_at((x',y')) is False. "; + +static PyObject* maskutils_convolve (PyObject*, PyObject*); +static PyObject* maskutils_find_closest (PyObject*, PyObject*); + +static PyMethodDef maskutils_methods[] = { + {"convolve", maskutils_convolve, METH_VARARGS, DOC_CONVOLVE}, + {"find_closest", maskutils_find_closest, METH_VARARGS, DOC_FINDCLOSEST}, + + {NULL, NULL, 0, NULL} +}; + +void +initmaskutils() +{ + PyInitModule ("maskutils", maskutils_methods); +} + +/* +** Implementations ************************************************************* +*/ + +static +PyObject * +maskutils_convolve(PyObject *self /* Not used */, PyObject *args) +{ + PyObject *aobj, *bobj, *oobj = Py_None; + bitmask_t *a, *b, *o; + int xoffset = 0, yoffset = 0; + + if (!PyArg_ParseTuple (args, "O!O!|O(ii)", &PyMask_Type, &aobj, &PyMask_Type, &bobj, &oobj, &xoffset, &yoffset)) + return NULL; + + a = PyMask_AsBitmap(aobj); + b = PyMask_AsBitmap(bobj); + + if (oobj == Py_None) { + PyMaskObject *result = PyObject_New(PyMaskObject, &PyMask_Type); + + result->mask = bitmask_create(a->w + b->w - 1, a->h + b->h - 1); + oobj = (PyObject*) result; + } + else + Py_INCREF(oobj); + + o = PyMask_AsBitmap(oobj); + + bitmask_convolve(a, b, o, xoffset, yoffset); + return oobj; +} + +static +PyObject * +maskutils_find_closest(PyObject *self /* Not used */, PyObject *args) +{ + PyObject * mobj; + bitmask_t * mask; + int x, y; + + if (!PyArg_ParseTuple (args, "O!(ii)", &PyMask_Type, &mobj, &x, &y)) + return NULL; + + mask = PyMask_AsBitmap (self); + bitmask_find_closest (mask, &x, &y); + + return Py_BuildValue ("(ii)", x, y); +} + +/* +** vim: ts=4 sw=4 cindent cino=\:0 +*/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-03 01:41:55
|
Revision: 108 http://pen.svn.sourceforge.net/pen/?rev=108&view=rev Author: mdgeorge Date: 2008-12-03 01:41:53 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Initial draft of a description of the D&D system Added Paths: ----------- doc/dragging.latex Added: doc/dragging.latex =================================================================== --- doc/dragging.latex (rev 0) +++ doc/dragging.latex 2008-12-03 01:41:53 UTC (rev 108) @@ -0,0 +1,38 @@ +\documentclass[12pt]{article} + +\author{Michael George \\ \texttt{mdg...@cs...}} +\title{Implementing Collision-Avoiding Drag and Drop} +\date{November 10, 2008} + +\begin{document} +\maketitle + +\abstract{We describe a method for implementing drag-and-drop of irregularly +shaped rigid 2D objects while maintaining the invariant that no two of them +overlap. Our method allows users to naturally and easily manipulate adjacent +objects. We also describe our handling of stretched rope-like objects.} + +\section{Introduction} + +\section{Dragging Solid Objects} +\section{Dragging Rope-like Objects} +In addition to solid objects, Pen has support for rope-like objects, including +string, rubber bands, and wires. Like rigid objects, we want to maintain the +invariant that these objects don't overlap, but there are a few important +differences. First, ropes can change shape during dragging, as they grow longer +or shorter, or wrap around other objects. Second, while the result of dragging +a rigid object depends only on the point where it is dropped, dragging rope-like +objects depends very much on the path along which they are dragged. + +We have decided to support only ``stretched'' ropes --- ropes that + +\subsection{Interaction between ropes and rigid objects} + +\section{Implementation} +\section{Vector-based algorithms} + +\end{document} + +% +% vim: tw=80 nonumber +% This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mdg...@us...> - 2008-12-03 01:06:48
|
Revision: 107 http://pen.svn.sourceforge.net/pen/?rev=107&view=rev Author: mdgeorge Date: 2008-12-03 01:06:44 +0000 (Wed, 03 Dec 2008) Log Message: ----------- Replacing symlinks. Added Paths: ----------- COPYING INSTALL Added: COPYING =================================================================== --- COPYING (rev 0) +++ COPYING 2008-12-03 01:06:44 UTC (rev 107) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. Added: INSTALL =================================================================== --- INSTALL (rev 0) +++ INSTALL 2008-12-03 01:06:44 UTC (rev 107) @@ -0,0 +1,236 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free +Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. (Caching is +disabled by default to prevent problems with accidental use of stale +cache files.) + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You only need +`configure.ac' if you want to change it or regenerate `configure' using +a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c89 CFLAGS=-O2 LIBS=-lposix + + *Note Defining Variables::, for more details. + +Compiling For Multiple Architectures +==================================== + +You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not support the `VPATH' +variable, you have to compile the package for one architecture at a +time in the source code directory. After you have installed the +package for one architecture, use `make distclean' before reconfiguring +for another architecture. + +Installation Names +================== + +By default, `make install' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + +Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + +There may be some features `configure' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +Sharing Defaults +================ + +If you want to set default values for `configure' scripts to share, you +can create a site shell script called `config.site' that gives default +values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). Here is a another example: + + /bin/bash ./configure CONFIG_SHELL=/bin/bash + +Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent +configuration-related scripts to be executed by `/bin/bash'. + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |