10-06-2022, 01:02 AM
Did I forget to save my post?
Again, For clocks I subtract Pi/2 from angle so 0 radians / 12 o'clock is straight up.
Here is 49+ clocks in 38 LOC:
Again, For clocks I subtract Pi/2 from angle so 0 radians / 12 o'clock is straight up.
Here is 49+ clocks in 38 LOC:
Code: (Select All)
_Title "49+ Analog Clocks in 38 Lines of Code for QB64 B+ 2018-10-02"
Screen _NewImage(720, 720, 32)
_ScreenMove 300, 10
While 1
Cls
For i = 0 To 11
clock 360 + 258 * Cos(_Pi(2 * i / 12)), 360 + 258 * Sin(_Pi(2 * i / 12)), 65
clock 360 + 149 * Cos(_Pi(2 * i / 12)), 360 + 149 * Sin(_Pi(2 * i / 12)), 37
clock 360 + 86 * Cos(_Pi(2 * i / 12)), 360 + 86 * Sin(_Pi(2 * i / 12)), 20
clock 360 + 50 * Cos(_Pi(2 * i / 12)), 360 + 50 * Sin(_Pi(2 * i / 12)), 12
Next
clock 360, 360, 340
clock 700, 700, 865
_Display
_Limit 2
Wend
Sub clock (x, y, r)
For a = 0 To 359 Step 6
If a Mod 30 = 0 Then r1 = 1 / 30 * r Else r1 = 1 / 75 * r
Circle (x + r * Cos(_D2R(a)), y + r * Sin(_D2R(a))), r1
Paint (x + r * Cos(_D2R(a)), y + r * Sin(_D2R(a))), _RGB32(100, 100, 100), _RGB32(255, 255, 255)
Next
If Val(Left$(Time$, 2)) + (Val(Mid$(Time$, 4, 2)) / 60) >= 12 Then hrs = Val(Left$(Time$, 2)) + (Val(Mid$(Time$, 4, 2)) / 60) - 12 Else hrs = Val(Left$(Time$, 2)) + (Val(Mid$(Time$, 4, 2)) / 60)
ftri x + 1 / 15 * r * Cos(Val(Mid$(Time$, 4, 2)) * _Pi(1 / 30) - _Pi(1 / 2) + _Pi(1 / 2)), y + 1 / 15 * r * Sin(Val(Mid$(Time$, 4, 2)) * _Pi(1 / 30) - _Pi(1 / 2) + _Pi(1 / 2)), x + 1 / 15 * r * Cos(Val(Mid$(Time$, 4, 2)) * _Pi(1 / 30) - _Pi(1 / 2) - _Pi(1 / 2)), y + 1 / 15 * r * Sin(Val(Mid$(Time$, 4, 2)) * _Pi(1 / 30) - _Pi(1 / 2) - _Pi(1 / 2)), x + r * Cos(Val(Mid$(Time$, 4, 2)) * _Pi(1 / 30) - _Pi(1 / 2)), y + r * Sin(Val(Mid$(Time$, 4, 2)) * _Pi(1 / 30) - _Pi(1 / 2)), _RGB32(255, 0, 0)
ftri x + 1 / 10 * r * Cos(hrs * _Pi(1 / 6) - _Pi(1 / 2) + _Pi(1 / 2)), y + 1 / 10 * r * Sin(hrs * _Pi(1 / 6) - _Pi(1 / 2) + _Pi(1 / 2)), x + 1 / 10 * r * Cos(hrs * _Pi(1 / 6) - _Pi(1 / 2) - _Pi(1 / 2)), y + 1 / 10 * r * Sin(hrs * _Pi(1 / 6) - _Pi(1 / 2) - _Pi(1 / 2)), x + 2 / 3 * r * Cos(hrs * _Pi(1 / 6) - _Pi(1 / 2)), y + 2 / 3 * r * Sin(hrs * _Pi(1 / 6) - _Pi(1 / 2)), _RGB32(0, 0, 255)
Line (x, y)-(x + r * Cos(Val(Right$(Time$, 2)) * _Pi(1 / 30) - _Pi(1 / 2)), y + r * Sin(Val(Right$(Time$, 2)) * _Pi(1 / 30) - _Pi(1 / 2))), _RGB32(255, 255, 0)
Circle (x, y), 1 / 10 * r, _RGB32(255, 255, 255)
Paint (x + 1 / 75 * r, y + 1 / 75 * r), _RGB32(100, 100, 100), _RGB32(255, 255, 255)
Circle (x, y), 1 / 30 * r, _RGB32(0, 0, 0)
End Sub
Sub ftri (x1, y1, x2, y2, x3, y3, K As _Unsigned Long)
a& = _NewImage(1, 1, 32)
_Dest a&
PSet (0, 0), K
_Dest 0
_MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3)
_FreeImage a& '<<< this is important!
End Sub
b = b + ...