.
Изображения взял готовые и немного переделал.
Это конечно плагиат, но в образовательных целях - можно...
В оригинале программы, куча анимации и наворотов...
Здесь по проще...
Повторить многое не смог, например анимация переворачивания цифр и.т.д. ...
Зато не много разобрался с полупрозрачный окнами.
Правая кнопка - выбор города...
Code
; Clock by Michael Vogel
; Sound additions by ebs
;>>>>>> this version for Mac <<<<<<<
#Phases=10
#Halftime=#Phases>>1
#Delay=60
#Gray=$808080
#White=$FFFFFF
#Black=0
#BorderColor=#Gray
Enumeration
#Never
#Hours=0
#Minutes
#Seconds
#OldValue
#NewValue
#Drawboard
#Plate
#WinID
#Numbers
#Now
#Undefined=-1
EndEnumeration
Global WinID
; adjust window size for added colons (ebs)
Global WX=690
;Global WX=590
Global WY=200
; adjust window size for added colons (ebs)
Global GX=240
;Global GX=190
Global GY=190
Global G_X=GX-1
Global G_Y=GY-1
Global G_M=G_Y>>1
Global OX=5
Global OY=5
Global OZ=5
Global Later=#Never
Global HourLast=#Undefined
Global MinuteLast=#Undefined
Global SecondLast=#Undefined
Global Font
Global Dim Image(#Plate)
Global Text.s
Global Dim Size(#Phases)
Procedure.l Greyscale(n,x)
n=x-n
n<<6
n/x
ProcedureReturn n*$10101
EndProcedure
Procedure.l QuickEvent(n)
n+ElapsedMilliseconds()
While n>ElapsedMilliseconds()
Select WaitWindowEvent(10)
Case #PB_Event_CloseWindow
ProcedureReturn #True
EndSelect
Wend
ProcedureReturn #False
EndProcedure
Procedure Plate(index,old,new,phase)
Image(#NewValue)=CopyImage(#Plate,#NewValue)
StartDrawing(ImageOutput(#NewValue))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(Font)
Text=RSet(Str(new),2,"0")
If index = #Seconds
Text + " "
Else
Text + ":"
EndIf
DrawText(1,1,Text,#White)
StopDrawing()
Image(#OldValue)=CopyImage(#Plate,#OldValue)
StartDrawing(ImageOutput(#OldValue))
DrawingMode(#PB_2DDrawing_Transparent)
DrawingFont(Font)
Text=RSet(Str(old),2,"0")
If index = #Seconds
Text + " "
Else
Text + ":"
EndIf
DrawText(1,1,Text,#White)
StopDrawing()
StartDrawing(ImageOutput(index))
If phase<>#Phases
Image(#Drawboard)=GrabImage(#NewValue,#Drawboard,0,0,GX,G_M)
DrawImage(Image(#Drawboard),0,0)
Image(#Drawboard)=GrabImage(#OldValue,#Drawboard,0,G_M,GX,G_M)
DrawImage(Image(#Drawboard),0,G_M)
If phase<#Halftime
Image(#Drawboard)=GrabImage(#OldValue,#Drawboard,0,0,GX,G_M)
ResizeImage(#Drawboard,GX,Size(phase))
Image(#Drawboard)=ImageID(#Drawboard)
DrawImage(Image(#Drawboard),0,G_M-Size(phase))
LineXY(0,G_M-Size(phase),GX,G_M-Size(phase),#BorderColor)
ElseIf phase>#Halftime
Image(#Drawboard)=GrabImage(#NewValue,#Drawboard,0,G_M,GX,G_M)
ResizeImage(#Drawboard,GX,Size(phase))
Image(#Drawboard)=ImageID(#Drawboard)
DrawImage(Image(#Drawboard),0,G_M)
LineXY(0,G_M+Size(phase),GX,G_M+Size(phase),#BorderColor)
EndIf
Else
Image(index)=CopyImage(#NewValue,index)
EndIf
StopDrawing()
EndProcedure
Procedure Flip(hour,Minute,Second)
Protected n
For n=1 To #Phases
If hour<>#Undefined
Plate(#Hours,HourLast,hour,n)
SetGadgetState(#Hours,Image(#Hours))
EndIf
If Minute<>#Undefined
Plate(#Minutes,MinuteLast,Minute,n)
SetGadgetState(#Minutes,Image(#Minutes))
EndIf
If Second<>#Undefined
Plate(#Seconds,SecondLast,Second,n)
SetGadgetState(#Seconds,Image(#Seconds))
EndIf
If QuickEvent(#Delay)
Later=#Now
Break
EndIf
Next n
If hour<>#Undefined
HourLast=hour
EndIf
If Minute<>#Undefined
MinuteLast=Minute
EndIf
If Second<>#Undefined
SecondLast=Second
EndIf
EndProcedure
Procedure UpdateClock()
Protected HourNow,MinuteNow,SecondNow
Protected Clock=Date()
HourNow=Hour(Clock)
MinuteNow=Minute(Clock)
SecondNow=Second(Clock)
If HourLast=HourNow
HourNow=#Undefined
EndIf
If MinuteLast=MinuteNow
MinuteNow=#Undefined
EndIf
If SecondLast=SecondNow
SecondNow=#Undefined
EndIf
Flip(HourNow,MinuteNow,SecondNow)
EndProcedure
Procedure Init()
Protected i
WinID=OpenWindow(#WinID,0,0,WX,WY,"Flip Flop",#PB_Window_Invisible|#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
SetWindowColor(#WinID, #Black)
For i=#Hours To #Seconds
ImageGadget(i,(WindowWidth(#WinID)-WX)/2 + OX+(GX+OZ)*i,(WindowHeight(#WinID)-WY)/2 + OY,GX,GY,0)
Next i
For i=#Hours To #Plate
Image(i)=CreateImage(i,GX,GY)
Next i
Font=LoadFont(#Numbers,"Geneva",GY*0.65,#PB_Font_Bold)
StartDrawing(ImageOutput(#Plate))
Box(0,0,G_X,G_Y,#Black)
For i=0 To G_M/3
c=Greyscale(i,G_M/3)
LineXY(0,i,G_X,i,c)
LineXY(0,i+G_M,G_X,i+G_M,c)
Next i
StopDrawing()
For i=1 To #Phases
Size(i)=Abs(Cos(i*#PI/#Phases)*G_M)
Next i
UpdateClock()
HideWindow(#WinID,0)
EndProcedure
Procedure Main()
Init()
Repeat
Select WaitWindowEvent(100)
Case #PB_Event_CloseWindow
Later=#Now
EndSelect
NewSecond=Second(Date())
If NewSecond<>OldSecond
UpdateClock()
OldSecond=NewSecond
EndIf
Until Later
EndProcedure
Main()