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

Re: [pygame] Native PyGame method for automatically scaling inputs to a surface resolution?

On Tue, Sep 27, 2011 at 3:39 PM, Mac Ryan <quasipedia@xxxxxxxxx> wrote:
On Tue, 27 Sep 2011 11:28:34 -0400
Christopher Night <cosmologicon@xxxxxxxxx> wrote:

> How can I use your system to draw a rectangle of a solid color onto a
> surface? With the regular pygame system, I would use surf.fill and
> pass it a Rect. If your system doesn't recognize rectangles of any
> sort, how can I do this? Feel free to show me in pseudocode how I
> could do it.

I suppose you mean something like:

>>> Surface.fill(WHITE, myrect)

is it?

If this is the case, the rectangle would be scaled (so a rect of
100x200 would be scaled to a rect of 10x20 assuming scale=0.1). The
general idea would be: any argument to a surface method whose purpose
is to indicate a measure ((x,y) tuples, explicit width/height or tuples)
would be scaled. Any other parameter whose purpose is not defining
coordinates (colours, flags, surfaces...) wouldn't.

Is myrect supposed to be a regular pygame.Rect? One big problem with that is that pygame.Rect properties are coerced to integers. This makes sense for a rectangle that describes a set of pixels, not so much for a rectangle that's supposed to describe a region in world coordinates.

Either way, that's fine, and not very suprising. That's exactly what I had in mind. So I really don't see why you weren't able to answer my original question. Let me try asking it one more time.

You say that a 100x200 rect would be scaled to 10x20 pixels. Yes, obviously, this makes sense. What would a 104x200 rect be scaled to? 10x20 pixels? Or 11x20 pixels? Or would it depend on the position of the rect? (Remember that in addition to height and width, rectangles also have positions, ie left and top. You can't just say "draw a 10x20 rectangle", you also have to say where to draw it. This is relevant to the question, so try to keep it in mind.)