I love this clock example. Just so simple. You guys are great! I
could not resist seeing how the thinking was progressing and took it
to the next step. Fewer lines, more accuracy (I have often noted
that the simplest most elegant solutions take the most time to create
and the least time to understand). As Ben suggested, this clock
should be a standard example for new users to look at. I will also
add it to my revOnline user area (see3d) as soon as today's connect
problem is fixed.
on openCard
setTime
end openCard
on setTime
set the itemDelimiter to ":"
get word 1 of the long time --8:13:15
put it & char 2 to 5 of (the long seconds mod 1) into fld "Time"
set the startangle of grc "hour" to 90 - (30 * item 1 of it) -
(item 2 of it) / 2
set the startangle of grc "minute" to 90 - (6 * item 2 of it) -
(item 3 of it) / 10
set the startangle of grc "second" to 90 - (6 * item 3 of it)
send "setTime" to me in 60-(the long seconds mod 1)*60 ticks
end setTime
Dennis
---------------------------------------------------------------------
On May 30, 2005, at 3:03 AM, Geoff Canyon wrote:
I originally went with polygon graphics, which put me at about
twenty lines of code by your way of counting (including "on" and
"end" statements).
Switching to oval graphics I got it down to 11 lines, which sweep
both the hour and minute hands. But the second hand is jumpy.
Simply using send...in just about always results in the second hand
either taking noticeably too long or too short to measure a second
here or there. So I added code to time seconds more finely. This
results in the second hand always ticking when it's supposed to.
The display shows the long seconds, and you can watch the updates
hit consistently in the first tenth of a second or so. It puts me
up at 18 lines of code, but the result is worth it I think:
on openCard
setTime
end openCard
local sTime
on setTime
put word 1 of the long time into tTime
if tTime is sTime then
send "setTime" to me in 5 ticks
exit setTime
end if
put tTime into sTime
put sTime && the long seconds into fld "time"
set the itemDelimiter to ":"
set the startangle of grc "hour" to 90 - (30 * item 1 of sTime) -
(item 2 of sTime) / 2
set the startangle of grc "minute" to 90 - (6 * item 2 of sTime)
- (item 3 of sTime) / 10
set the startangle of grc "second" to 90 - (6 * item 3 of sTime)
send "setTime" to me in 50 ticks
end setTime
The stack is available by executing this in the message box:
go stack url "http://www.inspiredlogic.com/rev/clock.rev"
On May 27, 2005, at 4:08 PM, Malte Brill wrote:
Sorry, couldnīt resist
on mouseUp
if the flag of me is empty then set the flag of me to false
set the flag of me to not the flag of me
if the flag of me then startClock
end mouseUp
on startclock
put the long time into myTime
put myTime into fld 1
set the itemdel to ":"
put char 1 to 2 of item 3 of myTime into daSecs
set the startAngle of grc "seconds" to 90-dasecs*6
put item 2 of myTime into daMinutes
set the startangle of grc minutes to 90-daminutes*6
put item 1 of myTime into daHours
set the startAngle of grc "hours" to 90-dahours*30-daminutes*30/60
if the flag of me then send startClock to me in 500 milliseconds
end startclock
Cheers,
Malte
Create 3 oval graphics
set arcangle of each graphic to zero
loc of all 3 needs to be the same
1 field to put the time in
Cheers,
Malte
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution