Microsoft Small Basic

Program Listing: ZTR830
Stack.PushValue("x1", 10)
Stack.PushValue("y1", 600)
Stack.PushValue("x2", 1200)
Stack.PushValue("y2", 100)
Turn = Math.pi/3.0
GraphicsWindow.Height = 700
GraphicsWindow.Width=1300
GraphicsWindow.Left=10
GraphicsWindow.top=10
GraphicsWindow.PenWidth=1
previousLen = -1

While Stack.GetCount("x1") > 0
x1 = Stack.PopValue("x1")
y1 = Stack.PopValue("y1")
x2 = Stack.PopValue("x2")
y2 = Stack.PopValue("y2")
len = Math.SquareRoot((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
If len > 1000 Then
GraphicsWindow.PenColor = "Wheat"
ElseIf len > 500 then
GraphicsWindow.PenColor = "LightGray"
ElseIf len > 150 then
GraphicsWindow.PenColor = "Gray"
ElseIf len > 90 then
GraphicsWindow.PenColor = "DarkBlue"
ElseIf len > 30 then
GraphicsWindow.PenColor = "Brown"
elseif len > 1 then
GraphicsWindow.PenColor = "DarkGray"
Else
GraphicsWindow.PenColor = "Black"
EndIf
GraphicsWindow.PenWidth = Math.Max(1, len / 20)
GraphicsWindow.DrawLine(x1,y1,x2,y2)
If len > .5 Then
ang = Math.ArcTan( (y2-y1)/(x2-x1) )
If x2 len = -len
EndIf
x2 = x1 + Math.Cos(ang)*len/3.0
y2 = y1 + Math.Sin(ang)*len/3.0
PushAndSwap()

x2 = x1 + Math.Cos(ang-turn)*len/3.0
y2 = y1 + Math.Sin(ang-turn)*len/3.0
PushAndSwap()

x2 = x1 + Math.Cos(ang+turn)*len/3.0
y2 = y1 + Math.Sin(ang+turn)*len/3.0
PushAndSwap()

x2 = x1 + Math.Cos(ang)*len/3.0
y2 = y1 + Math.Sin(ang)*len/3.0
PushAndSwap()
EndIf
EndWhile

Sub PushAndSwap
Stack.PushValue("x1", x1)
Stack.PushValue("y1", y1)
Stack.PushValue("x2", x2)
Stack.PushValue("y2", y2)
x1 = x2
y1 = y2
EndSub