[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] keep-aspect scale



So
you have destRect=(w,h)
origImage=(wo,ho)

lets take

alphaw=w/w0
alphah=h/h0
alpha_worst=min(alphaw,alphah)

and scale the original picture par factor alphaworst

and center it

Guillaume




On Tue, 17 Jul 2001, Per Wigren wrote:

> Hi!
>
> A simple question:
> I have a Rect (inside of a frame) that can be of any size
> and I have another Rect (image) that also can be of any
> size. I want to scale the image to be as big as possible
> inside the frame while keeping aspectratio so it doesn't
> get too wide or too tall.
>
> Any tips?
>
> Regards
> Per Wigren
>
> ____________________________________
> pygame mailing list
> pygame-users@seul.org
> http://pygame.seul.org
>

____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org