Computer Science Canada
[Tutorial] Rotating Pictures Based on Mouse Position
|Author:||wierdo1111 [ Sun Mar 24, 2013 12:26 am ]|
|Post subject:||[Tutorial] Rotating Pictures Based on Mouse Position|
This will cover how to rotate pictures based on it's position relative to the mouse.
Before I start somethings to note; I have included the picture i used as an attachment, your picture must have some padding or some of it may get clipped
during the rotation unless your picture is just a circle like mine, and to get rid of the white border you can just use picMerge and Pic.SetTransparentColor.
Have your basic variables You can assume what they are, and specifying what image to use.
Here is some code that will let you move your picture around, I'm not going to talk about how it works.
Now whats happening is that we are getting an x and a y value based off the position of the center of the image relative to the mouse position.
Based on the combination of these x and y values being positive or negative we can determine the quadrant the mouse is in.
Using this info we can use sohcahtoa and related angles to find the theta (angle), so RA = arctand (|opp|/|adj|) or so RA = arctand (|y|/|x|),
following that up with, then theta can be found using some related angle knowledge.
Now all that's left is to make pic1 become pic rotated by the angle we got from before, draw it, then free pic1 or Turing will eventually crash.
The parameters for Pic.Rotate are (variable of pic to rotate, angle (must be integer), pivot point or point of rotation in pic)