[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] 1.2 on the horizon



Fantastic, that's what I wanted and more.

Time to work through the Numeric Docs I reckon.

Joc

--- Pete Shinners <shredwheat@mediaone.net> wrote:
> > ...
> > if pygame.draw.lines accepted an offset
> > to start drawing from. This would mean
> > that I could have a vector shape class
> > that could move about the screen without
> > having to rewrite the points array for
> > simple translation. Rotation would be
> > nice as well, but that would just be
> > pushing it ;)
> 
> 
> try using Numeric arrays to store your point
> coordinates.
> then it becomes very easy to transform your points
> around.
> (in fact, Numeric comes with some matrix transform
> tools
> so you should be able to do rotations pretty easy
> with
> that (although i've never tried that really))
> 
> anyways, instead of a python list or tuple to store
> your
> points, we use a Numeric array. but if you want to
> just
> keep your points in a list and addon a quicky
> transform
> you can. Numeric functions can accept lists
> (although 
> they'll never be as quick as using Numeric arrays)
> 
> 
> import Numeric
> import math
> 
> def drawlinesoffset(points, offset):
>     newpts = Numeric.add(points, offset)
>     pygame.draw.lines(newpts)
> 
> def buildrotatematrix(angle):
>     "warning, poor math off the top of pete's head"
>     s, c = sin(angle), cos(angle)
>     return Numeric.array(((s,c),(c,s)))
> 
> def drawlinesrotated(points, angle):
>     rot = buildrotatematrix(angle)
>     newpts = Numeric.matrixmultiply(points, rot)
>     pygame.draw.lines(newpts)
> 
> 
> 
> tada. that should all work for you, assuming my
> early morning
> logic hasn't failed me on the rotation matrix :]
> 
> also, just so you know, you are free to pass
> floating point
> numbers into the draw functions. they just get
> truncated to
> integers.
> 
> 
> 
> ____________________________________
> pygame mailing list
> pygame-users@seul.org
> http://pygame.seul.org


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org