Author Topic: Neon Clock  (Read 8694 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Neon Clock
« on: March 23, 2022, 01:43:31 am »
A couple years ago someone told us how to get neon colors using a _GL Sub. I'm guessing it's only for Windows computers but I could be wrong. Anyway, I decided to dig it up tonight and make a Neon Clock. Using CLS and _DISPLAY doesn't work with it (it flashes too much), so instead of CLS on my usual clocks, I drew the neon circles for the clock and used a LINE command to delete the clock hands. Doing this I also added the trail-effect that B+ showed me when I first started. Tell me what you think. It also chimes the hour every hour. Here is a photo of it also below. By the way, how do you view larger photos on here that others are using, I only know the Attachments, thanks.

Code: QB64: [Select]
  1. _Title "Neon Clock by SierraKen"
  2. Screen _NewImage(600, 600, 32)
  3.  
  4. Type vec2
  5.     x As Single
  6.     y As Single
  7.  
  8. ReDim Shared vert(4024) As vec2, max_v_index
  9. Dim Shared rFactor!, gFactor!, bFactor!
  10. rFactor! = 0.5: gFactor! = 1: bFactor! = 0.5
  11.  
  12. For t = 0 To 360 Step .5
  13.     x2 = (Sin(t) * 260) + 400
  14.     y2 = (Cos(t) * 190) + 300
  15.     max_v_index = max_v_index + 1
  16.     vert(max_v_index).x = x2
  17.     vert(max_v_index).y = y2
  18.  
  19. For t = 1 To 359
  20.     For tt = t - 2 To t + 2 Step .5
  21.         x2 = Int((Sin(tt) * 230) + 400)
  22.         y2 = Int((Cos(tt) * 170) + 300)
  23.         max_v_index = max_v_index + 1
  24.         vert(max_v_index).x = x2
  25.         vert(max_v_index).y = y2
  26.     Next tt
  27.  
  28.     _Limit 30
  29.  
  30.     hours = Timer \ 3600
  31.     minutes = Timer \ 60 - hours * 60
  32.     seconds = (Timer - hours * 3600 - minutes * 60)
  33.     ho$ = Left$(Time$, 2): hou = Val(ho$)
  34.     min$ = Mid$(Time$, 4, 2): minu = Val(min$)
  35.     seco$ = Right$(Time$, 2): secon = Val(seco$)
  36.  
  37.     'Minutes
  38.     m = 180 - minutes * 6
  39.     xx = Int(Sin(m / 180 * 3.141592) * 120) + 300
  40.     yy = Int(Cos(m / 180 * 3.141592) * 120) + 304
  41.     For b = -5 To 5 Step .1
  42.         Line (300 + b, 304)-(xx, yy), _RGB32(0, 255, 255)
  43.         Line (300, 304 + b)-(xx, yy), _RGB32(0, 255, 255)
  44.     Next b
  45.     'Hours
  46.     h = 360 - hours * 30 + 180
  47.     xxx = Int(Sin(h / 180 * 3.141592) * 100) + 300
  48.     yyy = Int(Cos(h / 180 * 3.141592) * 100) + 304
  49.     For b = -5 To 5 Step .1
  50.         Line (300 + b, 304)-(xxx, yyy), _RGB32(0, 255, 0)
  51.         Line (300, 304 + b)-(xxx, yyy), _RGB32(0, 255, 0)
  52.     Next b
  53.     'Seconds
  54.     s = (60 - seconds) * 6 + 180
  55.     xxxx = Int(Sin(s / 180 * 3.141592) * 125) + 300
  56.     yyyy = Int(Cos(s / 180 * 3.141592) * 125) + 304
  57.     For b = -5 To 5 Step .1
  58.         Line (300 + b, 304)-(xxxx, yyyy), _RGB32(255, 0, 0)
  59.         Line (300, 304 + b)-(xxxx, yyyy), _RGB32(255, 0, 0)
  60.     Next b
  61.     _Display
  62.     Line (175, 175)-(425, 440), _RGB32(0, 0, 0, 5), BF
  63.  
  64.     'Chimes
  65.     If minu = 0 And secon = 0 Then
  66.         hour2 = hou
  67.         If hour2 > 12 Then hour2 = hour2 - 12
  68.         If hour2 = 0 Then hour2 = 12
  69.         For chimes = 1 To hour2
  70.             ttt = 0
  71.             Do
  72.                 'queue some sound
  73.                 Do While _SndRawLen < 0.1 'you may wish to adjust this
  74.                     sample = Sin(ttt * 340 * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  75.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  76.                     _SndRaw sample
  77.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  78.                 Loop
  79.                 'do other stuff, but it may interrupt sound
  80.             Loop While ttt < 2 'play for 2 seconds
  81.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  82.             Loop
  83.         Next chimes
  84.     End If
  85.     two:
  86.  
  87.  
  88. Sub _GL ()
  89.     Static glInit
  90.     If glInit = 0 Then
  91.         glInit = 1
  92.  
  93.     End If
  94.     'set the gl screen so that it can work normal screen coordinates
  95.     _glTranslatef -1, 1, 0
  96.     _glScalef 1 / 400, -1 / 300, 1
  97.  
  98.     _glEnable _GL_BLEND
  99.  
  100.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  101.     _glEnableClientState _GL_VERTEX_ARRAY
  102.     _glVertexPointer 2, _GL_FLOAT, 0, _Offset(vert())
  103.     For j = 1 To 15
  104.         _glColor4f rFactor!, gFactor!, bFactor!, 0.015
  105.         _glPointSize j
  106.         _glDrawArrays _GL_POINTS, 10, max_v_index
  107.     Next
  108.     _glFlush
  109.  
Neon Clock by SierraKen.jpg
* Neon Clock by SierraKen.jpg (Filesize: 56.22 KB, Dimensions: 600x623, Views: 225)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Neon Clock
« Reply #1 on: March 23, 2022, 01:07:54 pm »
Nice looking clock, could probably be done without _GL.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Neon Clock
« Reply #2 on: March 23, 2022, 01:33:55 pm »
Thanks. I just made it a bit fancier, I added details on the clock and Roman Numerals and added the grandfather clock song for every hour. Plus you can press the space bar to hear it anytime. I also changed the hour hand to be a lot smaller than the other hands. There is a photo below.

Code: QB64: [Select]
  1. _Title "Neon Clock by SierraKen - Press Space Bar to hear hour anytime"
  2. Screen _NewImage(600, 600, 32)
  3.  
  4. Type vec2
  5.     x As Single
  6.     y As Single
  7.  
  8. ReDim Shared vert(4024) As vec2, max_v_index
  9. Dim Shared rFactor!, gFactor!, bFactor!
  10. rFactor! = 0.5: gFactor! = 1: bFactor! = 0.5
  11.  
  12. For t = 0 To 360 Step .5
  13.     x2 = (Sin(t) * 260) + 400
  14.     y2 = (Cos(t) * 190) + 300
  15.     max_v_index = max_v_index + 1
  16.     vert(max_v_index).x = x2
  17.     vert(max_v_index).y = y2
  18.  
  19. For t = 1 To 359
  20.     For tt = t - 2 To t + 2 Step .5
  21.         x2 = Int((Sin(tt) * 230) + 400)
  22.         y2 = Int((Cos(tt) * 170) + 300)
  23.         max_v_index = max_v_index + 1
  24.         vert(max_v_index).x = x2
  25.         vert(max_v_index).y = y2
  26.     Next tt
  27.  
  28.     _Limit 50
  29.     For sc = 1 To 60
  30.         ss = (60 - sc) * 6 + 180
  31.         x4 = Int(Sin(ss / 180 * 3.141592) * 150) + 300
  32.         y4 = Int(Cos(ss / 180 * 3.141592) * 150) + 300
  33.         Circle (x4, y4), 3, _RGB32(230, 230, 230)
  34.         n2 = (60 - sc) * 6 + 180
  35.         x3 = Int(Sin(n2 / 180 * 3.141592) * 140) + 290
  36.         y3 = Int(Cos(n2 / 180 * 3.141592) * 140) + 295
  37.         Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
  38.         If sc = 5 Then _PrintString (x3, y3), "I"
  39.         If sc = 10 Then _PrintString (x3, y3), "II"
  40.         If sc = 15 Then _PrintString (x3, y3), "III"
  41.         If sc = 20 Then _PrintString (x3, y3), "IV"
  42.         If sc = 25 Then _PrintString (x3, y3), "V"
  43.         If sc = 30 Then _PrintString (x3, y3), "VI"
  44.         If sc = 35 Then _PrintString (x3, y3), "VII"
  45.         If sc = 40 Then _PrintString (x3, y3), "VIII"
  46.         If sc = 45 Then _PrintString (x3, y3), "IX"
  47.         If sc = 50 Then _PrintString (x3, y3), "X"
  48.         If sc = 55 Then _PrintString (x3, y3), "XI"
  49.         If sc = 60 Then _PrintString (x3, y3), "XII"
  50.     Next sc
  51.  
  52.     hours = Timer \ 3600
  53.     minutes = Timer \ 60 - hours * 60
  54.     seconds = (Timer - hours * 3600 - minutes * 60)
  55.     ho$ = Left$(Time$, 2): hou = Val(ho$)
  56.     min$ = Mid$(Time$, 4, 2): minu = Val(min$)
  57.     seco$ = Right$(Time$, 2): secon = Val(seco$)
  58.  
  59.     'Minutes
  60.     m = 180 - minutes * 6
  61.     xx = Int(Sin(m / 180 * 3.141592) * 120) + 300
  62.     yy = Int(Cos(m / 180 * 3.141592) * 120) + 304
  63.     For b = -5 To 5 Step .1
  64.         Line (300 + b, 304)-(xx, yy), _RGB32(0, 255, 255)
  65.         Line (300, 304 + b)-(xx, yy), _RGB32(0, 255, 255)
  66.     Next b
  67.     'Hours
  68.     h = 360 - hours * 30 + 180
  69.     xxx = Int(Sin(h / 180 * 3.141592) * 75) + 300
  70.     yyy = Int(Cos(h / 180 * 3.141592) * 75) + 304
  71.     For b = -5 To 5 Step .1
  72.         Line (300 + b, 304)-(xxx, yyy), _RGB32(0, 255, 0)
  73.         Line (300, 304 + b)-(xxx, yyy), _RGB32(0, 255, 0)
  74.     Next b
  75.     'Seconds
  76.     s = (60 - seconds) * 6 + 180
  77.     xxxx = Int(Sin(s / 180 * 3.141592) * 125) + 300
  78.     yyyy = Int(Cos(s / 180 * 3.141592) * 125) + 304
  79.     For b = -5 To 5 Step .1
  80.         Line (300 + b, 304)-(xxxx, yyyy), _RGB32(255, 0, 0)
  81.         Line (300, 304 + b)-(xxxx, yyyy), _RGB32(255, 0, 0)
  82.     Next b
  83.     _Display
  84.     Line (175, 175)-(425, 440), _RGB32(0, 0, 0, 5), BF
  85.  
  86.     'Chimes
  87.     If (minu = 0 And secon = 0) Or song = 1 Then
  88.         song = 0
  89.  
  90.         'note frequencies
  91.         For notes = 1 To 20
  92.             If notes = 1 Then note = 311.13 'D#
  93.             If notes = 2 Then note = 246.94 'B
  94.             If notes = 3 Then note = 277.18 'C#
  95.             If notes = 4 Then note = 185.00 'F#
  96.             If notes = 5 Then note = 0
  97.             If notes = 6 Then note = 185.00 'F#
  98.             If notes = 7 Then note = 277.18 'C#
  99.             If notes = 8 Then note = 311.13 'D#
  100.             If notes = 9 Then note = 246.94 'B
  101.             If notes = 10 Then note = 0
  102.             If notes = 11 Then note = 311.13 'D#
  103.             If notes = 12 Then note = 277.18 'C3
  104.             If notes = 13 Then note = 246.94 'B
  105.             If notes = 14 Then note = 185.00 'F#
  106.             If notes = 15 Then note = 0
  107.             If notes = 16 Then note = 185.00 'F#
  108.             If notes = 17 Then note = 277.18 'C#
  109.             If notes = 18 Then note = 311.13 'D#
  110.             If notes = 19 Then note = 246.94 'B
  111.             If notes = 20 Then note = 0
  112.  
  113.             Do
  114.                 'queue some sound
  115.                 Do While _SndRawLen < 0.5 'you may wish to adjust this
  116.                     sample = Sin(ttt * note * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  117.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  118.                     _SndRaw sample
  119.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  120.                 Loop
  121.                 'do other stuff, but it may interrupt sound
  122.             Loop While ttt < 1 'play for 1 second
  123.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  124.             Loop
  125.             ttt = 0
  126.         Next notes
  127.         hour2 = hou
  128.         If hour2 > 12 Then hour2 = hour2 - 12
  129.         If hour2 = 0 Then hour2 = 12
  130.         For chimes = 1 To hour2
  131.             ttt = 0
  132.             Do
  133.                 'queue some sound
  134.                 Do While _SndRawLen < 0.1 'you may wish to adjust this
  135.                     sample = Sin(ttt * 240 * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  136.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  137.                     _SndRaw sample
  138.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  139.                 Loop
  140.                 'do other stuff, but it may interrupt sound
  141.             Loop While ttt < 2 'play for 2 seconds
  142.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  143.             Loop
  144.         Next chimes
  145.     End If
  146.     two:
  147.     a$ = InKey$
  148.     If a$ = Chr$(27) Then End
  149.     If a$ = " " Then song = 1
  150.  
  151.  
  152. Sub _GL ()
  153.     Static glInit
  154.     If glInit = 0 Then
  155.         glInit = 1
  156.  
  157.     End If
  158.     'set the gl screen so that it can work normal screen coordinates
  159.     _glTranslatef -1, 1, 0
  160.     _glScalef 1 / 400, -1 / 300, 1
  161.  
  162.     _glEnable _GL_BLEND
  163.  
  164.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  165.     _glEnableClientState _GL_VERTEX_ARRAY
  166.     _glVertexPointer 2, _GL_FLOAT, 0, _Offset(vert())
  167.     For j = 1 To 15
  168.         _glColor4f rFactor!, gFactor!, bFactor!, 0.015
  169.         _glPointSize j
  170.         _glDrawArrays _GL_POINTS, 10, max_v_index
  171.     Next
  172.     _glFlush
  173.  
Neon Clock by SierraKen.jpg
* Neon Clock by SierraKen.jpg (Filesize: 73.2 KB, Dimensions: 598x627, Views: 216)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Neon Clock
« Reply #3 on: March 25, 2022, 02:19:24 pm »
Here is another update. It took me 2 days to figure it out but I finally made a clock pendulum for it. It doesn't use gravity or physics like Static's pendulums, but like many small clock pendulums, I tried to make it swing with the seconds. It might not be exact but it's as good as I can get it. One swing is one second. I also realize the first swing is a bit higher than the rest, but I'm not sure why it does that, but that's OK :). Here is a picture of it below and the code. Feel free to use the Pendulum Sub I made or any other code in your projects.

Code: QB64: [Select]
  1. _Title "Neon Clock by SierraKen - Press Space Bar to hear hour anytime"
  2. Screen _NewImage(600, 600, 32)
  3.  
  4. Type vec2
  5.     x As Single
  6.     y As Single
  7.  
  8. ReDim Shared vert(4024) As vec2, max_v_index
  9. Dim Shared rFactor!, gFactor!, bFactor!
  10. rFactor! = 0.5: gFactor! = 1: bFactor! = 0.5
  11.  
  12. For t = 0 To 360 Step .5
  13.     x2 = (Sin(t) * 260) + 400
  14.     y2 = (Cos(t) * 190) + 300
  15.     max_v_index = max_v_index + 1
  16.     vert(max_v_index).x = x2
  17.     vert(max_v_index).y = y2
  18.  
  19. For t = 1 To 359
  20.     For tt = t - 2 To t + 2 Step .5
  21.         x2 = Int((Sin(tt) * 230) + 400)
  22.         y2 = Int((Cos(tt) * 170) + 300)
  23.         max_v_index = max_v_index + 1
  24.         vert(max_v_index).x = x2
  25.         vert(max_v_index).y = y2
  26.     Next tt
  27. tt = 23
  28. d = 0
  29.     _Limit 50
  30.  
  31.     For sc = 1 To 60
  32.         ss = (60 - sc) * 6 + 180
  33.         x4 = Int(Sin(ss / 180 * 3.141592) * 150) + 300
  34.         y4 = Int(Cos(ss / 180 * 3.141592) * 150) + 300
  35.         Circle (x4, y4), 3, _RGB32(230, 230, 230)
  36.         n2 = (60 - sc) * 6 + 180
  37.         x3 = Int(Sin(n2 / 180 * 3.141592) * 140) + 290
  38.         y3 = Int(Cos(n2 / 180 * 3.141592) * 140) + 295
  39.         Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
  40.         If sc = 5 Then _PrintString (x3, y3), "I"
  41.         If sc = 10 Then _PrintString (x3, y3), "II"
  42.         If sc = 15 Then _PrintString (x3, y3), "III"
  43.         If sc = 20 Then _PrintString (x3, y3), "IV"
  44.         If sc = 25 Then _PrintString (x3, y3), "V"
  45.         If sc = 30 Then _PrintString (x3, y3), "VI"
  46.         If sc = 35 Then _PrintString (x3, y3), "VII"
  47.         If sc = 40 Then _PrintString (x3, y3), "VIII"
  48.         If sc = 45 Then _PrintString (x3, y3), "IX"
  49.         If sc = 50 Then _PrintString (x3, y3), "X"
  50.         If sc = 55 Then _PrintString (x3, y3), "XI"
  51.         If sc = 60 Then _PrintString (x3, y3), "XII"
  52.     Next sc
  53.  
  54.     hours = Timer \ 3600
  55.     minutes = Timer \ 60 - hours * 60
  56.     seconds = (Timer - hours * 3600 - minutes * 60)
  57.     ho$ = Left$(Time$, 2): hou = Val(ho$)
  58.     min$ = Mid$(Time$, 4, 2): minu = Val(min$)
  59.     seco$ = Right$(Time$, 2): secon = Val(seco$)
  60.  
  61.     pendulum tt, d
  62.  
  63.     'Minutes
  64.     m = 180 - minutes * 6
  65.     xx = Int(Sin(m / 180 * 3.141592) * 120) + 300
  66.     yy = Int(Cos(m / 180 * 3.141592) * 120) + 304
  67.     For b = -5 To 5 Step .1
  68.         Line (300 + b, 304)-(xx, yy), _RGB32(0, 255, 255)
  69.         Line (300, 304 + b)-(xx, yy), _RGB32(0, 255, 255)
  70.     Next b
  71.     'Hours
  72.     h = 360 - hours * 30 + 180
  73.     xxx = Int(Sin(h / 180 * 3.141592) * 75) + 300
  74.     yyy = Int(Cos(h / 180 * 3.141592) * 75) + 304
  75.     For b = -5 To 5 Step .1
  76.         Line (300 + b, 304)-(xxx, yyy), _RGB32(0, 255, 0)
  77.         Line (300, 304 + b)-(xxx, yyy), _RGB32(0, 255, 0)
  78.     Next b
  79.     'Seconds
  80.     s = (60 - seconds) * 6 + 180
  81.     xxxx = Int(Sin(s / 180 * 3.141592) * 125) + 300
  82.     yyyy = Int(Cos(s / 180 * 3.141592) * 125) + 304
  83.     For b = -5 To 5 Step .1
  84.         Line (300 + b, 304)-(xxxx, yyyy), _RGB32(255, 0, 0)
  85.         Line (300, 304 + b)-(xxxx, yyyy), _RGB32(255, 0, 0)
  86.     Next b
  87.     _Display
  88.     Line (175, 175)-(425, 440), _RGB32(0, 0, 0, 20), BF
  89.  
  90.     'Chimes
  91.     If (minu = 0 And secon = 0) Or song = 1 Then
  92.         song = 0
  93.  
  94.         'note frequencies
  95.         For notes = 1 To 20
  96.             If notes = 1 Then note = 311.13 'D#
  97.             If notes = 2 Then note = 246.94 'B
  98.             If notes = 3 Then note = 277.18 'C#
  99.             If notes = 4 Then note = 185.00 'F#
  100.             If notes = 5 Then note = 0
  101.             If notes = 6 Then note = 185.00 'F#
  102.             If notes = 7 Then note = 277.18 'C#
  103.             If notes = 8 Then note = 311.13 'D#
  104.             If notes = 9 Then note = 246.94 'B
  105.             If notes = 10 Then note = 0
  106.             If notes = 11 Then note = 311.13 'D#
  107.             If notes = 12 Then note = 277.18 'C3
  108.             If notes = 13 Then note = 246.94 'B
  109.             If notes = 14 Then note = 185.00 'F#
  110.             If notes = 15 Then note = 0
  111.             If notes = 16 Then note = 185.00 'F#
  112.             If notes = 17 Then note = 277.18 'C#
  113.             If notes = 18 Then note = 311.13 'D#
  114.             If notes = 19 Then note = 246.94 'B
  115.             If notes = 20 Then note = 0
  116.  
  117.             Do
  118.                 'queue some sound
  119.                 Do While _SndRawLen < 0.5 'you may wish to adjust this
  120.                     sample = Sin(ttt * note * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  121.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  122.                     _SndRaw sample
  123.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  124.                 Loop
  125.                 'do other stuff, but it may interrupt sound
  126.             Loop While ttt < 1 'play for 1 second
  127.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  128.             Loop
  129.             ttt = 0
  130.         Next notes
  131.         hour2 = hou
  132.         If hour2 > 12 Then hour2 = hour2 - 12
  133.         If hour2 = 0 Then hour2 = 12
  134.         For chimes = 1 To hour2
  135.             ttt = 0
  136.             Do
  137.                 'queue some sound
  138.                 Do While _SndRawLen < 0.1 'you may wish to adjust this
  139.                     sample = Sin(ttt * 240 * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  140.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  141.                     _SndRaw sample
  142.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  143.                 Loop
  144.                 'do other stuff, but it may interrupt sound
  145.             Loop While ttt < 2 'play for 2 seconds
  146.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  147.             Loop
  148.         Next chimes
  149.     End If
  150.     two:
  151.     a$ = InKey$
  152.     If a$ = Chr$(27) Then End
  153.     If a$ = " " Then song = 1
  154.  
  155.  
  156. Sub pendulum (tt, d)
  157.     If d = 0 Then tt = tt + (.26 / 2)
  158.     If d = 1 Then tt = tt - (.26 / 2)
  159.     If tt < 24.25 Then d = 0
  160.     If tt > 26 Then d = 1
  161.     x5 = (Sin(tt) * 80) + 300
  162.     y5 = (Cos(tt) * 80) + 300
  163.     For sz = -3 To 4
  164.         Line (300 + sz, 300)-(x5, y5), _RGB32(255, 255, 127)
  165.         Line (300, 300 + sz)-(x5, y5), _RGB32(255, 255, 127)
  166.     Next sz
  167.     For sz = .1 To 15 Step .1
  168.         Circle (x5, y5), sz, _RGB32(255, 255, 127)
  169.     Next sz
  170.     _Delay .06
  171.     _Display
  172.  
  173. Sub _GL ()
  174.     Static glInit
  175.     If glInit = 0 Then
  176.         glInit = 1
  177.  
  178.     End If
  179.     'set the gl screen so that it can work normal screen coordinates
  180.     _glTranslatef -1, 1, 0
  181.     _glScalef 1 / 400, -1 / 300, 1
  182.  
  183.     _glEnable _GL_BLEND
  184.  
  185.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  186.     _glEnableClientState _GL_VERTEX_ARRAY
  187.     _glVertexPointer 2, _GL_FLOAT, 0, _Offset(vert())
  188.     For j = 1 To 15
  189.         _glColor4f rFactor!, gFactor!, bFactor!, 0.015
  190.         _glPointSize j
  191.         _glDrawArrays _GL_POINTS, 10, max_v_index
  192.     Next
  193.     _glFlush
  194.  

Neon Clock by SierraKen.jpg
* Neon Clock by SierraKen.jpg (Filesize: 78.49 KB, Dimensions: 600x624, Views: 207)

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Neon Clock
« Reply #4 on: March 25, 2022, 03:21:51 pm »
Oh dear. I enjoyed the original version... Now there is no challenge to look forward to when trying to guess the correct time... But I do so like Roman Numerals... Eventually, if modifications continue, press a specific key and the computer will "tell" you the time... I miss the guessing *sigh*
Logic is the beginning of wisdom.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Neon Clock
« Reply #5 on: March 25, 2022, 03:29:12 pm »
Wow Johno, I wondered about that. I'll make 2 selections, one with and one without the inside details, except for the pendulum and hands. I'll also add a key to press for it to speak the time, thanks for the suggestions!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Neon Clock
« Reply #6 on: March 25, 2022, 04:26:17 pm »
I added the computer to speak the time, in AM and PM when you press S. I also added a selections page before the clock starts to either see the Roman Numerals or not. During the clock you can also turn them off and on with 1 and 2. And of course there's the space bar that plays the chimes anytime. All of these selections are on the Title Bar. I also added a small round knob in the center of the clock.

Code: QB64: [Select]
  1. _Title "1 Without Numerals  2 With Numerals  S Speak Time  Space Bar For Chimes"
  2. Screen _NewImage(600, 600, 32)
  3.  
  4. Type vec2
  5.     x As Single
  6.     y As Single
  7. Print "Neon Clock Selections"
  8. Print "----------------------------------"
  9. Print "(1) Without Roman Numerals"
  10. Print "(2) With Roman Numerals"
  11. Print "You can also press 1 or 2 anytime."
  12. Print "->";
  13.     sel$ = InKey$
  14.     If sel$ = "1" Then rom = 0: GoTo nexxx:
  15.     If sel$ = "2" Then rom = 1: GoTo nexxx:
  16. nexxx:
  17. ReDim Shared vert(4024) As vec2, max_v_index
  18. Dim Shared rFactor!, gFactor!, bFactor!
  19. rFactor! = 0.5: gFactor! = 1: bFactor! = 0.5
  20.  
  21. For t = 0 To 360 Step .5
  22.     x2 = (Sin(t) * 260) + 400
  23.     y2 = (Cos(t) * 190) + 300
  24.     max_v_index = max_v_index + 1
  25.     vert(max_v_index).x = x2
  26.     vert(max_v_index).y = y2
  27.  
  28. For t = 1 To 359
  29.     For tt = t - 2 To t + 2 Step .5
  30.         x2 = Int((Sin(tt) * 230) + 400)
  31.         y2 = Int((Cos(tt) * 170) + 300)
  32.         max_v_index = max_v_index + 1
  33.         vert(max_v_index).x = x2
  34.         vert(max_v_index).y = y2
  35.     Next tt
  36. tt = 23
  37. d = 0
  38.     _Limit 50
  39.     If rom = 0 Then GoTo skip:
  40.     For sc = 1 To 60
  41.         ss = (60 - sc) * 6 + 180
  42.         x4 = Int(Sin(ss / 180 * 3.141592) * 150) + 300
  43.         y4 = Int(Cos(ss / 180 * 3.141592) * 150) + 300
  44.         Circle (x4, y4), 3, _RGB32(230, 230, 230)
  45.         n2 = (60 - sc) * 6 + 180
  46.         x3 = Int(Sin(n2 / 180 * 3.141592) * 140) + 290
  47.         y3 = Int(Cos(n2 / 180 * 3.141592) * 140) + 295
  48.         Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
  49.         If sc = 5 Then _PrintString (x3, y3), "I"
  50.         If sc = 10 Then _PrintString (x3, y3), "II"
  51.         If sc = 15 Then _PrintString (x3, y3), "III"
  52.         If sc = 20 Then _PrintString (x3, y3), "IV"
  53.         If sc = 25 Then _PrintString (x3, y3), "V"
  54.         If sc = 30 Then _PrintString (x3, y3), "VI"
  55.         If sc = 35 Then _PrintString (x3, y3), "VII"
  56.         If sc = 40 Then _PrintString (x3, y3), "VIII"
  57.         If sc = 45 Then _PrintString (x3, y3), "IX"
  58.         If sc = 50 Then _PrintString (x3, y3), "X"
  59.         If sc = 55 Then _PrintString (x3, y3), "XI"
  60.         If sc = 60 Then _PrintString (x3, y3), "XII"
  61.     Next sc
  62.     skip:
  63.     hours = Timer \ 3600
  64.     minutes = Timer \ 60 - hours * 60
  65.     seconds = (Timer - hours * 3600 - minutes * 60)
  66.     ho$ = Left$(Time$, 2): hou = Val(ho$)
  67.     min$ = Mid$(Time$, 4, 2): minu = Val(min$)
  68.     seco$ = Right$(Time$, 2): secon = Val(seco$)
  69.  
  70.     pendulum tt, d
  71.  
  72.     'Minutes
  73.     m = 180 - minutes * 6
  74.     xx = Int(Sin(m / 180 * 3.141592) * 120) + 300
  75.     yy = Int(Cos(m / 180 * 3.141592) * 120) + 304
  76.     For b = -5 To 5 Step .1
  77.         Line (300 + b, 304)-(xx, yy), _RGB32(0, 255, 255)
  78.         Line (300, 304 + b)-(xx, yy), _RGB32(0, 255, 255)
  79.     Next b
  80.     'Hours
  81.     h = 360 - hours * 30 + 180
  82.     xxx = Int(Sin(h / 180 * 3.141592) * 75) + 300
  83.     yyy = Int(Cos(h / 180 * 3.141592) * 75) + 304
  84.     For b = -5 To 5 Step .1
  85.         Line (300 + b, 304)-(xxx, yyy), _RGB32(0, 255, 0)
  86.         Line (300, 304 + b)-(xxx, yyy), _RGB32(0, 255, 0)
  87.     Next b
  88.     'Seconds
  89.     s = (60 - seconds) * 6 + 180
  90.     xxxx = Int(Sin(s / 180 * 3.141592) * 125) + 300
  91.     yyyy = Int(Cos(s / 180 * 3.141592) * 125) + 304
  92.     For b = -5 To 5 Step .1
  93.         Line (300 + b, 304)-(xxxx, yyyy), _RGB32(255, 0, 0)
  94.         Line (300, 304 + b)-(xxxx, yyyy), _RGB32(255, 0, 0)
  95.     Next b
  96.     For sz = .1 To 10 Step .1
  97.         Circle (300, 300), sz, _RGB32(255, 255, 127)
  98.     Next sz
  99.  
  100.     _Display
  101.     Line (175, 175)-(425, 440), _RGB32(0, 0, 0, 20), BF
  102.  
  103.     'Chimes
  104.     If (minu = 0 And secon = 0) Or song = 1 Then
  105.         song = 0
  106.  
  107.         'note frequencies
  108.         For notes = 1 To 20
  109.             If notes = 1 Then note = 311.13 'D#
  110.             If notes = 2 Then note = 246.94 'B
  111.             If notes = 3 Then note = 277.18 'C#
  112.             If notes = 4 Then note = 185.00 'F#
  113.             If notes = 5 Then note = 0
  114.             If notes = 6 Then note = 185.00 'F#
  115.             If notes = 7 Then note = 277.18 'C#
  116.             If notes = 8 Then note = 311.13 'D#
  117.             If notes = 9 Then note = 246.94 'B
  118.             If notes = 10 Then note = 0
  119.             If notes = 11 Then note = 311.13 'D#
  120.             If notes = 12 Then note = 277.18 'C3
  121.             If notes = 13 Then note = 246.94 'B
  122.             If notes = 14 Then note = 185.00 'F#
  123.             If notes = 15 Then note = 0
  124.             If notes = 16 Then note = 185.00 'F#
  125.             If notes = 17 Then note = 277.18 'C#
  126.             If notes = 18 Then note = 311.13 'D#
  127.             If notes = 19 Then note = 246.94 'B
  128.             If notes = 20 Then note = 0
  129.  
  130.             Do
  131.                 'queue some sound
  132.                 Do While _SndRawLen < 0.5 'you may wish to adjust this
  133.                     sample = Sin(ttt * note * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  134.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  135.                     _SndRaw sample
  136.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  137.                 Loop
  138.                 'do other stuff, but it may interrupt sound
  139.             Loop While ttt < 1 'play for 1 second
  140.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  141.             Loop
  142.             ttt = 0
  143.         Next notes
  144.         hour2 = hou
  145.         If hour2 > 12 Then hour2 = hour2 - 12
  146.         If hour2 = 0 Then hour2 = 12
  147.         For chimes = 1 To hour2
  148.             ttt = 0
  149.             Do
  150.                 'queue some sound
  151.                 Do While _SndRawLen < 0.1 'you may wish to adjust this
  152.                     sample = Sin(ttt * 240 * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  153.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  154.                     _SndRaw sample
  155.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  156.                 Loop
  157.                 'do other stuff, but it may interrupt sound
  158.             Loop While ttt < 2 'play for 2 seconds
  159.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  160.             Loop
  161.         Next chimes
  162.     End If
  163.     two:
  164.     a$ = InKey$
  165.     If a$ = Chr$(27) Then End
  166.     If a$ = " " Then song = 1
  167.     If a$ = "1" Then
  168.         rom = 0
  169.         For sz = .1 To 180 Step .1
  170.             Circle (300, 300), sz, _RGB32(0, 0, 0)
  171.         Next sz
  172.     End If
  173.     If a$ = "2" Then rom = 1
  174.     If a$ = "s" Or a$ = "S" Then
  175.         hour2 = hou
  176.         If hour2 > 12 Then
  177.             hour2 = hour2 - 12
  178.             ampm$ = "P M"
  179.         Else
  180.             ampm$ = "A M"
  181.         End If
  182.         hour3$ = Str$(hour2)
  183.         hour4 = Val(hour3$)
  184.         hour5$ = Str$(hour4)
  185.         min2 = Val(min$)
  186.         min3$ = Str$(min2)
  187.         seco2 = Val(seco$)
  188.         seco3$ = Str$(seco2)
  189.         sentence$ = "The time is " + hour5$ + ampm$ + min3$ + " minutes and " + seco3$ + " seconds."
  190.         speak sentence$, 1, 0
  191.     End If
  192.  
  193.  
  194. Sub pendulum (tt, d)
  195.     If d = 0 Then tt = tt + (.26 / 2)
  196.     If d = 1 Then tt = tt - (.26 / 2)
  197.     If tt < 24.25 Then d = 0
  198.     If tt > 26 Then d = 1
  199.     x5 = (Sin(tt) * 80) + 300
  200.     y5 = (Cos(tt) * 80) + 300
  201.     For sz = -3 To 4
  202.         Line (300 + sz, 300)-(x5, y5), _RGB32(255, 255, 127)
  203.         Line (300, 300 + sz)-(x5, y5), _RGB32(255, 255, 127)
  204.     Next sz
  205.     For sz = .1 To 15 Step .1
  206.         Circle (x5, y5), sz, _RGB32(255, 255, 127)
  207.     Next sz
  208.     _Delay .06
  209.     _Display
  210.  
  211. Sub _GL ()
  212.     Static glInit
  213.     If glInit = 0 Then
  214.         glInit = 1
  215.  
  216.     End If
  217.     'set the gl screen so that it can work normal screen coordinates
  218.     _glTranslatef -1, 1, 0
  219.     _glScalef 1 / 400, -1 / 300, 1
  220.  
  221.     _glEnable _GL_BLEND
  222.  
  223.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  224.     _glEnableClientState _GL_VERTEX_ARRAY
  225.     _glVertexPointer 2, _GL_FLOAT, 0, _Offset(vert())
  226.     For j = 1 To 15
  227.         _glColor4f rFactor!, gFactor!, bFactor!, 0.015
  228.         _glPointSize j
  229.         _glDrawArrays _GL_POINTS, 10, max_v_index
  230.     Next
  231.     _glFlush
  232.  
  233. Sub speak (text As String, Speaker As Integer, Speed)
  234.     Dim message As String, remove$, out$
  235.     Dim As Long i, j
  236.     message = text
  237.     'some symbols and such can't be used with Powershell like this, as they're command symbols
  238.     'we need to strip them out of our text.  (Like apostrophes!)
  239.     remove$ = "'" + Chr$(34) 'add to remove$ here, if more symbols need to be removed as future testing showcases problems
  240.     For j = 1 To Len(remove$)
  241.         Do
  242.             i = InStr(message, Mid$(remove$, j, 1))
  243.             If i Then message = Left$(message, i - 1) + Mid$(message, i + 1)
  244.         Loop Until i = 0
  245.     Next
  246.     out$ = "Powershell -Command " + Chr$(34)
  247.     out$ = out$ + "Add-Type -AssemblyName System.Speech; "
  248.     out$ = out$ + "$Speech = New-Object System.Speech.Synthesis.SpeechSynthesizer; "
  249.     If Speaker = 0 Then out$ = out$ + "$Speech.SelectVoice('Microsoft David Desktop'); "
  250.     If Speaker = 1 Then out$ = out$ + "$Speech.SelectVoice('Microsoft Zira Desktop'); "
  251.     If Speed Then out$ = out$ + "$Speech.Rate =" + Str$(Speed) + "; "
  252.     out$ = out$ + "$Speech.Speak('" + message + "');" + Chr$(34)
  253.     Shell _Hide out$
  254.  

Neon Clock by SierraKen.jpg
* Neon Clock by SierraKen.jpg (Filesize: 84.68 KB, Dimensions: 602x628, Views: 208)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Neon Clock
« Reply #7 on: March 25, 2022, 04:45:37 pm »
I forgot hour zero, which is 12 AM. Here is the update:

Code: QB64: [Select]
  1. _Title "1 Without Numerals  2 With Numerals  S Speak Time  Space Bar For Chimes"
  2. Screen _NewImage(600, 600, 32)
  3.  
  4. Type vec2
  5.     x As Single
  6.     y As Single
  7. Print "Neon Clock Selections"
  8. Print "----------------------------------"
  9. Print "(1) Without Roman Numerals"
  10. Print "(2) With Roman Numerals"
  11. Print "You can also press 1 or 2 anytime."
  12. Print "->";
  13.     sel$ = InKey$
  14.     If sel$ = "1" Then rom = 0: GoTo nexxx:
  15.     If sel$ = "2" Then rom = 1: GoTo nexxx:
  16. nexxx:
  17. ReDim Shared vert(4024) As vec2, max_v_index
  18. Dim Shared rFactor!, gFactor!, bFactor!
  19. rFactor! = 0.5: gFactor! = 1: bFactor! = 0.5
  20.  
  21. For t = 0 To 360 Step .5
  22.     x2 = (Sin(t) * 260) + 400
  23.     y2 = (Cos(t) * 190) + 300
  24.     max_v_index = max_v_index + 1
  25.     vert(max_v_index).x = x2
  26.     vert(max_v_index).y = y2
  27.  
  28. For t = 1 To 359
  29.     For tt = t - 2 To t + 2 Step .5
  30.         x2 = Int((Sin(tt) * 230) + 400)
  31.         y2 = Int((Cos(tt) * 170) + 300)
  32.         max_v_index = max_v_index + 1
  33.         vert(max_v_index).x = x2
  34.         vert(max_v_index).y = y2
  35.     Next tt
  36. tt = 23
  37. d = 0
  38.     _Limit 50
  39.     If rom = 0 Then GoTo skip:
  40.     For sc = 1 To 60
  41.         ss = (60 - sc) * 6 + 180
  42.         x4 = Int(Sin(ss / 180 * 3.141592) * 150) + 300
  43.         y4 = Int(Cos(ss / 180 * 3.141592) * 150) + 300
  44.         Circle (x4, y4), 3, _RGB32(230, 230, 230)
  45.         n2 = (60 - sc) * 6 + 180
  46.         x3 = Int(Sin(n2 / 180 * 3.141592) * 140) + 290
  47.         y3 = Int(Cos(n2 / 180 * 3.141592) * 140) + 295
  48.         Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
  49.         If sc = 5 Then _PrintString (x3, y3), "I"
  50.         If sc = 10 Then _PrintString (x3, y3), "II"
  51.         If sc = 15 Then _PrintString (x3, y3), "III"
  52.         If sc = 20 Then _PrintString (x3, y3), "IV"
  53.         If sc = 25 Then _PrintString (x3, y3), "V"
  54.         If sc = 30 Then _PrintString (x3, y3), "VI"
  55.         If sc = 35 Then _PrintString (x3, y3), "VII"
  56.         If sc = 40 Then _PrintString (x3, y3), "VIII"
  57.         If sc = 45 Then _PrintString (x3, y3), "IX"
  58.         If sc = 50 Then _PrintString (x3, y3), "X"
  59.         If sc = 55 Then _PrintString (x3, y3), "XI"
  60.         If sc = 60 Then _PrintString (x3, y3), "XII"
  61.     Next sc
  62.     skip:
  63.     hours = Timer \ 3600
  64.     minutes = Timer \ 60 - hours * 60
  65.     seconds = (Timer - hours * 3600 - minutes * 60)
  66.     ho$ = Left$(Time$, 2): hou = Val(ho$)
  67.     min$ = Mid$(Time$, 4, 2): minu = Val(min$)
  68.     seco$ = Right$(Time$, 2): secon = Val(seco$)
  69.  
  70.     pendulum tt, d
  71.  
  72.     'Minutes
  73.     m = 180 - minutes * 6
  74.     xx = Int(Sin(m / 180 * 3.141592) * 120) + 300
  75.     yy = Int(Cos(m / 180 * 3.141592) * 120) + 304
  76.     For b = -5 To 5 Step .1
  77.         Line (300 + b, 304)-(xx, yy), _RGB32(0, 255, 255)
  78.         Line (300, 304 + b)-(xx, yy), _RGB32(0, 255, 255)
  79.     Next b
  80.     'Hours
  81.     h = 360 - hours * 30 + 180
  82.     xxx = Int(Sin(h / 180 * 3.141592) * 75) + 300
  83.     yyy = Int(Cos(h / 180 * 3.141592) * 75) + 304
  84.     For b = -5 To 5 Step .1
  85.         Line (300 + b, 304)-(xxx, yyy), _RGB32(0, 255, 0)
  86.         Line (300, 304 + b)-(xxx, yyy), _RGB32(0, 255, 0)
  87.     Next b
  88.     'Seconds
  89.     s = (60 - seconds) * 6 + 180
  90.     xxxx = Int(Sin(s / 180 * 3.141592) * 125) + 300
  91.     yyyy = Int(Cos(s / 180 * 3.141592) * 125) + 304
  92.     For b = -5 To 5 Step .1
  93.         Line (300 + b, 304)-(xxxx, yyyy), _RGB32(255, 0, 0)
  94.         Line (300, 304 + b)-(xxxx, yyyy), _RGB32(255, 0, 0)
  95.     Next b
  96.     For sz = .1 To 10 Step .1
  97.         Circle (300, 300), sz, _RGB32(255, 255, 127)
  98.     Next sz
  99.  
  100.     _Display
  101.     Line (175, 175)-(425, 440), _RGB32(0, 0, 0, 20), BF
  102.  
  103.     'Chimes
  104.     If (minu = 0 And secon = 0) Or song = 1 Then
  105.         song = 0
  106.  
  107.         'note frequencies
  108.         For notes = 1 To 20
  109.             If notes = 1 Then note = 311.13 'D#
  110.             If notes = 2 Then note = 246.94 'B
  111.             If notes = 3 Then note = 277.18 'C#
  112.             If notes = 4 Then note = 185.00 'F#
  113.             If notes = 5 Then note = 0
  114.             If notes = 6 Then note = 185.00 'F#
  115.             If notes = 7 Then note = 277.18 'C#
  116.             If notes = 8 Then note = 311.13 'D#
  117.             If notes = 9 Then note = 246.94 'B
  118.             If notes = 10 Then note = 0
  119.             If notes = 11 Then note = 311.13 'D#
  120.             If notes = 12 Then note = 277.18 'C3
  121.             If notes = 13 Then note = 246.94 'B
  122.             If notes = 14 Then note = 185.00 'F#
  123.             If notes = 15 Then note = 0
  124.             If notes = 16 Then note = 185.00 'F#
  125.             If notes = 17 Then note = 277.18 'C#
  126.             If notes = 18 Then note = 311.13 'D#
  127.             If notes = 19 Then note = 246.94 'B
  128.             If notes = 20 Then note = 0
  129.  
  130.             Do
  131.                 'queue some sound
  132.                 Do While _SndRawLen < 0.5 'you may wish to adjust this
  133.                     sample = Sin(ttt * note * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  134.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  135.                     _SndRaw sample
  136.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  137.                 Loop
  138.                 'do other stuff, but it may interrupt sound
  139.             Loop While ttt < 1 'play for 1 second
  140.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  141.             Loop
  142.             ttt = 0
  143.         Next notes
  144.         hour2 = hou
  145.         If hour2 > 12 Then hour2 = hour2 - 12
  146.         If hour2 = 0 Then hour2 = 12
  147.         For chimes = 1 To hour2
  148.             ttt = 0
  149.             Do
  150.                 'queue some sound
  151.                 Do While _SndRawLen < 0.1 'you may wish to adjust this
  152.                     sample = Sin(ttt * 240 * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  153.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  154.                     _SndRaw sample
  155.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  156.                 Loop
  157.                 'do other stuff, but it may interrupt sound
  158.             Loop While ttt < 2 'play for 2 seconds
  159.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  160.             Loop
  161.         Next chimes
  162.     End If
  163.     two:
  164.     a$ = InKey$
  165.     If a$ = Chr$(27) Then End
  166.     If a$ = " " Then song = 1
  167.     If a$ = "1" Then
  168.         rom = 0
  169.         For sz = .1 To 180 Step .1
  170.             Circle (300, 300), sz, _RGB32(0, 0, 0)
  171.         Next sz
  172.     End If
  173.     If a$ = "2" Then rom = 1
  174.     If a$ = "s" Or a$ = "S" Then
  175.         hour2 = hou
  176.         If hour2 > 12 Then
  177.             hour2 = hour2 - 12
  178.             ampm$ = "P M"
  179.         Else
  180.             ampm$ = "A M"
  181.         End If
  182.         hour3$ = Str$(hour2)
  183.         hour4 = Val(hour3$)
  184.         If hour4 = 0 Then hour4 = 12
  185.         hour5$ = Str$(hour4)
  186.         min2 = Val(min$)
  187.         min3$ = Str$(min2)
  188.         seco2 = Val(seco$)
  189.         seco3$ = Str$(seco2)
  190.         sentence$ = "The time is " + hour5$ + ampm$ + min3$ + " minutes and " + seco3$ + " seconds."
  191.         speak sentence$, 1, 0
  192.     End If
  193.  
  194.  
  195. Sub pendulum (tt, d)
  196.     If d = 0 Then tt = tt + (.26 / 2)
  197.     If d = 1 Then tt = tt - (.26 / 2)
  198.     If tt < 24.25 Then d = 0
  199.     If tt > 26 Then d = 1
  200.     x5 = (Sin(tt) * 80) + 300
  201.     y5 = (Cos(tt) * 80) + 300
  202.     For sz = -3 To 4
  203.         Line (300 + sz, 300)-(x5, y5), _RGB32(255, 255, 127)
  204.         Line (300, 300 + sz)-(x5, y5), _RGB32(255, 255, 127)
  205.     Next sz
  206.     For sz = .1 To 15 Step .1
  207.         Circle (x5, y5), sz, _RGB32(255, 255, 127)
  208.     Next sz
  209.     _Delay .06
  210.     _Display
  211.  
  212. Sub _GL ()
  213.     Static glInit
  214.     If glInit = 0 Then
  215.         glInit = 1
  216.  
  217.     End If
  218.     'set the gl screen so that it can work normal screen coordinates
  219.     _glTranslatef -1, 1, 0
  220.     _glScalef 1 / 400, -1 / 300, 1
  221.  
  222.     _glEnable _GL_BLEND
  223.  
  224.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  225.     _glEnableClientState _GL_VERTEX_ARRAY
  226.     _glVertexPointer 2, _GL_FLOAT, 0, _Offset(vert())
  227.     For j = 1 To 15
  228.         _glColor4f rFactor!, gFactor!, bFactor!, 0.015
  229.         _glPointSize j
  230.         _glDrawArrays _GL_POINTS, 10, max_v_index
  231.     Next
  232.     _glFlush
  233.  
  234. Sub speak (text As String, Speaker As Integer, Speed)
  235.     Dim message As String, remove$, out$
  236.     Dim As Long i, j
  237.     message = text
  238.     'some symbols and such can't be used with Powershell like this, as they're command symbols
  239.     'we need to strip them out of our text.  (Like apostrophes!)
  240.     remove$ = "'" + Chr$(34) 'add to remove$ here, if more symbols need to be removed as future testing showcases problems
  241.     For j = 1 To Len(remove$)
  242.         Do
  243.             i = InStr(message, Mid$(remove$, j, 1))
  244.             If i Then message = Left$(message, i - 1) + Mid$(message, i + 1)
  245.         Loop Until i = 0
  246.     Next
  247.     out$ = "Powershell -Command " + Chr$(34)
  248.     out$ = out$ + "Add-Type -AssemblyName System.Speech; "
  249.     out$ = out$ + "$Speech = New-Object System.Speech.Synthesis.SpeechSynthesizer; "
  250.     If Speaker = 0 Then out$ = out$ + "$Speech.SelectVoice('Microsoft David Desktop'); "
  251.     If Speaker = 1 Then out$ = out$ + "$Speech.SelectVoice('Microsoft Zira Desktop'); "
  252.     If Speed Then out$ = out$ + "$Speech.Rate =" + Str$(Speed) + "; "
  253.     out$ = out$ + "$Speech.Speak('" + message + "');" + Chr$(34)
  254.     Shell _Hide out$
  255.  

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Neon Clock
« Reply #8 on: March 25, 2022, 05:14:26 pm »
Slight change again. I had to fix the AM/PM at 12 PM.

Code: QB64: [Select]
  1. _Title "1 Without Numerals  2 With Numerals  S Speak Time  Space Bar For Chimes"
  2. Screen _NewImage(600, 600, 32)
  3.  
  4. Type vec2
  5.     x As Single
  6.     y As Single
  7. Print "Neon Clock Selections"
  8. Print "----------------------------------"
  9. Print "(1) Without Roman Numerals"
  10. Print "(2) With Roman Numerals"
  11. Print "You can also press 1 or 2 anytime."
  12. Print "->";
  13.     sel$ = InKey$
  14.     If sel$ = "1" Then rom = 0: GoTo nexxx:
  15.     If sel$ = "2" Then rom = 1: GoTo nexxx:
  16. nexxx:
  17. ReDim Shared vert(4024) As vec2, max_v_index
  18. Dim Shared rFactor!, gFactor!, bFactor!
  19. rFactor! = 0.5: gFactor! = 1: bFactor! = 0.5
  20.  
  21. For t = 0 To 360 Step .5
  22.     x2 = (Sin(t) * 260) + 400
  23.     y2 = (Cos(t) * 190) + 300
  24.     max_v_index = max_v_index + 1
  25.     vert(max_v_index).x = x2
  26.     vert(max_v_index).y = y2
  27.  
  28. For t = 1 To 359
  29.     For tt = t - 2 To t + 2 Step .5
  30.         x2 = Int((Sin(tt) * 230) + 400)
  31.         y2 = Int((Cos(tt) * 170) + 300)
  32.         max_v_index = max_v_index + 1
  33.         vert(max_v_index).x = x2
  34.         vert(max_v_index).y = y2
  35.     Next tt
  36. tt = 23
  37. d = 0
  38.     _Limit 50
  39.     If rom = 0 Then GoTo skip:
  40.     For sc = 1 To 60
  41.         ss = (60 - sc) * 6 + 180
  42.         x4 = Int(Sin(ss / 180 * 3.141592) * 150) + 300
  43.         y4 = Int(Cos(ss / 180 * 3.141592) * 150) + 300
  44.         Circle (x4, y4), 3, _RGB32(230, 230, 230)
  45.         n2 = (60 - sc) * 6 + 180
  46.         x3 = Int(Sin(n2 / 180 * 3.141592) * 140) + 290
  47.         y3 = Int(Cos(n2 / 180 * 3.141592) * 140) + 295
  48.         Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
  49.         If sc = 5 Then _PrintString (x3, y3), "I"
  50.         If sc = 10 Then _PrintString (x3, y3), "II"
  51.         If sc = 15 Then _PrintString (x3, y3), "III"
  52.         If sc = 20 Then _PrintString (x3, y3), "IV"
  53.         If sc = 25 Then _PrintString (x3, y3), "V"
  54.         If sc = 30 Then _PrintString (x3, y3), "VI"
  55.         If sc = 35 Then _PrintString (x3, y3), "VII"
  56.         If sc = 40 Then _PrintString (x3, y3), "VIII"
  57.         If sc = 45 Then _PrintString (x3, y3), "IX"
  58.         If sc = 50 Then _PrintString (x3, y3), "X"
  59.         If sc = 55 Then _PrintString (x3, y3), "XI"
  60.         If sc = 60 Then _PrintString (x3, y3), "XII"
  61.     Next sc
  62.     skip:
  63.     hours = Timer \ 3600
  64.     minutes = Timer \ 60 - hours * 60
  65.     seconds = (Timer - hours * 3600 - minutes * 60)
  66.     ho$ = Left$(Time$, 2): hou = Val(ho$)
  67.     min$ = Mid$(Time$, 4, 2): minu = Val(min$)
  68.     seco$ = Right$(Time$, 2): secon = Val(seco$)
  69.  
  70.     pendulum tt, d
  71.  
  72.     'Minutes
  73.     m = 180 - minutes * 6
  74.     xx = Int(Sin(m / 180 * 3.141592) * 120) + 300
  75.     yy = Int(Cos(m / 180 * 3.141592) * 120) + 304
  76.     For b = -5 To 5 Step .1
  77.         Line (300 + b, 304)-(xx, yy), _RGB32(0, 255, 255)
  78.         Line (300, 304 + b)-(xx, yy), _RGB32(0, 255, 255)
  79.     Next b
  80.     'Hours
  81.     h = 360 - hours * 30 + 180
  82.     xxx = Int(Sin(h / 180 * 3.141592) * 75) + 300
  83.     yyy = Int(Cos(h / 180 * 3.141592) * 75) + 304
  84.     For b = -5 To 5 Step .1
  85.         Line (300 + b, 304)-(xxx, yyy), _RGB32(0, 255, 0)
  86.         Line (300, 304 + b)-(xxx, yyy), _RGB32(0, 255, 0)
  87.     Next b
  88.     'Seconds
  89.     s = (60 - seconds) * 6 + 180
  90.     xxxx = Int(Sin(s / 180 * 3.141592) * 125) + 300
  91.     yyyy = Int(Cos(s / 180 * 3.141592) * 125) + 304
  92.     For b = -5 To 5 Step .1
  93.         Line (300 + b, 304)-(xxxx, yyyy), _RGB32(255, 0, 0)
  94.         Line (300, 304 + b)-(xxxx, yyyy), _RGB32(255, 0, 0)
  95.     Next b
  96.     For sz = .1 To 10 Step .1
  97.         Circle (300, 300), sz, _RGB32(255, 255, 127)
  98.     Next sz
  99.  
  100.     _Display
  101.     Line (175, 175)-(425, 440), _RGB32(0, 0, 0, 20), BF
  102.  
  103.     'Chimes
  104.     If (minu = 0 And secon = 0) Or song = 1 Then
  105.         song = 0
  106.  
  107.         'note frequencies
  108.         For notes = 1 To 20
  109.             If notes = 1 Then note = 311.13 'D#
  110.             If notes = 2 Then note = 246.94 'B
  111.             If notes = 3 Then note = 277.18 'C#
  112.             If notes = 4 Then note = 185.00 'F#
  113.             If notes = 5 Then note = 0
  114.             If notes = 6 Then note = 185.00 'F#
  115.             If notes = 7 Then note = 277.18 'C#
  116.             If notes = 8 Then note = 311.13 'D#
  117.             If notes = 9 Then note = 246.94 'B
  118.             If notes = 10 Then note = 0
  119.             If notes = 11 Then note = 311.13 'D#
  120.             If notes = 12 Then note = 277.18 'C3
  121.             If notes = 13 Then note = 246.94 'B
  122.             If notes = 14 Then note = 185.00 'F#
  123.             If notes = 15 Then note = 0
  124.             If notes = 16 Then note = 185.00 'F#
  125.             If notes = 17 Then note = 277.18 'C#
  126.             If notes = 18 Then note = 311.13 'D#
  127.             If notes = 19 Then note = 246.94 'B
  128.             If notes = 20 Then note = 0
  129.  
  130.             Do
  131.                 'queue some sound
  132.                 Do While _SndRawLen < 0.5 'you may wish to adjust this
  133.                     sample = Sin(ttt * note * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  134.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  135.                     _SndRaw sample
  136.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  137.                 Loop
  138.                 'do other stuff, but it may interrupt sound
  139.             Loop While ttt < 1 'play for 1 second
  140.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  141.             Loop
  142.             ttt = 0
  143.         Next notes
  144.         hour2 = hou
  145.         If hour2 > 12 Then hour2 = hour2 - 12
  146.         If hour2 = 0 Then hour2 = 12
  147.         For chimes = 1 To hour2
  148.             ttt = 0
  149.             Do
  150.                 'queue some sound
  151.                 Do While _SndRawLen < 0.1 'you may wish to adjust this
  152.                     sample = Sin(ttt * 240 * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  153.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  154.                     _SndRaw sample
  155.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  156.                 Loop
  157.                 'do other stuff, but it may interrupt sound
  158.             Loop While ttt < 2 'play for 2 seconds
  159.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  160.             Loop
  161.         Next chimes
  162.     End If
  163.     two:
  164.     a$ = InKey$
  165.     If a$ = Chr$(27) Then End
  166.     If a$ = " " Then song = 1
  167.     If a$ = "1" Then
  168.         rom = 0
  169.         For sz = .1 To 180 Step .1
  170.             Circle (300, 300), sz, _RGB32(0, 0, 0)
  171.         Next sz
  172.     End If
  173.     If a$ = "2" Then rom = 1
  174.     If a$ = "s" Or a$ = "S" Then
  175.         hour2 = hou
  176.         If hour2 > 11 Then
  177.             ampm$ = "P M"
  178.         Else
  179.             ampm$ = "A M"
  180.         End If
  181.         If hour2 > 12 Then hour2 = hour2 - 12
  182.         hour3$ = Str$(hour2)
  183.         hour4 = Val(hour3$)
  184.         If hour4 = 0 Then hour4 = 12
  185.         hour5$ = Str$(hour4)
  186.         min2 = Val(min$)
  187.         min3$ = Str$(min2)
  188.         seco2 = Val(seco$)
  189.         seco3$ = Str$(seco2)
  190.         sentence$ = "The time is " + hour5$ + ampm$ + min3$ + " minutes and " + seco3$ + " seconds."
  191.         speak sentence$, 1, 0
  192.     End If
  193.  
  194.  
  195. Sub pendulum (tt, d)
  196.     If d = 0 Then tt = tt + (.26 / 2)
  197.     If d = 1 Then tt = tt - (.26 / 2)
  198.     If tt < 24.25 Then d = 0
  199.     If tt > 26 Then d = 1
  200.     x5 = (Sin(tt) * 80) + 300
  201.     y5 = (Cos(tt) * 80) + 300
  202.     For sz = -3 To 4
  203.         Line (300 + sz, 300)-(x5, y5), _RGB32(255, 255, 127)
  204.         Line (300, 300 + sz)-(x5, y5), _RGB32(255, 255, 127)
  205.     Next sz
  206.     For sz = .1 To 15 Step .1
  207.         Circle (x5, y5), sz, _RGB32(255, 255, 127)
  208.     Next sz
  209.     _Delay .06
  210.     _Display
  211.  
  212. Sub _GL ()
  213.     Static glInit
  214.     If glInit = 0 Then
  215.         glInit = 1
  216.  
  217.     End If
  218.     'set the gl screen so that it can work normal screen coordinates
  219.     _glTranslatef -1, 1, 0
  220.     _glScalef 1 / 400, -1 / 300, 1
  221.  
  222.     _glEnable _GL_BLEND
  223.  
  224.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  225.     _glEnableClientState _GL_VERTEX_ARRAY
  226.     _glVertexPointer 2, _GL_FLOAT, 0, _Offset(vert())
  227.     For j = 1 To 15
  228.         _glColor4f rFactor!, gFactor!, bFactor!, 0.015
  229.         _glPointSize j
  230.         _glDrawArrays _GL_POINTS, 10, max_v_index
  231.     Next
  232.     _glFlush
  233.  
  234. Sub speak (text As String, Speaker As Integer, Speed)
  235.     Dim message As String, remove$, out$
  236.     Dim As Long i, j
  237.     message = text
  238.     'some symbols and such can't be used with Powershell like this, as they're command symbols
  239.     'we need to strip them out of our text.  (Like apostrophes!)
  240.     remove$ = "'" + Chr$(34) 'add to remove$ here, if more symbols need to be removed as future testing showcases problems
  241.     For j = 1 To Len(remove$)
  242.         Do
  243.             i = InStr(message, Mid$(remove$, j, 1))
  244.             If i Then message = Left$(message, i - 1) + Mid$(message, i + 1)
  245.         Loop Until i = 0
  246.     Next
  247.     out$ = "Powershell -Command " + Chr$(34)
  248.     out$ = out$ + "Add-Type -AssemblyName System.Speech; "
  249.     out$ = out$ + "$Speech = New-Object System.Speech.Synthesis.SpeechSynthesizer; "
  250.     If Speaker = 0 Then out$ = out$ + "$Speech.SelectVoice('Microsoft David Desktop'); "
  251.     If Speaker = 1 Then out$ = out$ + "$Speech.SelectVoice('Microsoft Zira Desktop'); "
  252.     If Speed Then out$ = out$ + "$Speech.Rate =" + Str$(Speed) + "; "
  253.     out$ = out$ + "$Speech.Speak('" + message + "');" + Chr$(34)
  254.     Shell _Hide out$
  255.  

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Neon Clock
« Reply #9 on: March 25, 2022, 08:09:27 pm »
Oh dear. I enjoyed the original version... Now there is no challenge to look forward to when trying to guess the correct time... But I do so like Roman Numerals... Eventually, if modifications continue, press a specific key and the computer will "tell" you the time... I miss the guessing *sigh*

You sound like you'd love a Roman Clock.

The Romans used 24 hour days, but they kept time from sun rise to sun set.  On the first day of summer, we have about 14 hours of daylight.  On the first day of winter, there's only about 10 hours of daylight. 

The difference in Roman time and modern time is that these hours aren't based on a whole day being broken down into 24 one-hour chunks.  The Roman day was 12 hours daylight, 12 hours darkness -- so the length of those 12 hours of daylight were about 70 minutes long in summer and only 50 minutes long in winter....

Which sounds like any modern clock that used Roman Time would certainly require a LOT of guessing!
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Marked as best answer by SierraKen on March 25, 2022, 06:48:53 pm

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Neon Clock
« Reply #10 on: March 25, 2022, 10:12:37 pm »
Not really sure what's going on here overall, but I had to fix the pendulum:

Code: QB64: [Select]
  1. _Title "1 Without Numerals  2 With Numerals  S Speak Time  Space Bar For Chimes"
  2. Screen _NewImage(600, 600, 32)
  3.  
  4. Type vec2
  5.     x As Single
  6.     y As Single
  7. Print "Neon Clock Selections"
  8. Print "----------------------------------"
  9. Print "(1) Without Roman Numerals"
  10. Print "(2) With Roman Numerals"
  11. Print "You can also press 1 or 2 anytime."
  12. Print "->";
  13.     sel$ = InKey$
  14.     If sel$ = "1" Then rom = 0: GoTo nexxx:
  15.     If sel$ = "2" Then rom = 1: GoTo nexxx:
  16. nexxx:
  17. ReDim Shared vert(4024) As vec2, max_v_index
  18. Dim Shared rFactor!, gFactor!, bFactor!
  19. rFactor! = 0.5: gFactor! = 1: bFactor! = 0.5
  20.  
  21. For t = 0 To 360 Step .5
  22.     x2 = (Sin(t) * 260) + 400
  23.     y2 = (Cos(t) * 190) + 300
  24.     max_v_index = max_v_index + 1
  25.     vert(max_v_index).x = x2
  26.     vert(max_v_index).y = y2
  27.  
  28. For t = 1 To 359
  29.     For tt = t - 2 To t + 2 Step .5
  30.         x2 = Int((Sin(tt) * 230) + 400)
  31.         y2 = Int((Cos(tt) * 170) + 300)
  32.         max_v_index = max_v_index + 1
  33.         vert(max_v_index).x = x2
  34.         vert(max_v_index).y = y2
  35.     Next tt
  36. tt = 23
  37. d = 0
  38.     _Limit 50
  39.     If rom = 0 Then GoTo skip:
  40.     For sc = 1 To 60
  41.         ss = (60 - sc) * 6 + 180
  42.         x4 = Int(Sin(ss / 180 * 3.141592) * 150) + 300
  43.         y4 = Int(Cos(ss / 180 * 3.141592) * 150) + 300
  44.         Circle (x4, y4), 3, _RGB32(230, 230, 230)
  45.         n2 = (60 - sc) * 6 + 180
  46.         x3 = Int(Sin(n2 / 180 * 3.141592) * 140) + 290
  47.         y3 = Int(Cos(n2 / 180 * 3.141592) * 140) + 295
  48.         Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
  49.         If sc = 5 Then _PrintString (x3, y3), "I"
  50.         If sc = 10 Then _PrintString (x3, y3), "II"
  51.         If sc = 15 Then _PrintString (x3, y3), "III"
  52.         If sc = 20 Then _PrintString (x3, y3), "IV"
  53.         If sc = 25 Then _PrintString (x3, y3), "V"
  54.         If sc = 30 Then _PrintString (x3, y3), "VI"
  55.         If sc = 35 Then _PrintString (x3, y3), "VII"
  56.         If sc = 40 Then _PrintString (x3, y3), "VIII"
  57.         If sc = 45 Then _PrintString (x3, y3), "IX"
  58.         If sc = 50 Then _PrintString (x3, y3), "X"
  59.         If sc = 55 Then _PrintString (x3, y3), "XI"
  60.         If sc = 60 Then _PrintString (x3, y3), "XII"
  61.     Next sc
  62.     skip:
  63.     hours = Timer \ 3600
  64.     minutes = Timer \ 60 - hours * 60
  65.     seconds = (Timer - hours * 3600 - minutes * 60)
  66.     ho$ = Left$(Time$, 2): hou = Val(ho$)
  67.     min$ = Mid$(Time$, 4, 2): minu = Val(min$)
  68.     seco$ = Right$(Time$, 2): secon = Val(seco$)
  69.  
  70.     pendulum tt, d
  71.  
  72.     'Minutes
  73.     m = 180 - minutes * 6
  74.     xx = Int(Sin(m / 180 * 3.141592) * 120) + 300
  75.     yy = Int(Cos(m / 180 * 3.141592) * 120) + 304
  76.     For b = -5 To 5 Step .1
  77.         Line (300 + b, 304)-(xx, yy), _RGB32(0, 255, 255)
  78.         Line (300, 304 + b)-(xx, yy), _RGB32(0, 255, 255)
  79.     Next b
  80.     'Hours
  81.     h = 360 - hours * 30 + 180
  82.     xxx = Int(Sin(h / 180 * 3.141592) * 75) + 300
  83.     yyy = Int(Cos(h / 180 * 3.141592) * 75) + 304
  84.     For b = -5 To 5 Step .1
  85.         Line (300 + b, 304)-(xxx, yyy), _RGB32(0, 255, 0)
  86.         Line (300, 304 + b)-(xxx, yyy), _RGB32(0, 255, 0)
  87.     Next b
  88.     'Seconds
  89.     s = (60 - seconds) * 6 + 180
  90.     xxxx = Int(Sin(s / 180 * 3.141592) * 125) + 300
  91.     yyyy = Int(Cos(s / 180 * 3.141592) * 125) + 304
  92.     For b = -5 To 5 Step .1
  93.         Line (300 + b, 304)-(xxxx, yyyy), _RGB32(255, 0, 0)
  94.         Line (300, 304 + b)-(xxxx, yyyy), _RGB32(255, 0, 0)
  95.     Next b
  96.     For sz = .1 To 10 Step .1
  97.         Circle (300, 300), sz, _RGB32(255, 255, 127)
  98.     Next sz
  99.  
  100.     _Display
  101.     Line (175, 175)-(425, 440), _RGB32(0, 0, 0, 20), BF
  102.  
  103.     'Chimes
  104.     If (minu = 0 And secon = 0) Or song = 1 Then
  105.         song = 0
  106.  
  107.         'note frequencies
  108.         For notes = 1 To 20
  109.             If notes = 1 Then note = 311.13 'D#
  110.             If notes = 2 Then note = 246.94 'B
  111.             If notes = 3 Then note = 277.18 'C#
  112.             If notes = 4 Then note = 185.00 'F#
  113.             If notes = 5 Then note = 0
  114.             If notes = 6 Then note = 185.00 'F#
  115.             If notes = 7 Then note = 277.18 'C#
  116.             If notes = 8 Then note = 311.13 'D#
  117.             If notes = 9 Then note = 246.94 'B
  118.             If notes = 10 Then note = 0
  119.             If notes = 11 Then note = 311.13 'D#
  120.             If notes = 12 Then note = 277.18 'C3
  121.             If notes = 13 Then note = 246.94 'B
  122.             If notes = 14 Then note = 185.00 'F#
  123.             If notes = 15 Then note = 0
  124.             If notes = 16 Then note = 185.00 'F#
  125.             If notes = 17 Then note = 277.18 'C#
  126.             If notes = 18 Then note = 311.13 'D#
  127.             If notes = 19 Then note = 246.94 'B
  128.             If notes = 20 Then note = 0
  129.  
  130.             Do
  131.                 'queue some sound
  132.                 Do While _SndRawLen < 0.5 'you may wish to adjust this
  133.                     sample = Sin(ttt * note * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  134.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  135.                     _SndRaw sample
  136.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  137.                 Loop
  138.                 'do other stuff, but it may interrupt sound
  139.             Loop While ttt < 1 'play for 1 second
  140.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  141.             Loop
  142.             ttt = 0
  143.         Next notes
  144.         hour2 = hou
  145.         If hour2 > 12 Then hour2 = hour2 - 12
  146.         If hour2 = 0 Then hour2 = 12
  147.         For chimes = 1 To hour2
  148.             ttt = 0
  149.             Do
  150.                 'queue some sound
  151.                 Do While _SndRawLen < 0.1 'you may wish to adjust this
  152.                     sample = Sin(ttt * 240 * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  153.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  154.                     _SndRaw sample
  155.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  156.                 Loop
  157.                 'do other stuff, but it may interrupt sound
  158.             Loop While ttt < 2 'play for 2 seconds
  159.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  160.             Loop
  161.         Next chimes
  162.     End If
  163.     two:
  164.     a$ = InKey$
  165.     If a$ = Chr$(27) Then End
  166.     If a$ = " " Then song = 1
  167.     If a$ = "1" Then
  168.         rom = 0
  169.         For sz = .1 To 180 Step .1
  170.             Circle (300, 300), sz, _RGB32(0, 0, 0)
  171.         Next sz
  172.     End If
  173.     If a$ = "2" Then rom = 1
  174.     If a$ = "s" Or a$ = "S" Then
  175.         hour2 = hou
  176.         If hour2 > 11 Then
  177.             ampm$ = "P M"
  178.         Else
  179.             ampm$ = "A M"
  180.         End If
  181.         If hour2 > 12 Then hour2 = hour2 - 12
  182.         hour3$ = Str$(hour2)
  183.         hour4 = Val(hour3$)
  184.         If hour4 = 0 Then hour4 = 12
  185.         hour5$ = Str$(hour4)
  186.         min2 = Val(min$)
  187.         min3$ = Str$(min2)
  188.         seco2 = Val(seco$)
  189.         seco3$ = Str$(seco2)
  190.         sentence$ = "The time is " + hour5$ + ampm$ + min3$ + " minutes and " + seco3$ + " seconds."
  191.         speak sentence$, 1, 0
  192.     End If
  193.  
  194.  
  195. Sub pendulum (tt, d)
  196.     'Locate 1, d + 1: Print tt
  197.     If d = 0 Then tt = tt + (.26 / 2)
  198.     If d = 1 Then tt = tt - (.26 / 2)
  199.     If tt < 24.25 Then d = 0
  200.     If tt > 26 Then d = 1
  201.     theta = .3 * Cos(Timer)
  202.     x5 = (Sin(theta) * 80) + 300
  203.     y5 = (Cos(theta) * 80) + 300
  204.     For sz = -3 To 4
  205.         Line (300 + sz, 300)-(x5, y5), _RGB32(255, 255, 127)
  206.         Line (300, 300 + sz)-(x5, y5), _RGB32(255, 255, 127)
  207.     Next sz
  208.     For sz = .1 To 15 Step .1
  209.         Circle (x5, y5), sz, _RGB32(255, 255, 127)
  210.     Next sz
  211.     _Delay .06
  212.     _Display
  213.  
  214. Sub _GL ()
  215.     Static glInit
  216.     If glInit = 0 Then
  217.         glInit = 1
  218.  
  219.     End If
  220.     'set the gl screen so that it can work normal screen coordinates
  221.     _glTranslatef -1, 1, 0
  222.     _glScalef 1 / 400, -1 / 300, 1
  223.  
  224.     _glEnable _GL_BLEND
  225.  
  226.     _glBlendFunc _GL_SRC_ALPHA, _GL_ONE
  227.     _glEnableClientState _GL_VERTEX_ARRAY
  228.     _glVertexPointer 2, _GL_FLOAT, 0, _Offset(vert())
  229.     For j = 1 To 15
  230.         _glColor4f rFactor!, gFactor!, bFactor!, 0.015
  231.         _glPointSize j
  232.         _glDrawArrays _GL_POINTS, 10, max_v_index
  233.     Next
  234.     _glFlush
  235.  
  236. Sub speak (text As String, Speaker As Integer, Speed)
  237.     Dim message As String, remove$, out$
  238.     Dim As Long i, j
  239.     message = text
  240.     'some symbols and such can't be used with Powershell like this, as they're command symbols
  241.     'we need to strip them out of our text.  (Like apostrophes!)
  242.     remove$ = "'" + Chr$(34) 'add to remove$ here, if more symbols need to be removed as future testing showcases problems
  243.     For j = 1 To Len(remove$)
  244.         Do
  245.             i = InStr(message, Mid$(remove$, j, 1))
  246.             If i Then message = Left$(message, i - 1) + Mid$(message, i + 1)
  247.         Loop Until i = 0
  248.     Next
  249.     out$ = "Powershell -Command " + Chr$(34)
  250.     out$ = out$ + "Add-Type -AssemblyName System.Speech; "
  251.     out$ = out$ + "$Speech = New-Object System.Speech.Synthesis.SpeechSynthesizer; "
  252.     If Speaker = 0 Then out$ = out$ + "$Speech.SelectVoice('Microsoft David Desktop'); "
  253.     If Speaker = 1 Then out$ = out$ + "$Speech.SelectVoice('Microsoft Zira Desktop'); "
  254.     If Speed Then out$ = out$ + "$Speech.Rate =" + Str$(Speed) + "; "
  255.     out$ = out$ + "$Speech.Speak('" + message + "');" + Chr$(34)
  256.     Shell _Hide out$
  257.  
  258.  
« Last Edit: March 26, 2022, 09:18:16 am by STxAxTIC »
You're not done when it works, you're done when it's right.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Neon Clock
« Reply #11 on: March 25, 2022, 10:48:29 pm »
Even though the pendulum was swinging around every second or so (I guessed at the numbers), I will use Static's fix instead because it's a LOT more natural looking. Thank you Static!!!!!!

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Neon Clock
« Reply #12 on: March 29, 2022, 04:52:53 pm »
I took B+'s idea and made a version without the _GL sub using regular graphics. It's pretty similar. :) You still need Windows though to use the voice feature. I'll post a picture below.
By the way, it's been 4 days or so and nobody has posted on this forum, I'm surprised, where is everyone?

Code: QB64: [Select]
  1. _Title "1 Without Numerals  2 With Numerals  S Speak Time  Space Bar For Chimes"
  2. Screen _NewImage(600, 600, 32)
  3.  
  4. Print "Neon Clock Selections"
  5. Print "----------------------------------"
  6. Print "(1) Without Roman Numerals"
  7. Print "(2) With Roman Numerals"
  8. Print "You can also press 1 or 2 anytime."
  9. Print "->";
  10.     sel$ = InKey$
  11.     If sel$ = "1" Then rom = 0: GoTo nexxx:
  12.     If sel$ = "2" Then rom = 1: GoTo nexxx:
  13. nexxx:
  14. tt = 23
  15. d = 0
  16.     _Limit 50
  17.     For t = 0 To 360 Step .5
  18.         x2 = (Sin(t) * 190) + 300
  19.         y2 = (Cos(t) * 190) + 300
  20.         For sz = .1 To 5 Step .1
  21.             Circle (x2, y2), sz, _RGB32(127, 255, 127)
  22.         Next sz
  23.     Next t
  24.  
  25.     For t = 1 To 359
  26.         For tt = t - 2 To t + 2 Step .5
  27.             x2 = Int((Sin(tt) * 170) + 300)
  28.             y2 = Int((Cos(tt) * 170) + 300)
  29.             For sz = .1 To 5 Step .1
  30.                 Circle (x2, y2), sz, _RGB32(255, 255, 255)
  31.             Next sz
  32.         Next tt
  33.     Next t
  34.     If rom = 0 Then GoTo skip:
  35.     For sc = 1 To 60
  36.         ss = (60 - sc) * 6 + 180
  37.         x4 = Int(Sin(ss / 180 * 3.141592) * 150) + 300
  38.         y4 = Int(Cos(ss / 180 * 3.141592) * 150) + 300
  39.         Circle (x4, y4), 3, _RGB32(230, 230, 230)
  40.         n2 = (60 - sc) * 6 + 180
  41.         x3 = Int(Sin(n2 / 180 * 3.141592) * 140) + 290
  42.         y3 = Int(Cos(n2 / 180 * 3.141592) * 140) + 295
  43.         Color _RGB32(255, 255, 255), _RGB32(0, 0, 0)
  44.         If sc = 5 Then _PrintString (x3, y3), "I"
  45.         If sc = 10 Then _PrintString (x3, y3), "II"
  46.         If sc = 15 Then _PrintString (x3, y3), "III"
  47.         If sc = 20 Then _PrintString (x3, y3), "IV"
  48.         If sc = 25 Then _PrintString (x3, y3), "V"
  49.         If sc = 30 Then _PrintString (x3, y3), "VI"
  50.         If sc = 35 Then _PrintString (x3, y3), "VII"
  51.         If sc = 40 Then _PrintString (x3, y3), "VIII"
  52.         If sc = 45 Then _PrintString (x3, y3), "IX"
  53.         If sc = 50 Then _PrintString (x3, y3), "X"
  54.         If sc = 55 Then _PrintString (x3, y3), "XI"
  55.         If sc = 60 Then _PrintString (x3, y3), "XII"
  56.     Next sc
  57.     skip:
  58.     hours = Timer \ 3600
  59.     minutes = Timer \ 60 - hours * 60
  60.     seconds = (Timer - hours * 3600 - minutes * 60)
  61.     ho$ = Left$(Time$, 2): hou = Val(ho$)
  62.     min$ = Mid$(Time$, 4, 2): minu = Val(min$)
  63.     seco$ = Right$(Time$, 2): secon = Val(seco$)
  64.  
  65.     pendulum tt, d
  66.  
  67.     'Minutes
  68.     m = 180 - minutes * 6
  69.     xx = Int(Sin(m / 180 * 3.141592) * 120) + 300
  70.     yy = Int(Cos(m / 180 * 3.141592) * 120) + 304
  71.     For b = -5 To 5 Step .1
  72.         Line (300 + b, 304)-(xx, yy), _RGB32(0, 255, 255)
  73.         Line (300, 304 + b)-(xx, yy), _RGB32(0, 255, 255)
  74.     Next b
  75.     'Hours
  76.     h = 360 - hours * 30 + 180
  77.     xxx = Int(Sin(h / 180 * 3.141592) * 75) + 300
  78.     yyy = Int(Cos(h / 180 * 3.141592) * 75) + 304
  79.     For b = -5 To 5 Step .1
  80.         Line (300 + b, 304)-(xxx, yyy), _RGB32(0, 255, 0)
  81.         Line (300, 304 + b)-(xxx, yyy), _RGB32(0, 255, 0)
  82.     Next b
  83.     'Seconds
  84.     s = (60 - seconds) * 6 + 180
  85.     xxxx = Int(Sin(s / 180 * 3.141592) * 125) + 300
  86.     yyyy = Int(Cos(s / 180 * 3.141592) * 125) + 304
  87.     For b = -5 To 5 Step .1
  88.         Line (300 + b, 304)-(xxxx, yyyy), _RGB32(255, 0, 0)
  89.         Line (300, 304 + b)-(xxxx, yyyy), _RGB32(255, 0, 0)
  90.     Next b
  91.     For sz = .1 To 10 Step .1
  92.         Circle (300, 300), sz, _RGB32(255, 255, 127)
  93.     Next sz
  94.  
  95.     _Display
  96.     Line (0, 0)-(600, 600), _RGB32(0, 0, 0, 20), BF
  97.  
  98.     'Chimes
  99.     If (minu = 0 And secon = 0) Or song = 1 Then
  100.         song = 0
  101.  
  102.         'note frequencies
  103.         For notes = 1 To 20
  104.             If notes = 1 Then note = 311.13 'D#
  105.             If notes = 2 Then note = 246.94 'B
  106.             If notes = 3 Then note = 277.18 'C#
  107.             If notes = 4 Then note = 185.00 'F#
  108.             If notes = 5 Then note = 0
  109.             If notes = 6 Then note = 185.00 'F#
  110.             If notes = 7 Then note = 277.18 'C#
  111.             If notes = 8 Then note = 311.13 'D#
  112.             If notes = 9 Then note = 246.94 'B
  113.             If notes = 10 Then note = 0
  114.             If notes = 11 Then note = 311.13 'D#
  115.             If notes = 12 Then note = 277.18 'C3
  116.             If notes = 13 Then note = 246.94 'B
  117.             If notes = 14 Then note = 185.00 'F#
  118.             If notes = 15 Then note = 0
  119.             If notes = 16 Then note = 185.00 'F#
  120.             If notes = 17 Then note = 277.18 'C#
  121.             If notes = 18 Then note = 311.13 'D#
  122.             If notes = 19 Then note = 246.94 'B
  123.             If notes = 20 Then note = 0
  124.  
  125.             Do
  126.                 'queue some sound
  127.                 Do While _SndRawLen < 0.5 'you may wish to adjust this
  128.                     sample = Sin(ttt * note * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  129.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  130.                     _SndRaw sample
  131.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  132.                 Loop
  133.                 'do other stuff, but it may interrupt sound
  134.             Loop While ttt < 1 'play for 1 second
  135.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  136.             Loop
  137.             ttt = 0
  138.         Next notes
  139.         hour2 = hou
  140.         If hour2 > 12 Then hour2 = hour2 - 12
  141.         If hour2 = 0 Then hour2 = 12
  142.         For chimes = 1 To hour2
  143.             ttt = 0
  144.             Do
  145.                 'queue some sound
  146.                 Do While _SndRawLen < 0.1 'you may wish to adjust this
  147.                     sample = Sin(ttt * 240 * Atn(1) * 8) '340Hz sine wave (ttt * 440 * 2p)
  148.                     sample = sample * Exp(-ttt * 3) 'fade out eliminates clicks after sound
  149.                     _SndRaw sample
  150.                     ttt = ttt + 1 / _SndRate 'sound card sample frequency determines time
  151.                 Loop
  152.                 'do other stuff, but it may interrupt sound
  153.             Loop While ttt < 2 'play for 2 seconds
  154.             Do While _SndRawLen > 0 'Finish any left over queued sound!
  155.             Loop
  156.         Next chimes
  157.     End If
  158.     two:
  159.     a$ = InKey$
  160.     If a$ = Chr$(27) Then End
  161.     If a$ = " " Then song = 1
  162.     If a$ = "1" Then
  163.         rom = 0
  164.         For sz = .1 To 180 Step .1
  165.             Circle (300, 300), sz, _RGB32(0, 0, 0)
  166.         Next sz
  167.     End If
  168.     If a$ = "2" Then rom = 1
  169.     If a$ = "s" Or a$ = "S" Then
  170.         hour2 = hou
  171.         If hour2 > 11 Then
  172.             ampm$ = "P M"
  173.         Else
  174.             ampm$ = "A M"
  175.         End If
  176.         If hour2 > 12 Then hour2 = hour2 - 12
  177.         hour3$ = Str$(hour2)
  178.         hour4 = Val(hour3$)
  179.         If hour4 = 0 Then hour4 = 12
  180.         hour5$ = Str$(hour4)
  181.         min2 = Val(min$)
  182.         min3$ = Str$(min2)
  183.         seco2 = Val(seco$)
  184.         seco3$ = Str$(seco2)
  185.         sentence$ = "The time is " + hour5$ + ampm$ + min3$ + " minutes and " + seco3$ + " seconds."
  186.         speak sentence$, 1, 0
  187.     End If
  188.  
  189.  
  190. Sub pendulum (tt, d)
  191.     If d = 0 Then tt = tt + (.26 / 2)
  192.     If d = 1 Then tt = tt - (.26 / 2)
  193.     If tt < 24.25 Then d = 0
  194.     If tt > 26 Then d = 1
  195.     theta = .3 * Cos(Timer)
  196.     x5 = (Sin(theta) * 80) + 300
  197.     y5 = (Cos(theta) * 80) + 300
  198.     For sz = -3 To 4
  199.         Line (300 + sz, 300)-(x5, y5), _RGB32(255, 255, 127)
  200.         Line (300, 300 + sz)-(x5, y5), _RGB32(255, 255, 127)
  201.     Next sz
  202.     For sz = .1 To 15 Step .1
  203.         Circle (x5, y5), sz, _RGB32(255, 255, 127)
  204.     Next sz
  205.     _Delay .06
  206.     _Display
  207.  
  208. Sub speak (text As String, Speaker As Integer, Speed)
  209.     Dim message As String, remove$, out$
  210.     Dim As Long i, j
  211.     message = text
  212.     'some symbols and such can't be used with Powershell like this, as they're command symbols
  213.     'we need to strip them out of our text.  (Like apostrophes!)
  214.     remove$ = "'" + Chr$(34) 'add to remove$ here, if more symbols need to be removed as future testing showcases problems
  215.     For j = 1 To Len(remove$)
  216.         Do
  217.             i = InStr(message, Mid$(remove$, j, 1))
  218.             If i Then message = Left$(message, i - 1) + Mid$(message, i + 1)
  219.         Loop Until i = 0
  220.     Next
  221.     out$ = "Powershell -Command " + Chr$(34)
  222.     out$ = out$ + "Add-Type -AssemblyName System.Speech; "
  223.     out$ = out$ + "$Speech = New-Object System.Speech.Synthesis.SpeechSynthesizer; "
  224.     If Speaker = 0 Then out$ = out$ + "$Speech.SelectVoice('Microsoft David Desktop'); "
  225.     If Speaker = 1 Then out$ = out$ + "$Speech.SelectVoice('Microsoft Zira Desktop'); "
  226.     If Speed Then out$ = out$ + "$Speech.Rate =" + Str$(Speed) + "; "
  227.     out$ = out$ + "$Speech.Speak('" + message + "');" + Chr$(34)
  228.     Shell _Hide out$
  229.  
Neon Clock 2 by SierraKen.jpg
* Neon Clock 2 by SierraKen.jpg (Filesize: 93.67 KB, Dimensions: 603x627, Views: 184)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Neon Clock
« Reply #13 on: March 29, 2022, 05:40:11 pm »
Quote
By the way, it's been 4 days or so and nobody has posted on this forum, I'm surprised, where is everyone?

Yeah I've been on other projects and reading.

We think somethings happened to Fellippe, posts removed and is listed as guest.

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: Neon Clock
« Reply #14 on: March 29, 2022, 05:43:59 pm »
Wow that is really bizarre. Hope he's OK. I'll pray for him.