Microsoft Small Basic

Program Listing: QLG339
' Draw Web
' Version 0.1
' Copyright © 2019 Nonki Takahashi. The MIT License.
' Last update 2019-10-05

GraphicsWindow.Title = "Web 0.1"
GraphicsWindow.BackgroundColor = "Black"
gw = GraphicsWindow.Width
gh = GraphicsWindow.Height
gd = Math.SquareRoot(gw * gw + gh * gh)
x[0] = gw / 2
y[0] = gh / 2
size = 6
gap = 16
GraphicsWindow.PenWidth = 0
GraphicsWindow.BrushColor = "#9933FFFF"
shp[0] = Shapes.AddEllipse(size, size)
Shapes.Move(shp[0], x[0] - size / 2, y[0] - size / 2)
a = 22.5
For i = 1 To 8
_a = Math.GetRadians(a)
x[i] = x[0] + gd / 2 * Math.Cos(_a)
y[i] = y[0] + gd / 2 * Math.Sin(_a)
a = a + 45
EndFor
a = 22.5
r = gap
While r < gd * 0.8
_a = Math.GetRadians(a)
n = i
x[i] = x[0] + r * Math.Cos(_a)
y[i] = y[0] + r * Math.Sin(_a)
shp[i] = Shapes.AddEllipse(size, size)
Shapes.Move(shp[i], x[i] - size / 2, y[i] - size / 2)
i = i + 1
a = a + 45
r = r * 1.07
EndWhile
GraphicsWindow.PenWidth = 2
GraphicsWindow.PenColor = "LightGray"
For k = 1 To 8
x1 = x[0]
y1 = y[0]
For j = k + 8 To n Step 8
x2 = x[j]
y2 = y[j]
GraphicsWindow.DrawLine(x1, y1, x2, y2)
AddDots()
x1 = x2
y1 = y2
EndFor
EndFor
For j = 9 To n
x2 = x[j]
y2 = y[j]
If 9 < j Then
GraphicsWindow.DrawLine(x1, y1, x2, y2)
AddDots()
EndIf
x1 = x2
y1 = y2
EndFor

Sub AddDots
_x = x2 - x1
_y = y2 - y1
len = Math.SquareRoot(_x * _x + _y * _y)
m = Math.Floor(len / gap)
If 2 <= m Then
GraphicsWindow.PenWidth = 0
r = 1 / m
For l = 1 To m - 1
i = i + 1
x[i] = x1 * (1 - r) + x2 * r
y[i] = y1 * (1 - r) + y2 * r
shp[i] = Shapes.AddEllipse(size, size)
Shapes.Move(shp[i], x[i] - size / 2, y[i] - size / 2)
r = r + 1 / m
EndFor
GraphicsWindow.PenWidth = 2
EndIf
EndSub