Each corner of the screen must have a green square.
This code does not work with a computer browser. Only Android.
Thanks.
Greetings
Code: Select all
; Date & Time Version 1
;
; SpiderBasic 2.2 JDK 1.1.8.0 144 (x86)
; Android Only
EnableExplicit
Enumeration
#FontH1
#FontH2
#mf
#mfDate
#mfTime
#TL ;Square Top Left
#TR ;Square Top Right
#BL ;Square Bottom Left
#BR ;Square Bottom Right
#Timer
EndEnumeration
Declare Start()
Declare onTimer()
Declare onChangeOrientation()
Start()
Procedure Start()
Protected BackColor = RGB(105, 105, 105)
Protected FrontColor = RGB(152, 251, 152)
Protected Image, Gadget
CloseDebugOutput()
;No Zoom
!$('head').append('<meta name="viewport" content="width=device-width, maximum-scale=1.0, user-scalable=0">');
LoadFont(#FontH1, "", 70)
LoadFont(#FontH2, "", 50)
OpenWindow(#mf, 0, 0, 0, 0, "Date & Time", #PB_Window_Background)
SetWindowColor(#mf, BackColor)
TextGadget(#mfDate, 0, 0, 400, 100, "", #PB_Text_Center)
SetGadgetFont(#mfDate, FontID(#FontH1))
SetGadgetColor(#mfDate, #PB_Gadget_FrontColor, FrontColor)
TextGadget(#mfTime, 0, 0, 400, 100, "00:00:00", #PB_Text_Center)
SetGadgetFont(#mfTime, FontID(#FontH2))
SetGadgetColor(#mfTime, #PB_Gadget_FrontColor, FrontColor)
;Squares
Image = CreateImage(#PB_Any, 40, 40, 0, FrontColor)
StartDrawing(ImageOutput(Image))
Box(0, 0, 40, 40, RGB(0, 0, 0))
Box(5, 5, 30, 30, FrontColor)
StopDrawing()
For Gadget = #TL To #BR
ImageGadget(Gadget, 0, 0, 40, 40, ImageID(Image))
Next
;Init
AddWindowTimer(#mf, #Timer, 1000)
onTimer()
onChangeOrientation()
;Triggers
BindEvent(#PB_Event_Timer, @onTimer(), #mf, #Timer)
BindEvent(#PB_Event_SizeWindow, @onChangeOrientation())
EndProcedure
Procedure onTimer()
SetGadgetText(#mfDate, FormatDate("%yyyy-%mm-%dd", Date()))
SetGadgetText(#mfTime, FormatDate("%hh:%ii:%ss", Date()))
EndProcedure
Procedure onChangeOrientation()
Protected width, height
!v_width = screen.width * window.devicePixelRatio;
!v_height = screen.height * window.devicePixelRatio;
!document.body.style.zoom = 1 / window.devicePixelRatio * 100 + "%"
ResizeGadget(#mfDate, (width - GadgetWidth(#mfDate))/2, (height - GadgetHeight(#mfDate))/2, #PB_Ignore, #PB_Ignore)
ResizeGadget(#mfTime, (width - GadgetWidth(#mfTime))/2, (height - GadgetHeight(#mfTime))/2 + 100, #PB_Ignore, #PB_Ignore)
ResizeGadget(#TL, 0, 0, #PB_Ignore, #PB_Ignore)
ResizeGadget(#TR, Width - 40, 0, #PB_Ignore, #PB_Ignore)
ResizeGadget(#BL, 0, height - 40, #PB_Ignore, #PB_Ignore)
ResizeGadget(#BR, Width - 40, height -40, #PB_Ignore, #PB_Ignore)
ResizeWindow(#mf, #PB_Ignore, #PB_Ignore, width, height)
EndProcedure
■ Parameter
- General option: Enabled unknown sources.
- Development options: Enabled USB debugging