|
Post by bplus on Apr 9, 2023 8:51:24 GMT -5
_Title "Easter Egg Clock" 'B+ 2022-04-01
' to do - draw the whole face and then save to image then just show time with hands!!! Randomize Timer Const xmax = 594, ymax = 706 Const sq = 640 '<<<<<<<<<<<<<< everything is scaled to this Const xy0 = sq / 2, dr = .6 * xy0, br = .1 * xy0, hh = .52 * xy0, mh = .6 * xy0, sh = .6 * xy0, thk = .01 * xy0 Const pi = 3.141592653589793, pm2 = 2 * pi, pd2 = pi / 2, pm2d12 = 2 * pi / 12, pm2d60 = 2 * pi / 60 ' pi stuff Const xc = xmax / 2, yc = ymax / 2 Screen _NewImage(xmax, ymax, 32) _ScreenMove (1200 - sq) / 2, 10 be& = _LoadImage("Brown Egg.png") Dim Shared pr(12), pg(12), pb(12) For i = 0 To 12 pr(i) = Rnd: pg(i) = Rnd: pb(i) = Rnd Next Do _PutImage , be&, 0 t# = Timer(.001) hour% = Int(t# / 3600) If hour% > 12 Then showHr# = t# / 3600 - 12 Else showHr# = t# / 3600 min# = t# / 60 - hour% * 60 sec# = t# - hour% * 3600 - Int(min#) * 60 For r = dr - dr / 11 To dr + dr / 11 Step .25 ' main circle Circle (xc, yc), r, &HFFFFFFFF Next lyne xc, yc - dr, 2 * dr, pd2, dr / 5.5, &HFFFFFFFF lyne xc, yc, dr, pi * .25, dr / 5.5, &HFFFFFFFF lyne xc, yc, dr, pi * .75, dr / 5.5, &HFFFFFFFF For i = 0 To 59 If i Mod 5 = 0 Then x = xc + (dr + 30) * Cos(i * pm2d60): y = yc + (dr + 30) * Sin(i * pm2d60) drawEasterEgg x, y, 30, _Atan2(yc - y, xc - x) Else r = 1 Circle (xc + dr * Cos(i * pm2d60), yc + dr * Sin(i * pm2d60)), r * .5 * thk, &HFFBF0A30 End If Next lyne xc, yc, hh, pm2d12 * showHr# - pd2, 8 * thk, &HFF000AFF lyne xc, yc, mh, pm2d60 * min# - pd2, 6 * thk, &HFFBF0A30 lyne xc, yc, sh, pm2d60 * sec# - pd2, 2 * thk, &HFFFFFF00 Circle (xc, yc), 3, &HFF000000 '_Limit 120 _Display Loop Until _KeyDown(27)
Sub lyne (x0, y0, lngth, ra, thic, c As _Unsigned Long) Dim x As Integer, y As Integer, l As Integer While l < lngth l = l + 1: x = x0 + l * Cos(ra): y = y0 + l * Sin(ra) For radius = 0 To thic / 2 Circle (x, y), radius, c, BF Next Wend End Sub
Sub drawEasterEgg (xc, yc, scale, radianAngle) Static index index = (index + 1) Mod 12 Dim r, g, b, x, y, c, a, d r = pr(index): g = pg(index): b = pb(index) For x = -1 To 1 Step .01 For y = -1 To 1 Step .01 If x < 0 Then c = c + .0005 Else c = c - .0005 If (x * x + (1.4 ^ x * 1.6 * y) ^ 2 - 1) <= .01 Then If y > 0 Then Color _RGB32(128 * (1 - y) + 128 * (1 - y) * Sin(c * r), 128 * (1 - y) + 128 * (1 - y) * Sin(c * g), 127 * (1 - y) + 127 * (1 - y) * Sin(c * b)) Else Color _RGB32(128 + 128 * Sin(c * r), 128 + 128 * Sin(c * g), 127 + 127 * Sin(c * b)) End If a = _Atan2(y, x) d = scale * Sqr(x * x + y * y) Line (xc + d * Cos(a + radianAngle), yc + d * Sin(a + radianAngle))-Step(1, 1) End If Next Next End Sub
Attachments:EE clock wo exe.zip (148.33 KB)
|
|