Author Topic: Spinner  (Read 2648 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Spinner
« on: June 19, 2021, 07:54:36 pm »
A subject started at JB forum by tsh73, this is the version I came up with that won't work (way too slow) there but works great here in QB64:

Code: QB64: [Select]
  1. _Title "Spinner" 'b+ 2021-06-18
  2. Screen _NewImage(500, 500, 32)
  3. Const rad = _Pi / 180
  4.     Cls
  5.     b = b + 5
  6.     For r = 20 To 200 Step 20 ' tsh73 suggested fix for inner most
  7.         a = b * r / 20
  8.         For i = r - 15 To r
  9.             arc 250, 250, i, a, 180
  10.         Next
  11.     Next
  12.     _Display
  13.     _Limit 15
  14.  
  15. Sub arc (xCenter, yCenter, arcRadius, dAStart, dAMeasure)
  16.     'notes:
  17.     'you may want to adjust size and color for line drawing
  18.     'using angle measures in degrees to match Just Basic ways with pie and piefilled
  19.     'this sub assumes drawing in a CW direction if dAMeasure positive
  20.  
  21.     'for Just Basic angle 0 degrees is due East and angle increases clockwise towards South
  22.  
  23.     'dAStart is degrees to start Angle, due East is 0 degrees
  24.  
  25.     'dAMeasure is degrees added (Clockwise) to dAstart for end of arc
  26.  
  27.     rAngleStart = rad * dAStart
  28.     rAngleEnd = rad * dAMeasure + rAngleStart
  29.     Stepper = rad / (.1 * arcRadius) 'fixed
  30.     lastX = xCenter + arcRadius * Cos(rAngleStart)
  31.     lastY = yCenter + arcRadius * Sin(rAngleStart)
  32.     PSet (lastX, lastY)
  33.     For rAngle = rAngleStart + Stepper To rAngleEnd Step Stepper
  34.         nextX = xCenter + arcRadius * Cos(rAngle)
  35.         nextY = yCenter + arcRadius * Sin(rAngle)
  36.         Line -(nextX, nextY) 'int speeds things up
  37.     Next