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

Re: [pygame] PixelArray question



On, Fri Aug 24, 2007, Lenard Lindstrom wrote:

> Marcus von Appen wrote:
>> On, Thu Aug 23, 2007, Lenard Lindstrom wrote:

[...] 
>> The integration of slicing, mapping and other features I mentioned
>> before surely might look superfluous to those who extensively use
>> numeric and numpy to do fast (or complex) operations on the pixels of a
>> surface. It allows you however to have a small feature subset which -
>> for most easy operations - allows you to stay independent of numpy and
>> numeric thus not requiring users to install them either.
>> 
>>   
> 
> Reducing the need for surfarray is good. I just wonder if PixelArray is the 
> only place where slicing and mapping could be done. Slicing, for instance, 
> could be a feature of the Surface fill and blit methods. They would take 
> optional x and y step values. The blit method could also have additional 
> blend options for color/alpha channel copying.

Interesting point. The API change for it however would not be very
intuitional, if we want to maintain backwards compatibility:

             Surface.fill(color, rect=None, sliceargs=None)
 
Making the rect exchangeable with slicing arguments would break filling
subareas limited by a rect. I'm not sure, what would be a good API, but
stuff like 

      Surface.fill(color, rect, [x:x1, ::2])
      Surface.fill(color, rect, [x:x1:3])
      Surface.fill(color, rect, [::2, 3:6])

looks a bit odd to me. Blitting makes it even more complex with a source
surface, rect arguments blending and slicing:

         Surface.blit(source, dest, rect, flags, blendflags, [...])
         ...

>> My intention never was (and surely will never be) to implement a whole
>> numeric/numpy replacement, not at last because both (especially numpy)
>> have a great depth (numpy for example offers bindings to lapack, one of
>> the fastest math libraries available), which to implement would go too 
>> far. 
>>   
> 
> An whole Numeric/numpy replacement would be overkill. But as it stands, 
> there is just no other way to do basic effects like shadows without them.

That depends on the effect, you want to have. Simple effects could be
done with PixelArray without any problems, complex effects are
definitely out of its scope.

Regards
Marcus

Attachment: pgpltlOd2xJP1.pgp
Description: PGP signature