Sunday, July 22, 2007

Rectangle Operations

The Rect class in Pygame is very useful for normal screen based apps. It doesn't work so well in OpenGL code, which uses a left handed coordinate system (a positive Y axis). Also, pygame.Rect uses integers for internal coordinates, which means you cannot use it at sub-pixel accuracy.

So... I wrote a new Rect class to fix these problems.
easy_install rect

>>> from rect import Rect
>>> r = Rect((0,0,10,10))
>>> r.bottom
Also included in the rect package is a quadtree spatial index, and a rectangle-bin packing function, useful for packing sprite strips, pre-rendered font characters or perhaps tile maps.

Update: Oops, a link would be helpful :-)


Richard Jones said...

Rect at the 'Shop


inactivist said...

Cool stuff.

I notice that the source code repo seems to have gone missing.

Is there a new code hosting location? A bit of searching doesn't turn up anything...

I realize I can get the sources from the package but I was just wondering... =)

Popular Posts