realbasic-games
[Top] [All Lists]

Re: Drawing Rotated Image

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Drawing Rotated Image
From: Andrew Krebs <andykr at gmail dot com>
Date: Mon, 26 Sep 2005 21:10:36 -0500
Delivered-to: realbasic-games at lists dot realsoftware dot com
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=bcK++OOZyfiDZJILLQ918EgVdsIofLT5vA9omkcijFaefccY3Clyx9jui/qCviQwgyop+1Z7PJ7b0ZoIDt324S7NjXci7KgNYj5ZOB56Snem/JyIi6Tb9zMSTriAN9tKfae02w0Nbw2PsTMorMeQE83RSqrMMIVAPMteMqsVgas=
References: <496bf51a05092019337180466a at mail dot gmail dot com> <a06200704bf567b8c2eb0 at 10 dot 0 dot 1 dot 4> <496bf51a0509211826355b31bb at mail dot gmail dot com> <a06200702bf57caa5de4d at 10 dot 0 dot 1 dot 4> <496bf51a050922191027900e59 at mail dot gmail dot com> <a06200703bf59bdf0dd80 at 10 dot 0 dot 1 dot 4> <0809ade5daadaea777c60fe4a3c4e71e at rpsystems dot net> <a06200710bf59cb3dfb3b at 10 dot 0 dot 1 dot 4> <071a7167dbb0422dc47129a40a7a1e57 at rpsystems dot net> <023193F6-ACBD-4106-B8C2-7D2F2D75FB44 at mac dot com>
This is exactly what I was going for.  Thanks Toon!

On 9/26/05, Toon Van Acker <toon dot van dot acker at mac dot com> wrote:
> You can use this bit of code to calculate the full rectangular (or
> whatever I'm supposed to call it) size of the picture, and the x and
> y coordinate of where the Object2D should be so the edges aren't
> clipped off.
>
> dim w, h, newX, newY, newW, newH, rotation, cosR, sinR as double
>
> w = imageWidth / 2.0
> h = imageHeight / 2.0
>
> cosR = cos(rotation)
> sinR = sin(rotation)
>
> newX = max( abs(cosR * w - sinR * h), abs(cosR * w + sinR * h) )
> newY = max( abs(sinR * w + cosR * h), abs(sinR * w - cosR * h) )
>
> newW = newX * 2.0
> newH = newY * 2.0
>
> Rotation is in radians and imageWidth and imageHeight are well... the
> width and height of the image.
> (This is taken out from the middle of other code. It should work, but
> if it doesn't, tell me. Also, you might have to handle rounding from
> double to integer to make sure a pixel isn't accidently clipped off,
> but I never really needed that myself so it isn't in here. A ceil
> (newX) and ceil(newY) would probably be easiest.)
>
>
> ---
> Toon Van Acker <toon dot van dot acker at mac dot com>
>               <http://homepage.mac.com/barthold.van.acker/realbasic/>
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
>
> Search the archives of this list here:
> <http://support.realsoftware.com/listarchives/lists.html>
>


--
Andrew Krebs
andykr at gmail dot com
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>