'+---------------+---------------------------------------------------+
'| ###### ###### | .--. . .-. |
'| ## ## ## # | | )| ( ) o |
'| ## ## ## | |--' |--. .-. `-. . .-...--.--. .-. |
'| ###### ## | | \ | |( )( ) | ( || | |( ) |
'| ## ## | ' `' `-`-' `-'-' `-`-`|' ' `-`-'`- |
'| ## ## # | ._.' |
'| ## ###### | Sources & Documents placed in the Public Domain. |
'+---------------+---------------------------------------------------+
'| |
'| === NewClock.bas === |
'| |
'| == A simple binary (BCD) clock inspired by the alien countdown |
'| == from the movie "Mission to Mars". |
'| == For easy reading it also have digital and analog displays. |
'| |
'+-------------------------------------------------------------------+
'| Done by RhoSigma, R.Heyder, provided AS IS, use at your own risk. |
'| Find me in the QB64 Forum or mail to support&rhosigma-cw.net for |
'| any questions or suggestions. Thanx for your interest in my work. |
'+-------------------------------------------------------------------+
'get my local appdata folder
lad$ = lad$ + "RhoSigma\"
'get old window position
cfg$ = lad$ + "NewClock.bin"
lft% = -1: top% = -1
'setup screen
scrFont&
= _LOADFONT("C:\Windows\Fonts\timesbd.ttf", 30)
'3D space origin is on these screen coordinates
'init BCD discs
InitDiscs
'init month names
month$(1) = "Jan": month$(2) = "Feb": month$(3) = "Mar": month$(4) = "Apr"
month$(5) = "May": month$(6) = "Jun": month$(7) = "Jul": month$(8) = "Aug"
month$(9) = "Sep": month$(10) = "Oct": month$(11) = "Nov": month$(12) = "Dec"
'draw hour/minute/seconds separators
Line3D 52, 0, 0, 52, 210, 0, 2
Line3D 52, 0, 0, 52, 0, -30, 2
Line3D 128, 0, 0, 128, 210, 0, 2
Line3D 128, 0, 0, 128, 0, -30, 2
'mark binary factors
_PRINTSTRING (8, 5), "8": Line3D
-20, 180, 0, -70, 180, 0, 6 _PRINTSTRING (8, 30), "4": Line3D
-20, 130, 0, -45, 130, 0, 6 _PRINTSTRING (280, 55), "2": Line3D
200, 80, 0, 225, 80, 0, 6 _PRINTSTRING (280, 80), "1": Line3D
200, 30, 0, 250, 30, 0, 6
'main loop
FlipDiscs
'cleanup
'run the clock
newState&
= (VAL(MID$(t$
, 1, 1)) * (2 ^ 20)) + (VAL(MID$(t$
, 2, 1)) * (2 ^ 16)) +_
diff&
= curState&
XOR newState&
curState& = newState&
IF (n%
MOD 4) = 0 THEN AxisSegments Discs
(n%
).x
Circle3D Discs(n%).x, Discs(n%).y, Discs(n%).z, Discs(n%).r, Discs(n%).a, 0
Circle3D Discs(n%).x, Discs(n%).y, Discs(n%).z, Discs(n%).r, Discs(n%).a + 6, 15
Discs(n%).a = Discs(n%).a + 6
IF Discs
(n%
).a
= 180 THEN Discs
(n%
).a
= 0 Circle3D Discs(n%).x, Discs(n%).y, Discs(n%).z, Discs(n%).r, Discs(n%).a, 15
'digital clock
'analog clock
LINE (242 - 34, 142 - 34)-(242 + 34, 142 + 34), 0, BF
x% = PolToCartX%((360 / 43200 * t#) - 90, 22)
y% = PolToCartY%((360 / 43200 * t#) - 90, 22)
LINE (242, 142)-(x%
+ 242, y%
+ 142), 14 x% = PolToCartX%((360 / 3600 * t#) - 90, 26)
y% = PolToCartY%((360 / 3600 * t#) - 90, 26)
LINE (242, 142)-(x%
+ 242, y%
+ 142), 10 x% = PolToCartX%((360 / 60 * t#) - 90, 28)
y% = PolToCartY%((360 / 60 * t#) - 90, 28)
LINE (242, 142)-(x%
+ 242, y%
+ 142), 12 x% = PolToCartX%((360 / 60 * t#) + 90, 7)
y% = PolToCartY%((360 / 60 * t#) + 90, 7)
LINE (242, 142)-(x%
+ 242, y%
+ 142), 12 gau& = ApplyFilter&(tru&, "Gauss8", 0, 0, -1, -1, -1, -1, -1)
'setup start values for all discs
n% = 0
Discs(n%).x = i%
Discs(n%).y = j%
Discs(n%).z = 0
Discs(n%).r = 10
Discs(n%).a = 0
n% = n% + 1
Discs(n%).x = i%
Discs(n%).y = j%
Discs(n%).z = 0
Discs(n%).r = 10
Discs(n%).a = 0
n% = n% + 1
Discs(n%).x = i%
Discs(n%).y = j%
Discs(n%).z = 0
Discs(n%).r = 10
Discs(n%).a = 0
n% = n% + 1
'draw rotation axis segments between discs
Line3D x%, 0, 0, x%, 20, 0, 12
Line3D x%, 40, 0, x%, 70, 0, 12
Line3D x%, 90, 0, x%, 120, 0, 12
Line3D x%, 140, 0, x%, 170, 0, 12
Line3D x%, 190, 0, x%, 210, 0, 12
SUB Line3D
(x1%
, y1%
, z1%
, x2%
, y2%
, z2%
, col%
) 'x1%/y1%/z1% = start, x2%/y2%/z2% = end, col% = color pen
x1# = (x1% + (y1% * 0.5)): z1# = (z1% + (y1% * 0.5))
x2# = (x2% + (y2% * 0.5)): z2# = (z2% + (y2% * 0.5))
LINE (x1#
+ cx%
, -z1#
+ cy%
)-(x2#
+ cx%
, -z2#
+ cy%
), col%
SUB Circle3D
(x%
, y%
, z%
, r%
, ba%
, col%
) 'x%/y%/z% = center, r% = radius, ba% = B-Axis angle, col% = color pen
mx# = (x% + (y% * 0.5)): mz# = (z% + (y% * 0.5))
zx#
= r%
* COS(ba%
* 0.017453292519943)zz#
= r%
* SIN(ba%
* 0.017453292519943) x#
= zx#
* COS(cir%
* 0.017453292519943) y#
= r%
* SIN(cir%
* 0.017453292519943) z#
= zz#
* COS(cir%
* 0.017453292519943) x# = (x# + (y# * 0.5)): z# = (z# + (y# * 0.5))
PSET (x#
+ mx#
+ cx%
, -z#
+ -mz#
+ cy%
), col%
'$INCLUDE: 'QB64Library\IMG-Support\converthelper.bm'
'$INCLUDE: 'QB64Library\IMG-Support\imageprocess.bm'