[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] blitting from-to surface with per-pixel alpha doesn't work...



On Mon, 2005-11-28 at 11:29 +0100, D. Gyimesi wrote:
> Anyway, the reason why I did choose the intermediate layer is that I
> have a number of layers that I should rotate around different pivots. 
> If you take a look to the screenshot that show my sucking with
> "compositing" ( http://www.cab.u-szeged.hu/~h370556/tc_shot.zip ) then
> you can understand what I'm talkin' about.

Each time you rotate an image you lose a little quality. You should get
the best performance and quality by blitting each part directly to the
target in the final position.

What you are describing is traditionally handled with a transform stack.
(Also called a matrix stack). The position and rotation of each piece is
described with a transformation matrix. In this case a 3x3 matrix will
be needed for 2D rotation and translation. The good thing is you can
then combine multiple transforms into a single matrix.

The unfortunate thing is that pygame has no support for these transform
matrices. There are a few good matrix libraries out there to start from.
You will want to find one that breaks the matrix back down into its
rotation and movement parts.

Hopefully that doesn't sound too scary. It's actually easier to use than
to describe. Transform stacks are more commonly used in 3D programs,
OpenGL has built in support for them. But its a nice common operation
for moving "parented" objects around. And you don't really need to
understand all the math to make basic use of them.