Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spiro - A Simulation
#4
But what we want to see is the line created by the last circle in the chain:
Code: (Select All)
' First Mod of Ashish Spirograph translated to QB64 2022-05-10 b+
_Title "Spirograph by Ashish b+ Mod and trans to QB64"
' what we really want to see is what the Spirograph is drawing
' at least as much seeing the many circled arm swinging around in circle.

xmax = 700: ymax = 700
Type spiro
    As Single x, y, r, ang
End Type
Dim spiral(15) As spiro
Screen _NewImage(xmax, ymax, 12)
_ScreenMove 200, 60
s = 2
spiral(0).x = xmax / 2
spiral(0).y = ymax / 2
spiral(0).r = 100
spiral(0).ang = 0
For s = 2 To 5 ' after 5 it gets to full of lines to apreciate but something looks wrong this is not Spirograph!
    Cls
    Print "S = "; s; "   press spacebar when spirograph begins to repeat..."
    F = 0
    While F = 0
        If InKey$ = " " Then F = 1
        spiral(0).ang = spiral(0).ang + .01
        For i = 1 To s
            spiral(i).x = Cos(spiral(i - 1).ang) * spiral(i - 1).r + spiral(i - 1).x
            spiral(i).y = Sin(spiral(i - 1).ang) * spiral(i - 1).r + spiral(i - 1).y
            spiral(i).r = spiral(i - 1).r / 1.5
            spiral(i).ang = spiral(i - 1).ang * 1.5
            If i = s Then fcirc spiral(i).x, spiral(i).y, 2, 9
        Next
        _Display
    Wend
Next

Sub fcirc (CX As Long, CY As Long, R As Long, C As _Unsigned Long)
    Dim Radius As Long, RadiusError As Long
    Dim X As Long, Y As Long
    Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
    If Radius = 0 Then PSet (CX, CY), C: Exit Sub
    Line (CX - X, CY)-(CX + X, CY), C, BF
    While X > Y
        RadiusError = RadiusError + Y * 2 + 1
        If RadiusError >= 0 Then
            If X <> Y + 1 Then
                Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
                Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
            End If
            X = X - 1
            RadiusError = RadiusError - X * 2
        End If
        Y = Y + 1
        Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
        Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
    Wend
End Sub

   
That is just the beginning of a very long circle filling ride!

And something looks off, a Spirograph drawing does not bulge out on right side not to mention 10 gears is 8 or 9 too many!
Back to drawing board...
b = b + ...
Reply


Messages In This Thread
Spiro - A Simulation - by TarotRedhand - 05-10-2022, 07:02 AM
RE: Spiro - A Simulation - by bplus - 05-10-2022, 03:37 PM
RE: Spiro - A Simulation - by bplus - 05-10-2022, 04:09 PM
RE: Spiro - A Simulation - by bplus - 05-10-2022, 04:56 PM
RE: Spiro - A Simulation - by aurel - 05-10-2022, 06:22 PM
RE: Spiro - A Simulation - by bplus - 05-10-2022, 06:30 PM
RE: Spiro - A Simulation - by bplus - 05-10-2022, 06:38 PM
RE: Spiro - A Simulation - by aurel - 05-10-2022, 06:38 PM
RE: Spiro - A Simulation - by bplus - 05-10-2022, 06:44 PM
RE: Spiro - A Simulation - by bplus - 05-10-2022, 08:22 PM
RE: Spiro - A Simulation - by bplus - 05-10-2022, 08:59 PM
RE: Spiro - A Simulation - by bplus - 05-10-2022, 09:05 PM
RE: Spiro - A Simulation - by johnno56 - 05-11-2022, 04:20 AM
RE: Spiro - A Simulation - by TarotRedhand - 05-11-2022, 06:44 AM



Users browsing this thread: 4 Guest(s)