Yet another clock

Post Reply
Henko
Posts: 829
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Yet another clock

Post by Henko »

Indeed, yet another clock.

IMG_1347.jpeg
IMG_1347.jpeg (189.69 KiB) Viewed 50 times
I saw it while visiting some bridge friends, and felt an iressistible urge to program it in SB.
IMG_1345.png
IMG_1345.png (485.12 KiB) Viewed 50 times
Here it is, be it the Dutch version.
The clock displays the time with text, in 5-minute intervals. The minutes within the 5-minute interval are displayed by little red spots in the corners of the panel. In the programmed version, a slider is added under the panel, to indicate the seconds within the current minute.
The program works well on iPhones and iPads.

Anyone who cares to do the English version?
The code for this Dutch version follows:

Code: Select all

' Another clock (Dutch version, for iPhones and iPads)
' Idea and physical versions by www.qlocktwo.com
' September 2025 by Henko

pR=0.75 ! pG=0.75 ! pB=0.75    ' panel color
cR=0 ! cG=0 ! cB=0.6           ' character color

init_prog()
ct$=get_clocktext$()
do slowdown
  u=current_hour() ! m=current_minute() ! s=current_second()
  if s<>so then ! seconds_bar(s) ! so=s ! end if
  if m=mo then continue else mo=m
  init_panel(ct$)
  if u=12 and m<16 then u=u else u=u%12 ! u1=u+1
  mm=m%5 ! m5=m-mm
  draw color cR,cG,cB ! draw alpha 1
  highlight(0,1,0,0)
  if m5=0  then highlight(.uur(u),22,0,0)
  if m5=5  then highlight( 2,5,.uur(u),0)
  if m5=10 then highlight(3,5,.uur(u),0)
  if m5=15 then highlight(6,8,.uur(u),0)
  if m5=20 then highlight(3,4,7,.uur(u1))
  if m5=25 then highlight(2,4,7,.uur(u1))
  if m5=30 then highlight(7,.uur(u1),0,0)
  if m5=35 then highlight(2,5,7,.uur(u1))
  if m5=40 then highlight(3,5,7,.uur(u1))
  if m5=45 then highlight(6,9,.uur(u1),0)
  if m5=50 then highlight(3,4,.uur(u1),0)
  if m5=55 then highlight(2,4,.uur(u1),0)
  corner(mm)
  until forever
end

def init_prog()
graphics ! graphics clear 1,1,1 ! draw color 0,0,0
set orientation portrait
get screen size .sw,.sh
.marge=int(.sw/56) ! .tl=.sw-2*.marge
.fs=.tl/6.615 ! .dx=0.6043*.fs ! .dy=0.65*.fs
.mo=-1
end def

def init_panel(t$)
fill color .pR,.pG,.pB
fill rect .marge,.marge to .sw-.marge,.sw-.marge
s=0
draw font size .fs ! draw color 0,0,0 ! draw alpha 0.1
for i=0 to 9
  y=.fs*i*0.65
  a$=mid$(t$,s,11) ! s+=11
  draw text a$ at .marge,y
  next i
end def

def highlight(a,b,c,d)
draw text .w$(a) at .marge+.wx(a)*.dx,.wy(a)*.dy
draw text .w$(b) at .marge+.wx(b)*.dx,.wy(b)*.dy
if c then draw text .w$(c) at .marge+.wx(c)*.dx,.wy(c)*.dy
if d then draw text .w$(d) at .marge+.wx(d)*.dx,.wy(d)*.dy
end def

def corner(k)
m=.marge
fill rect m,m to m+5,m+5
fill rect .sw-m-5,m to .sw-m,m+5
fill rect .sw-m-5,m+.tl-5 to .sw-m,m+.tl
fill rect m,m+.tl-5 to m+5,m+.tl
fill color 1,0,0
if k>=1 then fill rect m,m to m+5,m+5
if k>=2 then fill rect .sw-m-5,m to .sw-m,m+5
if k>=3 then fill rect .sw-m-5,m+.tl-5 to .sw-m,m+.tl
if k>=4 then fill rect m,m+.tl-5 to m+5,m+.tl
end def

def seconds_bar(s)
if not init then
  init=1 ! m=.marge ! y=.sw-m+20
  slider "seconds" value s/59 at m,y size .sw-2*m
  end if
slider "seconds" value s/59
end def

def get_clocktext$()
dim .w$(23),.wx(23),.wy(23),.uur(13)
for i=0 to 22 ! read .w$(i),.wx(i),.wy(i) ! next i
for i=1 to 12 ! read .uur(i) ! next i
data "HET",0,0,  "IS",4,0, "VIJF",7,0, "TIEN",0,1
data "VOOR",7,1, "OVER",0,2, "KWART",6,2, "HALF",0,3
data "OVER",7,3, "VOOR",0,4, "EEN",7,4, "TWEE",0,5
data "DRIE",7,5, "VIER",0,6, "VIJF",4,6, "ZES",8,6
data "ZEVEN",0,7, "NEGEN",6,7, "ACHT",0,8, "TIEN",4,8
data "ELF",8,8, "TWAALF",0,9, "UUR",8,9
data 10,11,12,13,14,15,16,18,17,19,20,21
t$=""
t$&="HETKISAVIJFTIENATZVOOR"
t$&="OVERMEKWARTHALFSPMOVER"
t$&="VOORTHGEENSTWEEAMCDRIE"
t$&="VIERVIJFZESZEVENONEGEN"
t$&="ACHTTIENELFTWAALFPMUUR"
return t$
end def

smbstarv
Posts: 100
Joined: Wed Nov 27, 2013 3:44 pm
My devices: Ipad 6th gen
Flag: Netherlands
Contact:

Re: Yet another clock

Post by smbstarv »

Funny !
This brightens my day....

Post Reply