06-05-2024, 06:12 PM
Orbit Poly 24
Code: (Select All)
Option _Explicit
_Title "orbit poly 24" 'b+ 2024-06-05
' a geometric meditation on the 24 points of circle / polygon
Const Xmax = 700, Ymax = 700
Screen _NewImage(Xmax, Ymax, 32)
_ScreenMove 300, 20
Dim px(1 To 24), py(1 To 24) ' 24 points on the circle
Dim As Long i, j, pIndex, cx, cy ' indexs and center point
Dim a, angle24, radius, x, y ' orbit point calculations
Dim As Long r, g, b ' color rgb trackers
cx = _Width / 2: cy = _Height / 2 ' start in center of screen
angle24 = 360 / 24 ' the angles inside a regular polygon of 24 sides
radius = 340 ' fill screen with big 340 radius circle
For a = 0 To 359 Step angle24 ' 24 angles
orbit cx, cy, a, radius, x, y ' orbit calc of x, y from center at angle and radius
pIndex = pIndex + 1 ' update point index
px(pIndex) = x: py(pIndex) = y ' save point calcs into an array
'
If a > 0 Then Line (px(pIndex - 1), py(pIndex - 1))-(x, y) ' draw the line around edge
Next
Line (px(24), py(24))-(px(1), py(1)) ' finsih edge lines
' now from all the points to all the other points, draw the lines
For i = 1 To 24
For j = 1 To 24
If i <> j Then Line (px(i), py(i))-(px(j), py(j)), _RGB32(255 - i * 10, 255 * i * j / 576, j * 10 + 15)
Next
Next
' now animate with moving color
r = 0: g = 80: b = 180
While _KeyDown(27) = 0
For i = 1 To 24
For j = 1 To 24
If i <> j Then
r = (r + 3) Mod 24: g = (g + 2) Mod 24: b = (b + 1) Mod 24
Line (px(i), py(i))-(px(j), py(j)), _RGB32(10 * r + 25, 10 * g + 25, 10 * b + 25)
End If
_Limit 552
Next
Next
Wend
' !!!!!! featuring the use of this SUB routine !!!!
Sub orbit (X_Origin, Y_Origin, Degrees, Radius, xOut, yOut) ' all default single should be ok
xOut = X_Origin + Radius * Cos(_D2R(Degrees))
yOut = Y_Origin + Radius * Sin(_D2R(Degrees))
End Sub
b = b + ...