here is the CLOCKFACE script...coded in 3 MINUTES...17 LINES of CODE

Geoff Canyon geoff at runrev.com
Mon May 30 23:47:21 EDT 2005


On May 30, 2005, at 4:37 PM, Dennis Brown wrote:

> That is a good point.  I tested it out, and the useless "set angle"  
> results in about 70ms of wasted time every second (7% CPU).  I am  
> surprised it is so high.  Doing the test and skipping it is a  
> thousand times faster.  I fixed up the script as my own exercise  
> for the student.  You can see the time lag slightly when the  
> computer is busy with something else, like loading a web page.
>
> Note: the angle calculations had to be changed to match what the  
> angle returned for these graphics.  The clock is in  my user space  
> (see3d).  It takes a licking, but keeps on ticking...

Four times faster still is comparing to a local variable rather than  
to the startAngle of the graphics. It adds a few lines of code  
though. It would appear that my web hosting company is down at the  
moment, so the script will have to suffice:

on openCard
   setTime
end openCard

local sHourAngle -- the angle for the hour hand
local sMinuteAngle -- the angle for the minute hand

on setTime
   put word 1 of the long time into T
   put T && the long seconds into fld "time"
   set the itemDelimiter to ":"
   get 90 - (30 * item 1 of T) - trunc((item 2 of T) / 2)
   if it is not sHourAngle then
     put it into sHourAngle
     set the startangle of grc "hour" to sHourAngle
   end if
   get 90 - (6 * item 2 of T) - trunc((item 3 of T) / 10)
   if it is not sMinuteAngle then
     put it into sMinuteAngle
     set the startangle of grc "minute" to sMinuteAngle
   end if
   set the startangle of grc "second" to 90 - (6 * item 3 of T)
   send "setTime" to me in (1 - (the long seconds mod 1)) seconds
end setTime


More information about the use-livecode mailing list