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

Re: [pygame] Questions about surface with alpha channel



Interesting to see that Surface.fill has gained new abilities. Having set_alpha do a blanket fill would be useful. But how does this affect the relationship with the complementary get_alpha? Should get_alpha still return None in this case? Does it make sense for a per-pixel alpha surface to even have a blanket alpha value since it is ignored? Practically speaking, would anything break if get_alpha always returns None on a per-pixel alpha surface and can this be useful?

René Dudfield wrote:
Or maybe Surface.set_alpha() could be told how to act the right way
when the surface has per pixel alpha.

That would probably be the more friendly way.  I've seen quite a few
people try to use .set_alpha on per pixel images.

Although under the hood set_alpha could use a
Surface.fill((0,0,0,255), BLEND_CHANNEL_A) - which would only fill the
alpha channel.


On 6/21/07, Lenard Lindstrom <len-l@xxxxxxxxx> wrote:
With pygame.surfarray

pygame.surfarray.pixels_alpha(surface)[...] = 0

Of course one needs Numeric.


René Dudfield wrote:
> I can't think of a way to set the alpha by itself, without setting the
> RGB.
>
> Say I wanted to set the alpha ONLY with fill() then I don't think I
> can do it.
>
> Is there some way you could do that by passing mask to a blit call?
>
> If there's no way to do it already, then perhaps we could create a
> separate function which only acts on one channel at once.  eg, only R,
> or only A.  This could be added as a 'special flag' the same way the
> BLEND_ADD etc have recently been added to Surface.fill()
>
> Or maybe I'm forgetting some way?
>
>
> On 6/21/07, John Eriksson <john@xxxxxxxxxxxx> wrote:
>> Hi,
>> I have a couple of questions regarding surfaces with an alpha channel.
>>
>> 1. Is this the correct way of creating an surface with an
>> alhpa-per-pixel channel?
>> surface = pygame.Surface((w, h), pygame.SRCALPHA)
>>
>> 2. How do you clear an alpha channel surface? I guesss you can't use the
>> fill method?
>>
>> Best Regards
>> /John
>>
>>
>>
>>


--
Lenard Lindstrom
<len-l@xxxxxxxxx>




--
Lenard Lindstrom
<len-l@xxxxxxxxx>