[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, 27 Sep 2011 15:53:03 -0400
Christopher Night <cosmologicon@xxxxxxxxx> wrote:

> 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.

Sorry. The good news is: this time I understood what you mean. (I
think!) :)

> 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.)

Since we are working in raster rather than in vectorial, I
would first convert the rectangle in coordinates, and then scale,
possibly rounding to the nearest integer.

The idea is that position (x=4) + (width=14) = right(18) -- > scaled: 2
and not x=4 --> scaled: 0 + width=14 --> scaled 1 --> scaled_sum: 1.
Which I suppose was the point you were trying to make in the first
post of yours (maybe part of the reason why I did not get it is that I
never used this before: I only needed to blit sprites on images in my
code).

Does this answer your question? Usual disclaimer: I did not think this
deeply, I'm very open to alternative ways of implementing it. :)

/mac