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

Re: [pygame] subsurfaces outside of their parents



------ Original Message ------
> No, it needs to appear to be 20x20 because the whole idea is to have
> whether or not its off the surface to be transparent. This makes it so
> code can draw 0, 0, --> 20, 20 on the subsurface without having to
> compensate for being off the surface and such... I want this feature,
> personally, for a widget drawing system involving subsurfaces.
> 
That sounds wrong - the whole idea of subsurface is that it shares pixels with
it's parent surface, right? So are you hoping this subsurface call to grow the
parent? are you hoping it would partially share pixels with the parent and
have some of it's own pixels? are you hoping it would have all it's own pixels
and none shared? are you hoping it would just return a false width and height
and really only have shared pixels on the area that did overlap the parent?

...Because none of those 4 behaviors are something I'd want pygame to do and I
can't think of any other way to resolve the surface having the size you asked
for in the case you describe. 

...I really like the modification Pete described though - I agree that it
seems to be the right thing, and aside from the fact that nothing would be
drawn to the area that didn't exist on the parent (which seems like the right
thing to me), it appears to satisfy your requirement "to have whether or not
its off the surface to be transparent" in that you can draw from 0,0 to 20,20
and have the destination be where you said it should be.


> On 11/8/05, Peter Shinners <pete@xxxxxxxxxxxx> wrote:
> > On Tue, 2005-11-08 at 00:46 -0500, Forest Darling wrote:
> > > I would like to see a feature where you could have a subsurface take a
> > > rect that covered an area that was partially or completely outside
> > > parent surface's rect...
> > >
> > > s = pygame.Surface((100, 100))
> > > sub = s.subsurface(Rect(-10, -10, 20, 20)
> >
> > This has been suggested before. If it is ok for the returned subsurface
> > to be smaller than requested, this would be easy to implement. The
> > surface would still use the right offset so that drawing to it would
> > appear where you expected.
> >
> > sub = s.subsurface(Rect(-10, -10, 20, 20)
> > print sub.get_size()
> > (10, 10)
> >
> > I'll think about it some more, it can lead to strange cases, but for the
> > most part I think it would do the right thing.
> >
> >
>