A Different Time(r)
Author: Norman Deppenbroek This example requires REBOL/View Return to REBOL Cookbook
This code shows an example of an alternative clock.
Ticking seconds, minutes, and hours using a 'progress face and a 'feel controlled by 'rate.
Here is the layout created which contains seconds, minutes, hours as 'progress indication.
The progress/data is updated and the progress 'face is shown. This all in a 'rate 1 action.
clock: layout [
origin 0
backcolor black
space 0x0
seconds: progress 240x10 center black tan
edge [ size: 1x1 color: black effect: 'flat ] rate 1
feel [
engage: func [ face act evt ] [
seconds/data: ( 1 / 60 ) * ( third now/time )
show seconds
]
]
minutes: progress 240x10 center black mint
edge [ size: 1x1 color: black effect: 'flat ] rate 1
feel [
engage: func [ face act evt ] [
minutes/data: ( 1 / 60 ) * ( second now/time )
show minutes
]
]
hours: progress 240x10 center black
aqua edge [ size: 1x1 color: black effect: 'flat ] rate 1
feel [
engage: func [ face act evt ] [
hours/data: ( 1 / 24 ) * ( first now/time )
show hours
]
]
]
|
Every 'face (seconds, minutes, or hours) has its own behavior specified
by 'colors and 'edge. The 'feel block contains the action to check every "rate x"
which is in this case the update of the 'progress with the seconds,minutes and hours.
Run the 'layout with:
view/title clock "Enjoy a different time"
|
|