GraphicsWindow.Show()

GraphicsWindow.MouseDown = OnMouseDown
GraphicsWindow.MouseMove = OnMouseMove

PenColorText = Shapes.AddText("")
Shapes.Move(PenColorText, 10, 10)
ShowPenColor()

Sub ShowPenColor
  Shapes.SetText(PenColorText, "Pen Color: " + GraphicsWindow.PenColor)
EndSub

Sub OnMouseDown
  prevX = GraphicsWindow.MouseX
  prevY = GraphicsWindow.MouseY
  If Mouse.IsRightButtonDown Then
    GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor()
    ShowPenColor()
  EndIf
EndSub

Sub OnMouseMove
  X = GraphicsWindow.MouseX
  Y = GraphicsWindow.MouseY
  If Mouse.IsLeftButtonDown Then
    GraphicsWindow.DrawLine(prevX, prevY, X, Y)
  EndIf
  prevX = X
  prevY = Y
EndSub
