Sub AddRectangle
i = i + 1
GraphicsWindow.PenColor = pc
GraphicsWindow.PenWidth = pw
GraphicsWindow.BrushColor = bc
shp[i] = Shapes.AddRectangle(width, height)
Shapes.Move(shp[i], x, y)
Shapes.Rotate(shp[i], angle)
Shapes.SetOpacity(shp[i], op)
EndSub
Sub AddText
i = i + 1
GraphicsWindow.BrushColor = bc
GraphicsWindow.FontSize = fs
GraphicsWindow.FontBold = fb
GraphicsWindow.FontItalic = fi
GraphicsWindow.FontName = fn
shp[i] = Shapes.AddText(txt)
Shapes.Move(shp[i], x, y)
Shapes.Rotate(shp[i], angle)
Shapes.SetOpacity(shp[i], op)
EndSub
Sub AddTriangle
i = i + 1
GraphicsWindow.PenColor = pc
GraphicsWindow.PenWidth = pw
GraphicsWindow.BrushColor = bc
shp[i] = Shapes.AddTriangle(x1, y1, x2, y2, x3, y3)
Shapes.Move(shp[i], x, y)
Shapes.Rotate(shp[i], angle)
Shapes.SetOpacity(shp[i], op)
EndSub
Sub Delay
t = Clock.ElapsedMilliseconds
mouseDown = "False"
While Clock.ElapsedMilliseconds < (t + 3000)
If mouseDown Then
If op = 100 Then
op = 70
Else
op = 100
EndIF
For i = 1 To Array.GetItemCount(shp)
Shapes.SetOpacity(shp[i], op)
EndFor
mouseDown = "False"
EndIf
EndWhile
EndSub
Sub Init
Not = "True=False;False=True;"
gw = 598
gh = 428
GraphicsWindow.Width = gw
GraphicsWindow.Height = gh
GraphicsWindow.PenWidth = 0
op = 100
fn = "Trebuchet MS"
fs = 20
fb = "True"
fi = "False"
GraphicsWindow.MouseDown = OnMouseDown
EndSub
Sub OnMouseDown
mouseDown = "True"
EndSub
Sub RemoveShapes
n = Array.GetItemCount(shp)
For i = 1 To n
Shapes.Remove(shp[i])
shp[i] = ""
EndFor
EndSub
Sub Math_CartesianToPolar
' Math | convert cartesian coodinate To polar coordinate
' param x, y - cartesian coordinate
' return r, a - polar coordinate
r = Math.SquareRoot(x * x + y * y)
If x = 0 And y > 0 Then
a = 90 ' [degree]
ElseIf x = 0 And y < 0 Then
a = -90
ElseIf x = 0 Then
a = 0
Else
a = Math.ArcTan(y / x) * 180 / Math.Pi
EndIf
If x < 0 Then
a = a + 180
ElseIf x >= 0 And y < 0 Then
a = a + 360
EndIf
EndSub