Microsoft Small Basic

Program Listing: QWB852
'Published ID#
'Set the ClickMouse recipe (below) to be called when the mouse is clicked
ProgramWindow.MouseClicked = ClickMouse
'ClearTheScreen (recipe below) --#23
ClearTheScreen()
'PrepareColorPalette (recipe below) --#15
PrepareColorPalette()

'------------- Recipe for ClickMouse --#3
Sub ClickMouse
' Play a chime --#2
Sound.PlayChime()
' If the right mouse button is clicked, then --#24
If (Mouse.IsRightButtonDown) Then
' ClearTheScreen (recipe below) --#26
ClearTheScreen()
' Otherwise --#25
Else
' ConnectTheDots (recipe below) --#6
ConnectTheDots()
EndIf
'------------- End of ClickMouse recipe --#3
EndSub

'------------- Recipe for ConnectTheDots --#5
Sub ConnectTheDots
' AddACircle (reipe below) --#10
AddACircle()
' Show the tortoise --#1
Tortoise.Show()
' Move the tortoise to the current position of the mouse --#7
Tortoise.MoveTo(ProgramWindow.GetMouseX(), ProgramWindow.GetMouseY())
'------------- End of ConnectTheDots recipe --#5
EndSub

'------------- Recipe for AddACircle --#9
Sub AddACircle
' The radius of the circle is 7 --#8.2
radius = 7
' Change the color for the next shape to the next color from the color wheel --#11
ShapeMaker.SetColorForNextShape(ColorWheel.GetNextColor())
' Create a circle --#8.1
circle = ShapeMaker.CreateCircle(radius)
' Change the circle to be 40% opaque --#13
ShapeMaker.SetOpacity(circle, 40)
' Move the center of the circle to the current position of the mouse --#8.0
ShapeMaker.CenterShapeAt(circle, ProgramWindow.GetMouseX(), ProgramWindow.GetMouseY())
'------------- End of AddACircle recipe --#9
EndSub

'------------- Recipe for ClearTheScreen --#22
Sub ClearTheScreen
' Clear the Program Window --#27
ProgramWindow.Clear()
' Write "Right click to clear" on the screen at position 100, 100 --#21
ProgramWindow.DrawText("Right click to clear",100,100)
'------------- End of ClearTheScreen recipe --#22
EndSub

'------------- Recipe for PrepareColorPalette --#14
Sub PrepareColorPalette
' Add red to the color wheel --#12
ColorWheel.AddColor(Colors.Red)
' Add green to the color wheel --#20
ColorWheel.AddColor(Colors.Green)
' Add blue to the color wheel --#19
ColorWheel.AddColor(Colors.Blue)
' Add purple to the color wheel --#18
ColorWheel.AddColor(Colors.Purple)
' Add pink to the color wheel --#17
ColorWheel.AddColor(Colors.Pink)
' Add teal to the color wheel --#16
ColorWheel.AddColor(Colors.Teal)
'------------- End of PrepareColorPalette recipe --#14
EndSub