7 years ago I was doing polygons!
Looks like I was filling with Paint back then, later versions I filled with fTri (Filled Triangles) way way faster! Plus could then do transparent colors.
Code: (Select All)
_Title "Polygon Demo by bplus"
' polygon demo.bas for QB64 (B+=MGA) 2017-09-17
Const xmax = 700
Const ymax = 700
Screen _NewImage(xmax, ymax, 32)
_Delay .25
_ScreenMove _Middle
x0 = xmax / 2: y0 = ymax / 2
For n = 3 To 9
radius = 345
Cls
rr = Rnd * 75: gg = Rnd * 75: bb = Rnd * 75
For a = 0 To _Pi(2) Step _Pi(1 / 20)
radius = radius - 8
pc& = _RGB(radius / 345 * 200 + rr, radius / 345 * 200 + gg, radius / 345 * 200 + bb)
Color pc&
polygon x0, y0, radius, n, a
Paint (x0, y0), pc&, pc&
_Limit 10
Next
Sleep 2
Next
Sub polygon (xOrigin, yOrigin, radius, nVertex, RadianAngleOffset)
polyAngle = _Pi(2) / nVertex
x1 = xOrigin + radius * Cos(polyAngle + RadianAngleOffset)
y1 = yOrigin + radius * Sin(polyAngle + RadianAngleOffset)
For i = 2 To nVertex + 1
x2 = xOrigin + radius * Cos(i * polyAngle + RadianAngleOffset)
y2 = yOrigin + radius * Sin(i * polyAngle + RadianAngleOffset)
Line (x1, y1)-(x2, y2)
x1 = x2: y1 = y2
Next
End Sub
Looks like I was filling with Paint back then, later versions I filled with fTri (Filled Triangles) way way faster! Plus could then do transparent colors.
b = b + ...