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

[pygame] Surfarray slicing



Pygame is fabulous, it's great fun fooling around with and I really like the
way it is written, it is very easy to work with. Great stuff in other words.

Enough praise, let's get down to the surfarray.
What's not so easy is getting the hang of the slicing, especially as I've
got a brain bug about the first index should be the row index and the second
should be line index. Too much C++ I guess.

What I really wondered about is the surfarray tutorial, it says that to flip
you can do like this:
flipped = imgarray[:,-1:0:-1]
But on my machine (and I guess most others too) this slices away the first
line in the bitmap.
After some trying and failing the correct way to flip across one dimention
of the bitmap is:
flipped = imgarray[:, ::-1] # for horizontal mirroring (up down)
flipped = imgarray[::-1, :] # for vertical mirroring (left right), Great for
making versions of a bitmap with the figure turning the other way.

Otherwise the tutorials are very nice and makes it real easy to get to grips
with pygame. Now I have to get back to hacking pygame Python.

PS: What is the point of the pygame.surfarray.array_colorkey(<surface>)
factory method any way?. It seems to create a mask of the visible portions
of the bitmap.




____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org