Bill DeWitt

unread,
Dec 2, 2015, 9:17:03 AM12/2/15
to MIT App Inventor Forum
I searched for this topic and although I found a couple of comments I didn't find a clear example of how to do it. So when I finally figured it out, I thought I should post it with a good title. If there is a better place or method to do this feel free to let me know.

The Design is just a Text box, a Canvass, and a clock. This is only set up to draw the seconds, as an example, but MinuteAngle and HourAngle are easy to calculate in a similar fashion and draw with different sized lines. What you do is multiply the seconds by 6 to get 360 ticks, and you subtract them from 180 to get the angle from -180 to 180. Then you ask for the sin and cos of that angle to make your x and y for the end of the line.


Scott Ferguson

unread,
Dec 2, 2015, 9:24:59 AM12/2/15
to MIT App Inventor Forum
Thanks for sharing this.
A clock is not a simple thing to code as you know :-)
I use sin and cos often with the Canvas for moving and drawing stuff.
It's great fun...
---
sf
Reply all
Reply to author
Forward
0 new messages