Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jbrave
Channel Surfer

Drawing to Rotating Coordinates...

If I am drawing to the center of the screen, say 640/360 and I rotate the coordinate system by 1 degree, it appears that the axis of rotation is 0,0. Does anyone know what mathematical calculation would allow me to keep an object in the center of the screen while rotating the coordinate system? clearly x and y have to change in order for the object to stay in its exact location, since the location of 640,360 has now changed... but what might the formula be? I'm pretty sure it would be some trigonometry, but not sure what.

any suggestions?
Screenshades: The first Screensaver for Roku2!
Musiclouds: The best free internet music, on your Roku!
Ouroborialis: Psychedelic Screensaver for Roku!
0 Kudos
1 REPLY 1
renojim
Community Streaming Expert

Re: Drawing to Rotating Coordinates...

You have to use TargetTranslation to move the origin to 640,360. This still won't do what you want if you want to rotate the object around its midpoint. If that's what you want, you have to set the TargetRect values to minus half the width and height. For example, the screensaver for Video Poker rotates the cards like this:

item = [{ url:url,TargetRect:{x:Int(-cardw/2), y:Int(-cardh/2), w:cardw, h:cardh},TargetRotation:r,TargetTranslation:{x:x,y:y}}]
canvas.SetLayer(1,item)

r, x, and y are random

By the way, if you're rotating a square and the corners are no longer 90 degrees, it's you display that's the problem. Also, it's hard to make a square maintain it's aspect ratio on an SD screen since everything has to be stretched slightly horizontally to maintain aspect ratio. On an HD screen, a square should always be a square.

-JT
Roku Community Streaming Expert

Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.

I am not a Roku employee.
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.