_Title "Optical Illusion Clock" ' b+ make over 2022-01-22
sided2 = side / 2
drawGrid
_Width / 2 - sided2
, _Height / 2 - sided2
, side
/ 60, side
/ 60, 60, 60Dim ticksX
(59), ticksY
(59) ticksX
(i
) = 175 + 170 * Cos(i
* _Pi(2 / 60)) ticksY
(i
) = 175 + 170 * Sin(i
* _Pi(2 / 60)) minutes
= Timer \
60 - hours
* 60 seconds
= (Timer - hours
* 3600 - minutes
* 60)
' for chimes
'Hours
h = 360 - hours * 30 + 180
radius = 15
x
= Int(Sin(h
/ 180 * 3.141592) * 80) + 175 y
= Int(Cos(h
/ 180 * 3.141592) * 80) + 175
'Minutes
m = 180 - minutes * 6
radius = 14
x
= Int(Sin(m
/ 180 * 3.141592) * 125) + 175 y
= Int(Cos(m
/ 180 * 3.141592) * 125) + 175
'Seconds
s = (60 - seconds) * 6 + 180
radius = 12
x
= Int(Sin(s
/ 180 * 3.141592) * 160) + 175 y
= Int(Cos(s
/ 180 * 3.141592) * 160) + 175
'Chimes
hour2 = hou
If hour2
> 12 Then hour2
= hour2
- 12 ttt = 0
'queue some sound
sample
= Sin(ttt
* 340 * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p) sample
= sample
* Exp(-ttt
* 3) 'fade out eliminates clicks after sound ttt
= ttt
+ 1 / _SndRate 'sound card sample frequency determines time 'do other stuff, but it may interrupt sound
drawStuff:
Sub drawGrid
(x
, y
, xs
, ys
, xn
, yn
) ' top left x, y, x side, y side, number of x, nmber of y dx = xs * xn: dy = ys * yn
Line (x
+ xs
* i
, y
)-(x
+ xs
* i
, y
+ dy
) Line (x
, y
+ ys
* i
)-(x
+ dx
, y
+ ys
* i
)
Dim W&
, H&
, sinr!
, cosr!
, i&
, x2&
, y2&
px(0) = -W& / 2: py(0) = -H& / 2: px(1) = -W& / 2: py(1) = H& / 2
px(2) = W& / 2: py(2) = H& / 2: px(3) = W& / 2: py(3) = -H& / 2
sinr!
= Sin(-radianRotation
): cosr!
= Cos(-radianRotation
) x2& = xScale * (px(i&) * cosr! + sinr! * py(i&)) + X: y2& = yScale * (py(i&) * cosr! - px(i&) * sinr!) + Y
px(i&) = x2&: py(i&) = y2&