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

Geoff Canyon geoff at runrev.com
Thu Jun 9 10:09:22 EDT 2005


I considered this option and went the other way for a couple reasons.  
It seemed more natural to leave it in one handler. It takes more  
lines of code to split the handlers up. I wonder what the overhead is  
to have three messages pending as opposed to one.

That said, I think this is the way to go. It solves the display-isn't- 
right-for-up-to-two-minutes problem, and the implementation is about  
as clean as can be.

I think we may finally be close to the optimum solution.

gc

On Jun 8, 2005, at 9:35 AM, Dennis Brown wrote:

> Geoff,
>
> Your new idea gave me an idea.  Make three handlers --one for each  
> hand (I hope I got the hour math straight)
> You can find it in my user space (see3d).
>
> Dennis
>
> on openCard
>   setSeconds; setMinutes; setHours
> end openCard
>
> on setSeconds
>   send setSeconds to me in 1-(the long seconds mod 1) seconds
>   put the long time into fld "Time" --8:13:15 AM
>   set the angle of grc "Second" to 450 - ((the seconds * 6) mod 360)
> end setSeconds
>
> on setMinutes
>   send setMinutes to me in 10-(the seconds mod 10) seconds --10  
> seconds/degree
>   set the angle of grc "Minute" to 450 - ((the seconds mod 3600)  
> div 10)
> end setMinutes
>
> on setHours
>   send setHours to me in 120-(the seconds mod 120) seconds --120  
> seconds/degree
>   set itemdel to ":"
>   set the angle of grc "Hour" to 450-(60*item 1 of the time mod 12)  
> - ((the seconds mod 3600) div 120) --It's UTC if you just use the  
> seconds here
> end setHours
>
> On Jun 8, 2005, at 10:04 AM, Geoff Canyon wrote:
>
>
>> I came up with a radically different approach. Several iterations  
>> ago, we realized that we didn't have to guess when it would be  
>> time to set the clock graphics. We could use 1-(the long seconds  
>> mod 1) to get a message sent exactly when we need it.
>>
>> Well, we're still guessing at when it's time to move the minute  
>> hand or the hour hand, and we don't need to. The minute hand moves  
>> one degree every ten seconds, the hour hand one degree every two  
>> minutes. The tests to determine this are simple. The natural thing  
>> to do is set the second hand, check to see if the minute hand  
>> needs to be set, and if it does check to see if the hour hand  
>> needs to be set. At each step, I want to exit if appropriate. The  
>> stumbling block was the send...in. I need to get to the end to do it.
>>
>> Then I realized -- the send...in doesn't have to be the last step.  
>> It can come at any point. So here's the script now:
>>
>>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list