Spiro - A Simulation
#7
OK next step in story is me trying to get closer to a Spirograph than Ashish:

Here is my first effort 5 years ago almost:
Code: (Select All)
_Title "Test 1 Spirograph" ' b+ trans from SB 2022-05-10
'Spirograph test.bas SmallBASIC 0.12.9 (B+=MGA) 2017-07-01
xmax = 700: ymax = 700
Screen _NewImage(xmax, ymax, 12) ' using 16 colors
_ScreenMove 300, 20
Dim Shared pi
pi = _Pi
rO = ymax / 2 - 10 ' fit screen radius of big circle
rI = rO / 2 ' smaller circle that travels inside edge of larger
OI = rO / rI ' rate inner circle spins compared to angle on outer circle
'? OI
Ox = xmax / 2
Oy = ymax / 2
Dim Shared px(20000), py(20000), pIndex
For a = 0 To 2 * pi Step pi / 360 'while the inner circle contacts outer at angle a
    Cls
    Circle (Ox, Oy), rO, 9
    'the origin of inner circle at same angle
    Ix = Ox + (rO - rI) * Cos(a)
    Iy = Oy + (rO - rI) * Sin(a)
    Ia = OI * a 'the angle of the inner points are OI * a on outer circle
    'draw line from origin of inner circle to outer edge
    Color 12
    wheel Ix, Iy, rI, -Ia
    For i = 1 To pIndex - 1
        PSet (px(i), py(i)), 15
    Next
    _Display
    _Delay .010
Next
Sub wheel (x, y, r, a)
    'local i, x1, y1
    Circle (x, y), r
    For i = 1 To 12
        x1 = x + r * Cos(i * 2 * pi / 12 + a)
        y1 = y + r * Sin(i * 2 * pi / 12 + a)
        Line (x, y)-(x1, y1)
        If i = 12 Then
            x2 = x + r / 2 * Cos(i * 2 * pi / 12 + a)
            y2 = y + r / 2 * Sin(i * 2 * pi / 12 + a)
            px(pIndex) = x2
            py(pIndex) = y2
            pIndex = pIndex + 1
        End If
    Next
End Sub


[Image: Test-1-Spirograph.png]



Me thinks if Walter had posted his after Ashish or mine, neither of us would have pursued Spirograph further! ;-))
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)