113 lines
3.4 KiB
Plaintext
113 lines
3.4 KiB
Plaintext
link graphics
|
|
|
|
global xsize,
|
|
ysize,
|
|
fontsize
|
|
|
|
procedure main(args)
|
|
if *args > 0 then xsize := ysize := numeric(args[1])
|
|
|
|
/xsize := /ysize := 200
|
|
WIN := WOpen("size=" || xsize || "," || ysize, "label=Clock", "resize=on") | stop("Fenster geht nicht auf!", image(xsize), " - ", image(ysize))
|
|
ziffernblatt()
|
|
|
|
repeat
|
|
{ write(&time)
|
|
|
|
if *Pending(WIN) > 1 then while *Pending() > 0 do
|
|
{ e := Event()
|
|
ziffernblatt()
|
|
}
|
|
|
|
Fg("#CFB53B")
|
|
FillCircle(xsize/2, ysize/2, xsize/2 * 0.81)
|
|
Fg("black")
|
|
|
|
clock := &clock
|
|
sec := clock[7:0]
|
|
min := clock[4:6]
|
|
hour := clock[1:3]
|
|
|
|
if fontsize > 7 then
|
|
{ #Fg("yellow")
|
|
EraseArea(10,0, TextWidth(clock),WAttrib("fheight"))
|
|
DrawString(10,fontsize, clock)
|
|
}
|
|
|
|
draw_zeiger(hour, min, sec)
|
|
|
|
WFlush()
|
|
delay(100)
|
|
}
|
|
end
|
|
|
|
procedure ziffernblatt()
|
|
xsize := WAttrib("width")
|
|
ysize := WAttrib("height")
|
|
if xsize < ysize then ysize := xsize
|
|
if ysize < xsize then xsize := ysize
|
|
|
|
EraseArea(0,0,WAttrib("width"),WAttrib("height"))
|
|
|
|
Fg("#CFB53B")
|
|
FillCircle(xsize/2, ysize/2, xsize/2)
|
|
Fg("black")
|
|
fontsize := fontsize := 30 * xsize / 800.0
|
|
|
|
every i := 1 to 60 do
|
|
{ winkel := 6 * i / 180.0 * &pi
|
|
if i % 5 = 0 then
|
|
{ laenge := 0.95
|
|
if fontsize > 15 then
|
|
{ Font("mono," || integer(fontsize) || ",bold")
|
|
WAttrib("linewidth=3")
|
|
}
|
|
if fontsize > 8 then
|
|
{ Font("sans," || integer(fontsize))
|
|
WAttrib("linewidth=2")
|
|
}
|
|
|
|
if fontsize > 8 then DrawString(xsize/2 + 0.90 * xsize/2 * sin(winkel) - fontsize / 2, ysize/2 - 0.90 * ysize/2 * cos(winkel) + fontsize/2, (i/5)("I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"))
|
|
}
|
|
else laenge := 0.98
|
|
if fontsize >= 5 then DrawLine(xsize/2 + laenge * xsize/2 * sin(winkel), ysize/2 - laenge * ysize/2 * cos(winkel), xsize/2 + 0.99 * xsize/2 * sin(winkel), ysize/2 - 0.99 * ysize/2 * cos(winkel))
|
|
if fontsize < 5 then if i % 5 = 0 then
|
|
{ WAttrib("linewidth=1")
|
|
DrawLine(xsize/2 + laenge * xsize/2 * sin(winkel), ysize/2 - laenge * ysize/2 * cos(winkel), xsize/2 + 0.99 * xsize/2 * sin(winkel), ysize/2 - 0.99 * ysize/2 * cos(winkel))
|
|
}
|
|
}
|
|
clock := &clock
|
|
sec := clock[7:0]
|
|
min := clock[4:6]
|
|
hour := clock[1:3]
|
|
|
|
if fontsize > 7 then
|
|
{ EraseArea(10,0, TextWidth(clock),WAttrib("fheight"))
|
|
DrawString(10,fontsize, clock)
|
|
}
|
|
draw_zeiger(hour, min, sec)
|
|
|
|
Fg("#D4AF37")
|
|
FillCircle(xsize/2, ysize/2, 5)
|
|
Fg("black")
|
|
WAttrib("linewidth=2")
|
|
|
|
DrawCircle(xsize/2, ysize/2,5)
|
|
|
|
end
|
|
|
|
procedure draw(laenge, breite, winkel)
|
|
WAttrib("linewidth=" || breite)
|
|
DrawLine(xsize/2,ysize/2,xsize/2 + laenge * sin(winkel), ysize/2 - laenge * cos(winkel))
|
|
end
|
|
|
|
procedure draw_zeiger(h, m, s)
|
|
wh := 30 * ((h % 12) + m / 60.0 + s / 3600.0) / 180 * &pi
|
|
wm := 6 * (m + s / 60.0) / 180.0 * &pi
|
|
ws := 6 * s / 180.0 * &pi
|
|
|
|
draw(xsize/2 * 0.5, 5, wh) # Stundenzeiger
|
|
draw(xsize/2 * 0.65, 3, wm) # Minutenzeiger
|
|
draw(xsize/2 * 0.80, 1, ws) # Sekundenzeiger
|
|
end
|