09-21-2022, 12:20 PM
A little graphics demo using a simple polygon drawing routine. If 360 is evenly divisible by the shapedeg variable you get a closed polygon. This would be speedier without using PAINT but I wanted ROTPOLY to be a simple as possible.
Code: (Select All)
'just playing with a subroutine
Screen _NewImage(800, 600, 32)
Dim klr As _Unsigned Long
For d = 0 To 360
_Limit 60
Cls
klr = _RGB32(d / 2, d / 2, d / 2)
rotpoly 400, 300, 100, 72, d, klr
Paint (400, 300), klr, klr
For n = 0 To 50
klr = _RGB32(d / 2 + n * 2, d / 4 + n * 2, d / 2 + n * 2)
rotpoly 400 + n * Sin(0.01745329 * d), 300 + n * Cos(0.01745329 * d), 100 - n, 72, d + n, klr
Paint (400 + n * Sin(0.01745329 * d), 300 + n * Cos(0.01745329 * d)), klr, klr
klr2 = _RGB32(d / 2 + n * 2, d / 4 + n * 2, d / 4 + n * 2)
rotpoly 150 + n * Sin(0.01745329 * d), 150 + n * Cos(0.01745329 * d), 80 - n, 60, d + 30, klr2
Paint (150 + n * Sin(0.01745329 * d), 150 + n * Cos(0.01745329 * d)), klr2, klr2
klr3 = _RGB32(d / 4 + n * 2, d / 4 + n * 2, d / 2 + n * 2)
rotpoly 600 + n * Sin(0.01745329 * d), 100 + n * Cos(0.01745329 * d), 90 - n, 90, d + n, klr3
Paint (600 + n * Sin(0.01745329 * d), 100 + n * Cos(0.01745329 * d)), klr3, klr3
klr4 = _RGB32(n * 2 + 30, d / 2 + 20, d / 2)
rotpoly 600 + n * Sin(0.01745329 * d), 400 + n * Cos(0.01745329 * d), 90 - n, 6, (d + n) * 2, klr4
Paint (600 + n * Sin(0.01745329 * d), 400 + n * Cos(0.01745329 * d)), klr4, klr4
klr5 = _RGB32(255 - n * 2, 255 - d / 2 + 20, 255 - d / 2)
rotpoly 120 + n * Sin(0.01745329 * d), 400 + n * Cos(0.01745329 * d), 90 - n, 120, d + n, klr5
Paint (120 + n * Sin(0.01745329 * d), 400 + n * Cos(0.01745329 * d)), klr5, klr5
klr6 = _RGB32(n * 2 + 30, d / 2 + 20, d / 2)
rotpoly 600 + n * Sin(0.01745329 * d), 400 + n * Cos(0.01745329 * d), 90 - n, 6, n * Sin(0.01745329 * d), klr6
Next
_Display
Next
Sub rotpoly (cx, cy, rr, shapedeg, turn, klr As _Unsigned Long)
'CX and CY are the center of the polygon
'rr is the outer radius of the polygon
'shapedeg is the angle the polygon will be drawn with
'turn is the degrees the polygon will be draw rotated from it's center
'klr is the color of the line drawn by the polygon
x = rr * Sin(0.01745329 * turn)
y = rr * Cos(0.01745329 * turn)
Line (cx + x, cy + y)-(cx + x, cy + y), klr
For deg = turn To turn + 360 Step shapedeg
x2 = rr * Sin(0.01745329 * deg)
y2 = rr * Cos(0.01745329 * deg)
Line -(cx + x2, cy + y2), klr
Next
End Sub